[SciTE] 문서 내에서 같은 단어 찾아 표시하기 by tactlee

커서 위치의 단어와 동일한 단어를 문서 전체에서 찾아 표시해준다. 특히 함수 등에서 특정 변수가 어디 어디에 쓰이고 있는지 분석할 때 아주 유용하다. SciteMarkWord에서 가져와 extman에 등록해서 사용할 수 있도록 수정했다.

SciTE_MarkWord.lua
  1. -- Scite Mark Word
  2. -- You can use this to mark all occurrences of a word in the document.
  3. -- From http://lua-users.org/wiki/SciteMarkWord

  4. scite_Command {
  5.     'Mark Occurences|markOccurrences|Ctrl+,',
  6.     'Clear Occurences|clearOccurrences|Alt+,',
  7. }

  8. function clearOccurrences()
  9.     scite.SendEditor(SCI_INDICATORCLEARRANGE, 0, editor.Length)
  10. end

  11. function markOccurrences()
  12.     clearOccurrences()
  13.     scite.SendEditor(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX)
  14.     scite.SendEditor(SCI_INDICSETFORE, 0255)
  15.     local txt = GetCurrentWord()
  16.     local flags = SCFIND_WHOLEWORD
  17.     local s,e = editor:findtext(txt,flags,0)
  18.     while s do
  19.         scite.SendEditor(SCI_INDICATORFILLRANGE, s, e - s)
  20.         s,e = editor:findtext(txt,flags,e+1)
  21.     end
  22. end

  23. function isWordChar(char)
  24.     local strChar = string.char(char)
  25.     local beginIndex = string.find(strChar, '%w')
  26.     if beginIndex ~= nil then
  27.         return true
  28.     end
  29.     if strChar == '_' or strChar == '$' then
  30.         return true
  31.     end

  32.     return false
  33. end

  34. function GetCurrentWord()
  35.     local beginPos = editor.CurrentPos
  36.     local endPos = beginPos
  37.     if editor.SelectionStart ~= editor.SelectionEnd then
  38.         return editor:GetSelText()
  39.     end
  40.     while isWordChar(editor.CharAt[beginPos-1]) do
  41.         beginPos = beginPos - 1
  42.     end
  43.     while isWordChar(editor.CharAt[endPos]) do
  44.         endPos = endPos + 1
  45.     end
  46.     return editor:textrange(beginPos,endPos)
  47. end

트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://tactlee.egloos.com/tb/1646918 [도움말]

덧글

덧글 입력 영역


GirlsWatch