In Notepad++, when select a word by double click or by cursor select, all other occurrences of the word will be selected.
What is the API to call to achieve this in Win32 (C++) platform.
You can set
highlight.current.word=1
in SciTEUser.properties
file which can be accessed from the menu Options > Open User Options File
.
More options refers to https://www.scintilla.org/SciTEDoc.html .
I have added my own approach to highlighting all occurrences of the current selection...
First, I added these functions to my SciTEstartup.lua
script:
function clearOccurrences()
scite.SendEditor(SCI_SETINDICATORCURRENT, 0)
scite.SendEditor(SCI_INDICATORCLEARRANGE, 0, editor.Length)
end
function markOccurrences()
if editor.SelectionStart == editor.SelectionEnd then
return
end
clearOccurrences()
scite.SendEditor(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX)
scite.SendEditor(SCI_INDICSETFORE, 0, 255)
local txt = GetCurrentWord()
--print "in markOccurrences()..."
local occurrences = 0
local flags = SCFIND_WHOLEWORD
local s,e = editor:findtext(txt,flags,0)
while s do
scite.SendEditor(SCI_INDICATORFILLRANGE, s, e - s)
occurrences = occurrences + 1
s,e = editor:findtext(txt,flags,e+1)
end
print("found "..tostring(occurrences).." occurrences")
end
Then I assigned Shortcut Keys to these functions in the ScitEUser.properties
files assigning highlight occurrences with "Ctrl-." and clearing with "Ctrl-,"
# from http://lua-users.org/wiki/SciteMarkWord
command.name.37.*=markOccurrences
command.mode.37.*=subsystem:lua,savebefore:no
command.37.*=markOccurrences
command.shortcut.37.*=Ctrl+.
command.name.38.*=clearOccurrences
command.mode.38.*=subsystem:lua,savebefore:no
command.38.*=clearOccurrences
command.shortcut.38.*=Ctrl+,
Please checkout the "MatchMarker.cxx" file in SciTE source.