Scite 标记词 |
|
您应该在您的 SciTEUser.properties 中添加类似的内容
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+,
以及您 SciTEStartup.lua 中的这个函数
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 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) end 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--Agust�n Fern�ndez, 2007 年 8 月 22 日
我在 markOccurrences 的顶部添加了一个对没有选择的测试 - 以防止 Scite(版本 3.5.2)在编辑器中没有选择时崩溃。
--Gavin Holt, 2014 年 12 月 20 日