为Scite添加自定义折叠Lua命令.(折叠区域为鼠标框选部分)Alt+z

优点: Lua速度无敌, 绝不出错.

操作步骤, 分以下两步:

一.  打开用户配置:

Options→ Open User Options File

选项→ 打开 User Options File

在SciTEUser.properties文件中, 添加以下代码:

#选择区域, 自动前后加折叠号
command.name.12.*=CommentFold注释折叠
command.mode.12.*=subsystem:lua,savebefore:no,groupundo
command.shortcut.12.*=Alt+z
command.12.*=CommentFold

二. 打开Scite目录下的自定义Lua文件. (文件名:  UserLuaScript.lua)

添加以下内容:

–Scite中, 用鼠标框选区域, 代码折叠.
–首尾添加注释代码;

–首行:{  •••➤  

–;50786729

–尾行:  ;}

function CommentFold()
    local p1=editor.SelectionStart
    local p2=editor.SelectionEnd    
    local L1=editor:LineFromPosition(p1)
    local L2=editor:LineFromPosition(p2)
    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
        editor:InsertText(p1,s)
        editor:InsertText(p2+m,”\t;}”)
        editor:GotoPos(p1+m)
        –~ 同时发送折叠命令
        scite.SendEditor(SCI_TOGGLEFOLD, L)
    end
end

给TA捐赠
共{{data.count}}人
人已捐赠
其他

任意窗口, 拖到屏幕上方向, 自动贴边隐藏(类似QQ).

2022-5-16 4:04:14

其他应用案例

原神用FindText做当前血量图像识别【1080P】

2022-5-17 8:40:09

4 条回复 A文章作者 M管理员
  1. AHK中文社区

    感谢分享

  2. AHK中文社区
    1河许人给您打赏了¥2
  3. doge

    学习学习

  4. Plastic

    > Lua: error checking global scope for command

    会报错呢楼主?

个人中心
购物车
优惠劵
有新私信 私信列表
搜索