Le 28/04/2013 13:06, pdv a écrit :
OK, here is a new version. Let me know if you experience anymore
problems.
For the time being I've left the clean-up step of the map as it was,
although I realize it's of limited value; when entering the same word
multiple times, the partial words get included anyway;
The map itself is still defined in the BufferView class, but as a shared
static map. The reason for this is that when the user makes changes to
the screen fonts, the map becomes useless and I think the best option is
to clear it at that point.
I've added the case LFUN_SCREEN_FONT_UPDATE: to BufferView::dispatch()
and added a corresponding request in GuiApplication::dispatch();
You should move the code that computes text width to
GuiFontMetrics::width(docstring). This is the right place for storing a
map, that could be static if you want to keep your current solution or
just a member of the GuiFontMetrics object so that you do not have to
play tricks with font attributes.
Moreover, if your mùap is in GuiFontMetrics it will be reset
automatically by the code in GuiApplication.cpp.
This will be much easier in my opinion.
I noticed then that the map was cleared and rebuild twice ...
... because in GuiPreferences::dispatchParams() there is first a call
dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()))
later followed by
dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE))
but the first dispatch runs GuiReset() which also sends a
LFUN_SCREEN_FONT_UPDATE.
Therefore I've commented out the 2nd explicit LFUN_SCREEN_FONT_UPDATE
request.
Not sure about that, but things should become clearer once code is at
the right place.
JMarc