User.propertes
Code: Select all
command.name.5.*=自定义折叠
command.mode.5.*=subsystem:lua,savebefore:no,groupundo
command.shortcut.5.*=Alt+z
command.5.*=CommentFold
userluascrpt.lua
Code: Select all
--~========================================================================
--Scite中, 用鼠标框选区域, 代码折叠.
--首尾添加注释代码;首:{ •••➤ 尾: ;}
function CommentFold()
local p1=editor.SelectionStart
local p2=editor.SelectionEnd
local L1=editor:LineFromPosition(p1)
local L2=editor:LineFromPosition(p2)
--~ 符号 字节长=3
local s = "\t;{ -----❄❄"
local m = #s
if L1~=L2 then
local Asc = {[9]=1,[13]=1}
--~ local Asc = {[0]=1,[9]=1,[10]=1,[13]=1,[32]=1,[34]=1,[39]=1,[44]=1}
--~停止字符集合: 9=Tab,13=Enter, --[0]=1,[10]=1,[13]=1,[32]=1,[34]=1,[39]=1,[44]=1
while Asc[editor.CharAt[p1]] == nil do
p1 = p1 + 1
end
--~防止框选到最后一行时, 计算出错.
while Asc[editor.CharAt[p2]] == nil and p2<editor.LineEndPosition[editor.LineCount ] do
p2 = p2 + 1
end
--~ print(p2)
editor:InsertText(p1,s)
editor:InsertText(p2+m,"\t;}")
editor:GotoPos(p1+m-3)
--~ 同时发送折叠命令
editor:ToggleFold(L1)
end
end