2

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:

  -- 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:

  • The default background changes only the background not taken up by (text) characters (including linefeeds/empty lines); I would like to modify this background color too
    • EDIT: Thanks to comment by @EgorSkriptunoff, managed to get (by manually experimenting with values) the entire background (at least while editing sciteLuaFunctions.lua, so for lua syntax coloring, but also for cpp it works) in the same color with this:
      
      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
      ... except, I cannot tell where are the styles 2, 4, 5, 6 etc documented, as they are not in the FAQ or the other docs linked in the snippet above ?! So is there a list of numeric styles somewhere, and what they change?
  • If I then open a new tab, the new styling disappears - if I go back to the previous tab, the new styling disappears as well; I would instead like for the style to persist until either explicitly reset by a script, or until shutdown.

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

sdaau
  • 36,975
  • 46
  • 198
  • 278
  • 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
  • 1
    `for i = 0, 63 do editor.StyleBack[i] = 0x282C34 end` – Egor Skriptunoff Nov 24 '16 at 20:34
  • 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
  • 1
    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 07:14
  • 1
    `props["fold.margin.colour"]=0x282C34; props["fold.margin.highlight.colour"]=0x282C34` – Egor Skriptunoff Nov 25 '16 at 10:31

0 Answers0