> I think this is a bad idea for performance reasons. Notice that it's
> not only memory issues: It's also the issue of displaying on screen.
> Displaying on screen is the most important bottleneck, and it has to
> be fast. It will not be fast if the fundamental data structure is
> one character at a time.
>
> Please take a look at the "new" kernel I wrote last year. That took
> the approach of having a "chunk" as the fundamental unit. A chunk is
> defined as a string of characters with the same character attributes.
> As a special case, a chunk could also be an inset, although insets
> were called elements for interoperability reasons.
I've looked for your kernel in the 'lyx' cvs module, but the code there is
incomplete. Is there a working version of your kernel? Is it still the plan
to use it instead of the current kernel? When?
For the current kernel, I thought of the following changes to the way the fonts
are stored by the LyX paragraph class:
1. The paragraph stores a vector (FontList) of pairs (position, font),
sorted by positions, containing the positions in the paragraph in which the font
changes, and the corresponding fonts.
2. The text vector stores special chars between the font changes.
This chars are rendered on the screen (for example, a small red dot).
For example, if the paragraph is "abc def ghi" where def is in bold, then
the paragrah text vector will contain "abc $def$ ghi",
and FontList will be {(0,default font),(5,bold),(9,default font)}.
Here are the advantages of the above suggestion:
1. Speed. The current rendering code (e.g., LyXText::draw) checks the font for each
character. This will be eliminated (font change occur only when the special
char is encountered)
2. Improved UI: When you place the cursor on the boundary between two fonts,
it is currently not always clear which font is going to be used.
This will be fixed by (2). Furthermore, it will give visual cue when
changing font attribute that doesn't have a visual effect (like language).
The only disadvantage is that it will give a different UI which will need getting
used to.
Any comments?