블록으로 지정한 구간을 정렬해준다. 자주 쓰이지는 않지만, 그래도 아쉬울 때가 있다. SciteSortSelection에서 가져와 extman에 등록해서 사용할 수 있도록 수정했다.
SciTE_SortSelection.lua
SciTE_SortSelection.lua
-- Sort a selected text-- The functions below will sort the selected text in alphabetical or alphabetical reverse order.-- From http://lua-users.org/wiki/SciteSortSelectionscite_Command {'Sort Selection|sort_text','Sort Selection Reverse|sort_text_reverse',}function lines(str)local t = {}local i, lstr = 1, #strwhile i <= lstr dolocal x, y = string.find(str, "\r?\n", i)if x then t[#t + 1] = string.sub(str, i, x - 1)else breakendi = y + 1endif i <= lstr then t[#t + 1] = string.sub(str, i) endreturn tendfunction sort_text()local sel = editor:GetSelText()if #sel == 0 then return endlocal eol = string.match(sel, "\n$")local buf = lines(sel)--table.foreach(buf, print) --used for debuggingtable.sort(buf)local out = table.concat(buf, "\n")if eol then out = out.."\n" endeditor:ReplaceSel(out)endfunction sort_text_reverse()local sel = editor:GetSelText()if #sel == 0 then return endlocal eol = string.match(sel, "\n$")local buf = lines(sel)--table.foreach(buf, print) --used for debuggingtable.sort(buf, function(a, b) return a > b end)local out = table.concat(buf, "\n")if eol then out = out.."\n" endeditor:ReplaceSel(out)end




덧글