The Number of occurrences is then shown in the statusbar.
There are two parts.
First append this to ahk.lua:
I know you shouldn't do that because changes are overwritten on updates,
but I don't know another place to put it.
Code: Select all
-- from http://lua-users.org/wiki/SciteMarkWord
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()
local count = 0
local flags = SCFIND_WHOLEWORD
local s,e = editor:findtext(txt,flags,0)
while s do
scite.SendEditor(SCI_INDICATORFILLRANGE, s, e - s)
s,e = editor:findtext(txt,flags,e+1)
-- added from me
count = count +1
--
end
-- added from me
props['countedOccurrences'] = count
props['markedWord'] = txt
--
return
end
function isWordChar(char)
local strChar = string.char(char)
local beginIndex = string.find(strChar, '%w')
if beginIndex ~= nil then
return true
end
if strChar == '_' or strChar == '$' then
return true
end
return false
end
function GetCurrentWord()
local beginPos = editor.CurrentPos
local endPos = beginPos
if editor.SelectionStart ~= editor.SelectionEnd then
return editor:GetSelText()
end
while isWordChar(editor.CharAt[beginPos-1]) do
beginPos = beginPos - 1
end
while isWordChar(editor.CharAt[endPos]) do
endPos = endPos + 1
end
return editor:textrange(beginPos,endPos)
end
-- Add user event handler OnDoubleClick
-- found somewhere
local old_OnDoubleClick = OnDoubleClick
function OnDoubleClick(shift, ctrl, alt)
local result
if old_OnDoubleClick then result = old_OnDoubleClick(shift, ctrl, alt) end
if markOccurrences() then return true end
return result
end
and add:
Code: Select all
highlight.current.word=1
statusbar.text.1=\
Line: $(LineNumber) | Column: $(ColumnNumber) | $(OverType) | ($(EOLMode)) | $(FileAttr) | $(countedOccurrences) Occurrences of "$(markedWord)" found
Perhaps fincs can add something like this to Scite4Autohotkey.
Especially for the search it would be nice to have a counter.
I know nothing about lua and scite, so i can't help if there are questions. Sorry.
But nevertheless i hope this could be helpful.