Jump to content

Recommended Posts

Posted (edited)

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
  • Developers
Posted (edited)

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

thanks.

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

or use Magnifier in this >way

Posted (edited)

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
  • 10 months later...
Posted (edited)

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

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
×
×
  • Create New...