Jump to content
Beege

SciTE Caret Color Switch - Use Both Dark and Light Themes

Recommended Posts

If you have every taken the time to set up a nice dark theme for your scite editor, you probably noticed shortly after a small yet really annoying flaw. For what ever reason, scite is not set up to let you change the caret fore color and caret line color per language. This really sucks if say you want to edit a properties file or any of the many other languages that Scite currently is setup to support. Pretty much all the other languages are set as light theme so unless you change the theme for those file types, you end up with something like below where the line color and caret are still using the dark theme colors. Line 3 in the pic:
 
post-8949-0-96975500-1392529505_thumb.pn
 
To get around this I came up with the following that seems to work pretty well.  
 
Add the following properties to SciteUser.properties file (Options -> Open User Options File). Update colors to your own needs. You can addionally add any other propertys that dont have a lexer language option in the same fashion.

# The default values (light themes) will be used for any lexer other than au3

caret.default.fore=#000000
caret.default.line.back=#FFFED8
selection.default.fore=#006000
selection.default.back=#F0A0A8

caret.au3.fore=#FFFFFF
caret.au3.line.back=#111111
selection.au3.fore=#C2FFAE
selection.au3.back=#f9f9f9

 
Add the following function to PersonalTools.Lua file. As jos pointed out, the OnStartup covers the filetab switches as well as the startup so only need the one function:

function PersonalTools:OnStartup()
    
    -- the "and" + "or" keywords are ternary operators here  
    local sLex = self:IsLexer(SCLEX_AU3) and 'au3' or 'default'

    props['caret.line.back'] =  props['caret.' .. sLex .. '.line.back']
    props['caret.fore'] =       props['caret.' .. sLex .. '.fore']
    props['selection.fore'] =   props['selection.' .. sLex .. '.fore']
    props['selection.back'] =   props['selection.' .. sLex .. '.back']

end


Last restart SciTE and that should be it. Let me know if you have any issues. Thanks
 

Edited by Beege
Rewrote and added selection.fore / back

Share this post


Link to post
Share on other sites

A couple of suggestions:

The current setup in the Full SciTE installer has an PersonalTools.lua file in the users directory which can be used for this type of scripts.This avoids having to update the SciteStartup.lua after each installation of the full installer.

You could also retrieve the current lexername in stead of using the File Extension as some Lexers use multiple different file extensions.

Using OnStartUp will run the function when changing FileTabs in SciTE in case you have multiple files open.

Something like this:

function PersonalTools:OnStartup()
    if props['caret.' .. editor.LexerLanguage .. '.line.back'] ~= '' then
        props['caret.line.back'] = props['caret.' .. editor.LexerLanguage .. '.line.back']
    else
        props['caret.line.back'] = props['caret.default.line.back']
    end

    if props['caret.' .. editor.LexerLanguage .. '.fore'] ~= '' then
        props['caret.fore'] = props['caret.' .. editor.LexerLanguage .. '.fore']
    else
        props['caret.fore'] = props['caret.default.fore']
    end
end

Cheers

Jos

Edited by Jos

Share this post


Link to post
Share on other sites
Guest

thanks.

my way is to open Magnifier and then Ctrl+Alt+I

or use Magnifier in this >way

Share this post


Link to post
Share on other sites

A couple of suggestions:

The current setup in the Full SciTE installer has an PersonalTools.lua file in the users directory which can be used for this type of scripts.This avoids having to update the SciteStartup.lua after each installation of the full installer.

You could also retrieve the current lexername in stead of using the File Extension as some Lexers use multiple different file extensions.

Using OnStartUp will run the function when changing FileTabs in SciTE in case you have multiple files open.

 

Something like this:

