Le 16 août 07 à 00:46, Dov Feldstern a écrit :
Hi!
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.). 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). But I'm running
into trouble, because there's just so much code all over the place
that deals with fonts, and since I don't understand it well enough,
I don't know what is safe to change and what isn't.
That seems not to be so simple indeed ;)
I'm attaching what I've got so far. It's very far from complete:
first and foremost, there's not even any UI yet for setting the
ignore-spelling attribute, yet! (I'm not even sure what kind of UI
we would want...); nor does the painting work --- I think it has to
do with how Text::getFont() gets the font, but again, I need a
better understanding of Font for that... What *is* working, though,
is that I've hard-coded into Paragraph.cpp something which ignores
spelling for notes by setting ignore to true --- and this does seem
to work (though there's a bug I only now noticed --- I'm only
checking the first character in each word to determine whether or
not it's to be ignored).
But anyhow, I'm not so sure anymore that my proposed approach is
really the way to go. Hijacking Font seems to be problematic, and
if we do decide its the way to go, I will need help. What I would
really like is some kind of mechanism which would allow me to
associate attributes with each position in the text, but I don't
think such a mechanism exists (besides Font) (For the record, I
still think that a character-attribute based solution is the
correct way to go, in order to keep things simple. But that doesn't
seem to be too east to achieve at the moment).
In the bigger picture, we still haven't really decided on the
requirements. I hear what people are saying, that this kind of
information doesn't belong in the file itself, but I'm not sure I
agree. I think that part of the problem is that some of the
features we've discussed really are more "preference-based",
whereas others are more "specific-text/instance-based" --- and
sometimes these two notions conflict. So I don't really know how to
continue...
Clearly, all about the spellchecker is currently preference-based.
But as we want to provide (among others) an instance level control,
some things would have to go into the file. However, these things
should never include type-level information, IMO.
So, the upshot is: here's my aborted-patch, but I don't think I
will continue with it unless someone thinks this is a direction
worth pursuing, and can provide some help; I don't know what the
correct way to deal with this issue is --- so far none of the
solutions seems to provide an answer to all the issues. So for now,
I'm supporting Mael's approach --- which solves some of the
problems, and isn't too intrusive --- provided that it'll be
possible to shut off all the ignores (i.e., to have the same
situation that we have today, where everything is spell-checked).
See the new patch at bugzilla (http://bugzilla.lyx.org/show_bug.cgi?
id=1509). Everything is spellchecked by default. It works already,
but with a temporary solution for the spellcheck insets (use of
notes; just for test purpose...).
Mael.