커서 위치의 단어와 동일한 단어를 문서 전체에서 찾아 표시해준다. 특히 함수 등에서 특정 변수가 어디 어디에 쓰이고 있는지 분석할 때 아주 유용하다. SciteMarkWord에서 가져와 extman에 등록해서 사용할 수 있도록 수정했다.
SciTE_MarkWord.lua
SciTE_MarkWord.lua
-- Scite Mark Word-- You can use this to mark all occurrences of a word in the document.-- From http://lua-users.org/wiki/SciteMarkWordscite_Command {'Mark Occurences|markOccurrences|Ctrl+,','Clear Occurences|clearOccurrences|Alt+,',}function clearOccurrences()scite.SendEditor(SCI_INDICATORCLEARRANGE, 0, editor.Length)endfunction markOccurrences()clearOccurrences()scite.SendEditor(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX)scite.SendEditor(SCI_INDICSETFORE, 0, 255)local txt = GetCurrentWord()local flags = SCFIND_WHOLEWORDlocal s,e = editor:findtext(txt,flags,0)while s doscite.SendEditor(SCI_INDICATORFILLRANGE, s, e - s)s,e = editor:findtext(txt,flags,e+1)endendfunction isWordChar(char)local strChar = string.char(char)local beginIndex = string.find(strChar, '%w')if beginIndex ~= nil thenreturn trueendif strChar == '_' or strChar == '$' thenreturn trueendreturn falseendfunction GetCurrentWord()local beginPos = editor.CurrentPoslocal endPos = beginPosif editor.SelectionStart ~= editor.SelectionEnd thenreturn editor:GetSelText()endwhile isWordChar(editor.CharAt[beginPos-1]) dobeginPos = beginPos - 1endwhile isWordChar(editor.CharAt[endPos]) doendPos = endPos + 1endreturn editor:textrange(beginPos,endPos)end




덧글