我想为 Scite 设置样式,因此它以默认样式启动 - 但随后我想通过运行命令将其更改为深色样式。所以,经过一番挖掘,我得到了这个脚本,sciteLuaFunctions.lua
我在其中映射到工具菜单中的一个命令:
-- http://scite.ruteam.ru/archive/1.59
local function encodeRGB(color)
if string.sub(color,1,1)=="#" and string.len(color)>6 then
return tonumber(string.sub(color,6,7)..string.sub(color,4,5)..string.sub(color,2,3), 16)
else
return color
end
end
function ChangeToDarkTheme()
-- http://www.scintilla.org/PaneAPI.html
-- http://www.scintilla.org/SciTEFAQ.html " How do I change SciTE to use black as the background colour?"
-- http://www.scintilla.org/SciTEDoc.html
-- color calculation works like this:
--~ mycolorRGB = { r = 100, g = 100, b = 100 } -- ok
--~ mycolor = (mycolorRGB.r+(mycolorRGB.g*256)+(mycolorRGB.b*65536)) -- ok
-- but also can use encodeRGB:
myBackgroundColor = encodeRGB("#282C34")
editor.StyleBack[32] = myBackgroundColor -- mods background, but where there no text
editor.StyleBack[33] = myBackgroundColor -- mods background of line numbers
end
然后,当我运行此命令时,我会得到如下信息:
问题是:
- 默认背景只改变不被(文本)字符占用的背景(包括换行符/空行);我也想修改这个背景颜色
- 编辑:感谢@EgorSkriptunoff 的评论,设法获得(通过手动试验值)整个背景(至少在编辑时
sciteLuaFunctions.lua
,因此对于lua
语法着色,但也适用于cpp
它)与此颜色相同:
...除了,我不知道样式 2、4、5、6 等记录在哪里,因为它们不在常见问题解答或上面片段中链接的其他文档中?!那么某处是否有数字样式列表,以及它们的变化?editor.StyleBack[32] = myBackgroundColor -- mods background, but where there no text editor.StyleBack[33] = myBackgroundColor -- mods background of line numbers editor.StyleBack[0] = myBackgroundColor -- mods background of whitespace/indents editor.StyleBack[2] = myBackgroundColor -- mods background of commented lines editor.StyleBack[4] = myBackgroundColor -- mods background of numbers at uncommented lines editor.StyleBack[5] = myBackgroundColor -- mods background of reserved keywords (function) at uncommented lines editor.StyleBack[6] = myBackgroundColor -- mods background of strings ("...") at uncommented lines editor.StyleBack[10] = myBackgroundColor -- mods background of equal signs, etc at uncommented lines editor.StyleBack[11] = myBackgroundColor -- mods background of regular variables at uncommented lines editor.StyleBack[14] = myBackgroundColor -- mods background of predef functions (string.sub) at uncommented lines
- 编辑:感谢@EgorSkriptunoff 的评论,设法获得(通过手动试验值)整个背景(至少在编辑时
- 如果我随后打开一个新选项卡,新样式就会消失 - 如果我返回上一个选项卡,新样式也会消失;相反,我希望该样式一直持续到由脚本显式重置或关闭为止。
是否可以使用 Lua 脚本来实现这些,如果可以,如何实现?