[Geany-Devel] pull request on GitHub, to add GeanyHighlightSelectedWords, into Geany Plugins
mbrush at xxxxx
Sat May 30 01:19:29 UTC 2015
On 2015-05-29 06:09 PM, Colomban Wendling wrote:
> Le 30/05/2015 01:45, Matthew Brush a écrit :
>> - Remove the "Mark All" keybinding. Also make these new indicator types
>> not cleared by the "Document->Remove Markers" menu item.
> As said on IRC, I probably would rather combine the two feature (current
> "mark all" [shift-ctrl+m] and this dynamic version of it).
> E.g, have a setting in the preferences "Dynamically mark the current
> word" that decides whether mark all is dynamic or not, and have
> shift+ctrl+m toggle the marking, whether it's dynamic or not.
>> - If there is a current word and it's different from the last one, clear
>> the indicators and then have Scintilla close its gap buffer by getting
>> the character pointer to it.
>> - Use strstr() starting at the character pointer to the buffer start,
>> comparing the bytes with the bytes of the current word, working its way
>> through the whole document.
>> - For each non-NULL return of strstr(), set an indicator at position
>> `foundPtr - docStartPtr` with the indicator length as the number of
>> bytes in the current word, and then use strstr() again starting at
>> `foundPtr + currentWordLength`, repeat to end.
> Why not use the basic Scintilla search features? It should be fast and
> do just what you want just as easily -- and look like it's the expected
> way you do it, which may even not need closing the gave or something.
Just because it's such a trivial search algorithm, using strstr() is
much more simple and probably more efficient than using Scintilla's API
to find text, but if manual and automatic mode is supported, it would
make sense to share the existing code, and that beats out advantage
having a redundant (yet simpler/faster) routine to do same, IMO. +1 (if
it's not too much hassle to refactor "Mark All").
>> Does that sound fairly reasonable?
>> The only thing I'm not 100% sure about is handling of multi-byte
>> characters in the UTF-8 of the wordchars or the buffer, but it seems
>> like it should "just work" since it's just comparing raw bytes, and at
>> worst, setting a indicator position in Scintilla that is between two
>> bytes of the same multi-byte char (but not moving the caret there, so no
>> weird editing bugs).
> you shouldn't have to worry about that. we already have a way to get
> the word under cursor, so just use that and don't worry about how it's
> done (we can always fix it if it doesn't get it right, but it seem to be
> good enough as nobody complained).
More information about the Devel