Scite 文件比较 |
|
将以下代码放入文件 compare_files.lua
中
-- -*- coding: utf-8 -*- local f1, f2 local diffTool local cmdNum = 48 -- menu commands occupy the last 2 slots if props["PLAT_WIN"] == "1" then diffTool = 'start /b C:\\"Program Files (x86)"\\Meld\\Meld.exe -n %q %q' else diffTool = "meld -n %q %q &" end local function setMenuCommands() local which which = "."..cmdNum..".*" props["command.name"..which] = f1 and "Add File to Comparison (1)" or "Add File to Comparison (0)" props["command.subsystem"..which] = 3 props["command"..which] = "addFileToComparison" props["command.mode"..which] = "savebefore:no" props["command.shortcut"..which] = "" which = "."..(cmdNum+1)..".*" props["command.name"..which] = f1 and "Reset File Comparison" or "" props["command.subsystem"..which] = 3 props["command"..which] = "resetFileComparison" props["command.mode"..which] = "savebefore:no" props["command.shortcut"..which] = "" end function addFileToComparison() if props["FileNameExt"] ~= "" then if f1 then f2 = props["FilePath"] if f2 ~= f1 then local exec = diffTool:format(f1, f2) resetFileComparison() os.execute(exec) else f2 = nil print("Error: Same file selected") end else f1 = props["FilePath"] setMenuCommands() end else print("Error: File not saved") end end function resetFileComparison() f1 = nil f2 = nil setMenuCommands() end setMenuCommands()
之后,使用 dofile
命令在您的 Lua 启动脚本中包含 compare_files.lua
。
--Andrey Moskalev--