Dov Feldstern <[EMAIL PROTECTED]> writes:
> I've been working on the ignore-spell-check feature using character
> attributes (actually inside Font), but I'm having trouble with this. I
> think much of the trouble is that I don't understand the intricacies
> of Fonts (realized fonts, inheritance/ignore, how fonts are copied,
> etc.).
I think you are not too far. See my comment below, which should get
you started if you find the energy to start again :)
> But more fundamentally, it's probably wrong to be doing this inside
> Font. I've been trying to do that mainly because Font already
> provides the kind of infrastructure that I want for a
> character-based attribute (font spans, and a mechanism for writing
> and reading this from the .lyx file).
Adding no-spellcheck is not worth than this horrible encoding-related
thing that is already there :)
I understand what you mean, but I still think that using font until
font is rewritten to become something else. We can maybe rename Font
the CharProps and be happy :)
Comments below.
JMarc
> Font::Font()
> - : bits(sane), lang(default_language), open_encoding_(false)
> + : bits(sane), lang(default_language), ignore_spelling(false),
> + open_encoding_(false)
> {}
I think that ignore_spelling should go inside FontBits, probably as a
separate FONT_MISC_STATE. What do the values say?
ON: force to enabled
OFF: force to disabled
INHERIT: do what the underlying font does (meaning this value is
undefined at this level, and font.resolve will be needed to know the
value). This is the fon't care value.
TOGGLE and IGNORE are used by the character dialog.
The thing to understand is that, if you do like what for ex. underline
or emph do, you are safe, even if you do no understand :)
> + } else if (token == "\\spelling") {
> + lex.next();
> + string const tok = lex.getString();
> + if (tok == "off")
> + font.setIgnoreSpelling(true);
> + else if (tok == "on")
> + font.setIgnoreSpelling(false);
> + else
> + // FIXME: assert? error? for now just assuming on...
> + font.setIgnoreSpelling(false);
Do the same as emph.
> if (inset->asTextInset()) {
> - inset->asTextInset()->text_.current_font = font;
> - inset->asTextInset()->text_.real_current_font = font;
> + Font font_copy = font;
> + if (inset->lyxCode() == Inset::NOTE_CODE)
> + font_copy.setIgnoreSpelling(true);
> + inset->asTextInset()->text_.current_font = font_copy;
> + inset->asTextInset()->text_.real_current_font = font_copy;
> }
> }
I think forcing a font like that is a bad idea. If you want to act on
inset properties, it is better to use a noSpellCheck virtual method in
the spellchecker. Do not mix different things.