Re: Fwd: Smart quotes patch

From: Martin Sevior <martines_at_unimelb.edu.au>
Date: Fri Feb 08 2008 - 04:46:29 CET

Hi Bobby,
        uwog and I had talk on IRC today and decided getting all this
to work correctly will require some more surgery to the src/text/fmt/xp
classes (the formatter classes).

For a start the original code where the plain quote's were replaced in
the PieceTable with curly quotes is fundamentally broken. It won't work
with undo and will screw up abicollab.

We can't use that technique to do this right.

What we need to do is to replace the quote in the formatter classes with
the curly quotes and insert special change record into the PieceTable as
well. We can use the special change record to get the undo behaviour
Tomas describes.

The we need to create a new subclass of fp_TextRun.cpp, call it
fp_SmartQuoteRun.cpp. All this does to draw the appropriate curly quote
INSTEAD of the regular quote.

So I envisage this happening:

Current code to detect a smart quote replacement identifies said quote.

The text run before and after the quote is split. A new
fp_SmartQuoteRun.cpp is inserted over the top of the smart quote. The
only thing this run does different from a regular fp_TextRun.cpp is it
just draws the appropriate smart quote instead of the character located
in the document model at this position.

To get undo to work right we also need to create a new type of
changeRecord.

Regarding the set language option, it used to enable different languages
to be correct spell checked within the same document. The is quite a
common feature of European documents.

Regarding who decides what goes in, the core developers generally reach
concensus.

If the feature works or is likely to made to work and does not cause
regressions we're generally pretty easy going.

In the case of smart quotes, this feature was removed because it
resulted in a fundamentally unstable document state. We need to fix that
before we allow this feature.

I believe the fp_SmartQuoteRun.cpp approach I outlined above will do
that.

Cheers

Martin
 

On Thu, 2008-02-07 at 21:51 -0500, Bobby Weinmann wrote:
> On Feb 7, 2008 4:45 AM, Tomas Frydrych <tf@o-hand.com> wrote:
> > Nope, undo immediately after smart-quote replacement should revert back
> > to the plain quote. Only a second undo should remove the actual insertion.
>
> This makes no sense to me, since if you don't want smart quotes, just
> disable them.
>
> However, I tried it in Word, and it works as you said, so QED, you win.
>
>
> > Add strings for the four or so quote types to the XAPString tables as I
> > suggested. This allows you to fine grain it as needed (e.g., can have
> > different quotes for de-DE and de-CH).
>
> Yes however, I have been using this as my guide:
> http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
>
> Wherein it states:
> - Sometimes, especially in books, the angle quotation marks (see
> below) are used in Germany and Austria, albeit in reversed order: »O«.
>
> This may be wrong. Can a German confirm or deny it?
>
> Assuming it is true, one locale can have more than one quoting system.
>
> >
> > > 2) How to switch languages period. If I type an English article with
> > > a German quote, what do you do?
> >
> > You switch language to German *before* starting the quote.
> >
> > > Someone suggested checking the
> > > language of the previous character, but that doesn't work for the same
> > > reason it looks like smart quotes were always broken - paragraphs
> > > often start with quotes, which means you have no previous character.
> >
> > You do not check the language of the previous character, but the
> > language at the insertion point.
> >
> > > I think the best solution would be a tool bar or dialog option that
> > > allows you to set the quote marks to whatever funky combination your
> > > language/locale uses.
> >
> > Nope, this should just work without the user having to mess about with
> > anything.
>
> I had never used the "Set Language" option before. I have now
> explored it a little, and this approach has some major problems:
> 1) See above about multiple quotation styles for one locale.
> 2) There is a "no proofing" option. A German might use this to turn
> off spell checking, but might still want German smart quotes.
> 3) It does not save my preference between documents. I assume it just
> reverts to the machine's locale, in which case, that's probably OK.
> 4) As I said, I had never heard of the option before, because I never
> had a need for it. If I wish to type in Hebrew, which I sometimes do,
> I change the keymap for my desktop and change Abiword to default the
> document to RTL if I wish.
> 5) Is having to change the language not "having to mess about with anything."
>
> This seems like it's basically a spelling/grammar checking option
> which is being repurposed for a function it doesn't match.
>
> >
> > > I'd also like to add the option to translate bactick "`" to open quote
> > > and apostrophe "'" to close quote. In English, it is impossible for
> > > the word processor to figure out whether an apostrophe at the
> > > beginning of a word is the start of a quote or an abbreviation used in
> > > speech ('em for them).
> >
> > I am not too sure about adding an option for this; it strikes me as a
> > marginal case and it is easy to work around.
>
> I disagree completely that this is a marginal case.
>
> Harry Potter books are the best selling books of all time (with the
> exception of the Bible). Read anything said by Hagrid, it is littered
> with these. Other authors start words with apostrophes in dialog all
> the time. Not to mention, one of the most famous English poems,
> "'Twas the night before Christmas."
>
> Though, you did mention a work-around, what did you mean?
>
> My proposal is to have a smart quotes tab in the options dialog (as in
> the patch I submitted). To this I would add a combobox with a list of
> predefined list of smart quote styles and a separate table tying each
> style to a locale. One of the entries would be "Custom" which would
> enable you to set the quote characters manually. Abiword would store
> the quote settings for each of the 4 quote chars. If no setting
> exists, it would default to the current locale's default.
>
> A user need not make any changes if they want it to "just work" for
> the default of their locale. If they change it, it is stored across
> sessions. If you need to switch quotes in the middle of a document,
> you go to the dialog and change it.
>
> All this being said, I personally only need smart quotes for English.
> If I need to tie it to the language to get it accepted, so be it.
>
> BTW, who makes decisions about what is in or out of Abiword?
>
> Bobby
Received on Fri Feb 8 05:13:53 2008

This archive was generated by hypermail 2.1.8 : Fri Feb 08 2008 - 05:13:53 CET