4 Dec 2008 14:40
Re: word wrap really slow
Alexey Semenyuk <ferry.admin <at> googlemail.com>
2008-12-04 13:40:21 GMT
2008-12-04 13:40:21 GMT
On Nov 23, 3:17 am, "Neil Hodgson" <nyamaton... <at> gmail.com> wrote: > Marko Mahnič: > > > One solution would be to stop lexing just after the last visible > > line and mark the rest of the file as "unlexed". The lexing would > > then be redone when an unlexed line is accessed or displayed. > > This is how it works but in order to determine the document height, > all the following lines need to be measured which requires them to be > lexed. The document height calculation can be different. This is the key to solve the problem. The most obvious approach is to measure document height in text lines and treat every wrapped text line segment as a distinct item. This helps to keep vertical scrolling calculations simple. Another simplification is to have all text lines have fixed height. The drawback of this approach is that complexity of scroll calculations is O(n), where n - number of text lines. So the bigger text file you edit, the more time is needed to calculate vertical scrolling, as you need to wrap all text lines to get vertical scroll limit. And every time you resize the editor's window you need to apply text wrap to entire file as well. Another approach is to measure vertical scroll in bytes. This adds extra complexity though doesn't suffer from the issues specific to the first approach. So the <scroll limit> = <text length in bytes> - <number of bytes that fit in the screen when the first text byte is visible>. Scroll page is fixed and equal to 1.(Continue reading)
RSS Feed