function PersonalTools:OnStartup()
    if props['caret.' .. editor.LexerLanguage .. '.line.back'] ~= '' then
        props['caret.line.back'] = props['caret.' .. editor.LexerLanguage .. '.line.back']
    else
        props['caret.line.back'] = props['caret.default.line.back']
    end

    if props['caret.' .. editor.LexerLanguage .. '.fore'] ~= '' then
        props['caret.fore'] = props['caret.' .. editor.LexerLanguage .. '.fore']
    else
        props['caret.fore'] = props['caret.default.fore']
    end
end

Nice! Thanks for the suggestions. Ill defiantly revise to utilize the personal tools. For using the editor.lexerlanguage, I actually started out doing it that way but then changed to extention only for simplicity until I can get a table made of what extensions use what lexername, and then tie those into some properties in the user.properties with some notes. Html lexer (aka hypertext) for example includes a ton while xml has its own little catagory and I could easily see myself guessing they were in the same group if not looking at the properties file. Thanks again for the Tips

Edited by Beege

Share this post


Link to post
Share on other sites

This is working again. editor.LexerLanguage stopped working somewhere along the way and has been updated to just check if this is au3 or not. 

edit: actually this works fine. I dont know what I had screwed up..

function PersonalTools:OnStartup()
    print(editor.LexerLanguage)
end

 

Edited by Beege

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By AutoitMike
      Scite 3.4.4
      Win 10
      I click "Help" or press F1, there is no response
      If I use the file explorer and double click Autoit.chm or Autoit3.chm help opens.
      There is no dialog to check or uncheck "Always ask before opening this file" when clicking on these files.
       
      If you are curious as to why I dont have the latest version, I am creating a back up laptop that has a VERY extensive automation application that I have written over the past 15 years.
       
      An extremely potent, powerful, needed function has been deleted in the upgrade of Autoit in recent years that I can not do without. If my main laptop dies, which it almost did, I am in a very bad position. So I bought the exact same laptop and I am "cofiguring" it to work exactly the same as my main laptop. However, this one has been "Upgraded" to Win 10 which I hope is not the problem. 
      Thanks for any help
    • By ozymandius257
      Is there a way to remove the numbers from the tabs in Scite?
      When you have multiple autoit programs open, the tabs are numbered, so you'll get something like 1 ProgramA.au3    2 Program2.au3   3 Program3.au3
      I am working on programs with numbers as the first character, so I get  1 3-DoThis.au3     2 4-DoAnother.au3   3 5-DoTheRest.au3  (not the real program names, obviously :))
      It would be nice if I could get rid of the tab number, and just have the program name on each tab.
       
       
    • By SgtHugoStiglitz
      HI people,
                        I got a questions, I maintain code in autoIT and every time I compile a new version or modification, Scite generate 2 folders. One folder is finish by released and the other is tentative. I try to make some google search, but never find answer would satisfied myself. The dev who was maintain it before were using AutoIt3Wrapper_GUI, and I don't know if it's related. I look both folder, but they seem pretty identical, but I would like to know what it's the difference between those to folder. Anyone have a clue?
    • By user4157124
      ConsoleWrite('>Message here.' & @CRLF) outputs colored text (per + > - ! characters).
      ConsoleWrite('warning' & @TAB & '38' & @TAB & 'more text ...' & @CRLF) enables jump to line 38 on doubleclick.

      Using "jump to line" format, only red and pink text coloring seems possible (simply prefixing color directives to output-text disables jump to line functionality). Is it possible to combine the two (define custom color while keeping "jump to line" functionality)?
    • By mannworks00
      After testing various schemes (themes) in the settings for the newest SciTE editor (v. 4.1.2), I discovered that I wasn't able to fully reset it back to its original colors (See snapshot). Specifically, after applying the "__SciTE4AutoIt3_Dark ==> Dark SciTE4AutoIt3 Color scheme."
      The problem: The Line number column and the Output console do not reset back to their original colors.
      The Solution: Delete or edit the user config file. You can safely delete the config file because it will completely regenerate on SciTE restart- with it's factory (out of the box) color scheme.
      I also wrote a small script that will do it programatically: How to reset SciTE scheme in version 4.1.2.
       
       

×
×
  • Create New...