Style Scite with Lua?


Style Scite with Lua?



I would like to style Scite, so it starts up with whatever is the default style - but then I would want to change to a different style to a dark one by running a command. So, after some digging, I got to this script in sciteLuaFunctions.lua which I mapped to a command in Tools menu:


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



Then, when I run this command, I get something like this:



scite-bckg



The problem is:


sciteLuaFunctions.lua


lua


cpp



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



Is it possible to achieve these with a Lua script, and if so, how?





Thanks @EgorSkriptunoff - already have that linked in the code; was wondering on what to do from lua, cheers!
– sdaau
Nov 24 '16 at 16:35





for i = 0, 63 do editor.StyleBack[i] = 0x282C34 end
– Egor Skriptunoff
Nov 24 '16 at 20:34


for i = 0, 63 do editor.StyleBack[i] = 0x282C34 end





Many thanks, @EgorSkriptunoff - that worked -- except the vertical line separating the line numbers and the text area does not change its background color. I experimented a bit with the values, and it seems not all numeric styles from 0 to 63 need to be changed; so I edited my OP above.. Cheers!
– sdaau
Nov 24 '16 at 23:16





The set of styles depends on the language of the file being edited (each .properties file defines its own styles, styles 0-31 are language-specific).
– Egor Skriptunoff
Nov 25 '16 at 7:14



.properties





props["fold.margin.colour"]=0x282C34; props["fold.margin.highlight.colour"]=0x282C34
– Egor Skriptunoff
Nov 25 '16 at 10:31



props["fold.margin.colour"]=0x282C34; props["fold.margin.highlight.colour"]=0x282C34









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?