Following the thread : http://groups.google.com/group/scite-interest/browse_thread/thread/5292678c868bef48/50dbfea3f37a4c48?show_docid=50dbfea3f37a4c48
I post this first mockup. There is still lot of work. For delay highlight, I don't see for now how to do this...
Neil but if you have some advice or requirements.
Feel free to provide it to me :)
Please find this new patch.
For now, only delay highlight is not implemented.
I created a couple of options, if you think that their names can be improve.
Neil, don't hesitate to propose it better.
You should be setting the current indicator before
wEditor.Call(SCI_INDICATORCLEARRANGE, 0, wEditor.Call(SCI_GETLENGTH));
in case the user has a script that works on indicators.
SciTEBase.cxx
..\src\SciTEBase.cxx(1146) : warning C4244: 'argument' : conversion from 'sptr_t' to 'char', possible loss of data
..\src\SciTEBase.cxx(1147) : warning C4244: 'argument' : conversion from 'sptr_t' to 'char', possible loss of data
hightlight -<> highlight
Please find this new patch that contains all the fixes.
Please find a new patch that fixes some bug .
For now, it's still one pb when I fold some block see screenshot with highlight.current.word.max=-1 (force to highlight all occurences of word.
If you have some clues. I try to detect fold/unfold with SCN_MODIFIED and SCNotification.modificationType with SC_MOD_CHANGEFOLD but that doesn't work.
I also work on optimized version that sets indicators only on the changed lines. But it's still some work (much more faster than unoptimized version). I will publish it when it will be more presentable.
I also have the problem to detect fold/unfold block with version.
Please find this optimized version.
I found a way to manage the fold/unfold and resize window with SCN_PAINTED and GUI::ScintillaWindow.InvalidateAll().
You can find it with the last optimized version (#2).
Limiting the number of matches just seems to be making this too complicated with the SCN_PAINTED handler and extra state.. It is better to implement something simple and then change it if there are problems. I'd drop all settings except for highlight.current.word and highlight.current.word.colour for now and only support 0 or 1 for highlight.current.word with 1 being the current option 2. The only requests have been for the editor window.
To minimize processing, highlighting could only be updated when SC_UPDATE_SELECTION set in the notification.
previousStyle is far too generic of a name to have in SciTEBase where many of the methods deal with styles. If there is more than one value used for managing the state of highlighting (as opposed to configuration) then they should be grouped into a struct or class.
Avoid allocations in favour of objects: there is a GetRange returning an SString so you don't have to bother with delete.
Can you put spaces after "if" to match other Scintilla code? And no spaces in calls or space before ':'.
Windows users rarely build from source so are unlikely to respond unless executables are available.
Ok, I remove some properties except :
- highlight.current.word that supports only 0 and 1 (with 1 highlight current selection or current word under the caret but not on its side)
- highlight.current.word.colour
- but I keep : highlight.current.word.by.style
To prevent highlight during input of user. I exclude the current word when the caret is on side on the word.
You can find this patch that manages SCI_LINEDUPLICATE and parses only new line.
By the way, I found inconsistency that describes into screenshot2.png. For now, I don't know where that comes from...
The optimization appears to be over-engineering. I thought this was going to be a simple little feature and the user would turn it off if it performed badly. Trying to decipher events like scrolls and resizes inside the highlighter is messy and there will probably be more cases where something is missed.
Hello Neil :
I've worked on both versions :
1- optimized version that parses the new visible lines only (Optimized_highlight_current_selected_word.5.tar.bz2).
2- normal version that parses all visibles lines on any significative changes (Highlight_current_selected_word.5.tar.bz2).
We can imaginate 3rd version (like the script scite-ru : http://scite-ru.googlecode.com/svn/trunk/pack/tools/highlighting_identical_text.lua\), that parses all document and that plugs on SCN_UPDATEUI notification. But I think that implies to limit number of highlight. Otherwise it will be too slow.
Both versions work without problem.
I manage all cases which calls HighlightCurrentWord method, and which seems possible for me :
1- Change of selection. Treated by SCN_UPDATEUI only if SC_UPDATE_SELECTION
2- During scroll or folding are occuring. Treated by SCN_PAINTED with call InvalidateAll() if needed. I had to add return of bool on SCI_INDICATORCLEARRANGE. The return is true when indicator is actually cleared otherwise false.
3- When duplication of line (SCI_LINEDUPLICATE). Treated by SCN_MODIFIED only when text added SC_MOD_INSERTTEXT. It's possible to drop this point if we don't highlight current word without selection.
Return condition of HighlightCurrentWord are :
1- No selection, and the caret is not on valid word (or on tip of the word).
2- There is selection, but it is not whole word.
3- There is selection, but it is not valid word (e.g. several words or lines)
4- No modification, when it's same selected word, same style, same visible lines. On this point, there is difference on both versions with forceBeginHighlightZone & lengthForceToParse for optimized version and lenDoc for normal one.
By the way, I took a look on Notepad++ source code. Notepad++ doesn't use SCN_PAINTED notification (that's good because it's frequently called, that reason why we need to have good return conditions) but it defines a new notification that only fires on the scroll up or down.
The result of not to use SCN_PAINTED are :
- no flash during the scroll and no need to call InvalidateAll().
- but in other hand, highlight is managed badly during the code fold.
In conclusion, I propose you both patches (with 3rd version without optimization like lua script of scite-ru), that allows you to decide which version is better for SciTE (for me, I prefer optimized version).
Or maybe do you think that the better way is abandon SCN_PAINTED (and bool with SCI_INDICATORCLEARRANGE) like Notepad++ with highlight is managed badly during the code fold.
For your information, I found where inconsistency comes from.
It's due to badly use of indicator with my sql lexer that tries to highlight error of PL/SQL since I didn't set the default current indicator (with pAccess->DecorationSetCurrentIndicator) into feature request [SQL] Add control for PL/SQL structure ID: 3181251
Jérôme