1
2 3 4 5 6 7 8 9 10 |
command.name.number.filepattern
command.number.filepattern command.is.filter.number.filepattern command.subsystem.number.filepattern command.save.before.number.filepattern command.input.number.filepattern command.replace.selection.number.filepattern command.quiet.number.filepattern command.mode.number.filepattern command.shortcut.number.filepattern |
1
2 3 |
command.name.0.*.cc=Indent
command.0.*.cc=astyle -taO $(FileNameExt) command.is.filter.0.*.cc=1 |
1
2 3 4 5 6 |
filter - accepts keyword arguments yes and no
quiet - accepts keyword arguments yes and no replaceselection - accepts yes, no, and auto savebefore - accepts yes, no, and prompt subsystem - console, windows, shellexec, lua, director, winhelp, htmlhelp groupundo - yes or no |
1
|
user.context.menu=Indent|1100|
|
If command.name is empty then no item is added to the Tools menu. This can be used for commands that are only in the context menu or user shortcuts.
在这里要为LuaForWindows自带的SciTE添加自动注释功能,参照《Using Lua With Scite》。步骤如下:
1.打开"SciTEGlobal.properties"文件,在文件末添加如下:
1
2 3 4 |
command.name.0.*=Auto AddComment
command.0.*=auto_AddComment command.subsystem.0.*=3 command.mode.0.*=savebefore:no |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
local strCommentHeader =
"-------------------------------------------------------------------------------\r\n-- \r\n-------------------------------------------------------------------------------\r\n"
local patternCommentFun = "function .+%((.*)%)" local strCommentFun = "-------------------------------------------------------------------------------\r\n-- \r\n" local patternCommentTable = " *([%w_]+) *=%s*(%b{})" local strCommentTable = "-------------------------------------------------------------------------------\r\n-- \r\n-- @class table\r\n" ------------------------------------------------------------------------------- -- 自动添加Lua语言注释 function auto_AddComment() local nLine = editor:LineFromPosition(editor.CurrentPos) local nPosition = editor:PositionFromLine(nLine) -- 文件头注释 if 0 == nLine then editor:InsertText(nPosition, strCommentHeader) editor.CurrentPos = editor.LineEndPosition[ 1] editor:SetSel(editor.CurrentPos, editor.CurrentPos) return end -- 函数注释, 仅函数在同一行声明 local strLineText = editor:textrange(nPosition, editor.LineEndPosition[nLine]) local strParam = string.match(strLineText, patternCommentFun) if nil ~= strParam then local tCommentFun = {strCommentFun} for k in string.gmatch(strParam, "([%w_]+)[, ]*") do tCommentFun[#tCommentFun + 1] = string. format( "-- @param %s \r\n", k) end local strComment = table.concat(tCommentFun) editor:InsertText(editor:PositionFromLine(nLine), strComment) editor.CurrentPos = editor.LineEndPosition[nLine + 1] editor:SetSel(editor.CurrentPos, editor.CurrentPos) return end -- 表注释 local strRangeText = editor:textrange(nPosition, editor.Length) local strTable, strField = string.match(strRangeText, patternCommentTable) if nil ~= strTable then local tCommentTable = {strCommentTable} tCommentTable[#tCommentTable + 1] = string. format( "-- @name %s\r\n", strTable) for k in string.gmatch(strField, "([%w_]+) *= *") do tCommentTable[#tCommentTable + 1] = string. format( "-- @field %s \r\n", k) end local strComment = table.concat(tCommentTable) editor:InsertText(editor:PositionFromLine(nLine), strComment) editor.CurrentPos = editor.LineEndPosition[nLine + 1] editor:SetSel(editor.CurrentPos, editor.CurrentPos) return end end |
参考资料:
1.http://www.scintilla.org/SciTEDoc.html
2.http://www.scintilla.org/SciTELua.html
3.http://lua-users.org/wiki/UsingLuaWithScite