function SnowLexerMarkers () local new = "" if editor.SelectionStart == editor.SelectionEnd then editor:SelectAll() end local text = editor:GetSelText().."\n" local pos = editor.SelectionStart for str in string.gfind(text, "([^\n]*)\n") do -- get next line local newstr = "" local fin = "" local len = string.len(str) if string.sub(str,len,len) == "\r" then len = len - 1 str = string.sub(str,1,len) fin = "\r" end local style = scite.SendEditor(SCI_GETSTYLEAT, pos) local i0,i = 1,1 while i <= len do local nstyle repeat pos = pos + 1 i = i + 1 nstyle = scite.SendEditor(SCI_GETSTYLEAT, pos) until nstyle ~= style or i > len local txt = "["..style.."]"..string.sub(str,i0,i-1) i0 = i newstr = newstr..txt style = nstyle end -- append line to formated text if new ~= "" then new = new.."\n" end new = new..newstr..fin pos = pos + string.len(fin) + 1 end editor:ReplaceSel(new) end |