[IDE Tool] ChangeTheme color switcher

Working on new editor enhancements?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

[IDE Tool] ChangeTheme color switcher

Post by kenmo »

ChangeTheme is a tool for "instantly" switching the color theme of the PureBasic IDE, faster than going through the Preferences window. You can link it to a menu item or keyboard shortcut.

Run:
ChangeTheme <no parameters or ""> = open a browse dialog, activate file if chosen
or
ChangeTheme <theme file> = activate the specified *.prefs file (as exported from IDE)
or
ChangeTheme <theme file or ""> -a = apply the theme to the active Scintilla without touching the prefs file or relaunching

What it does:
- loads the colors
- tries to close the IDE, or else prompts you to close it
- writes the colors to your IDE preferences file
- re-launches the IDE
- 2019-06-09: new --apply/-a option to apply the style without touching the prefs file

Please try it out and submit suggestions!

Source and Windows exe on GitHub

Written for quick switching of the Solarized light and dark color themes
Last edited by kenmo on Mon Jun 10, 2019 4:05 am, edited 1 time in total.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Tool] ChangeTheme color switcher

Post by IdeasVacuum »

Sounds really nice kenmo.

I think there might be a psychological issue though - we spend so much time getting the look just right, people don't want to try your switcher in case something goes wrong?

What if it made a backup preferences file of the IDE first? That would give people more confidence to try it?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: [Tool] ChangeTheme color switcher

Post by blueb »

Ideasvacuum,

I've lost some templates and pref settings due to file corruption in the past
(it's really time consuming to rebuild these from scratch)
so I make a backup copy often (usually after I've made some changes to a template, etc.)

Code: Select all

If CopyDirectory("C:\Users\Bob H\AppData\Roaming\PureBasic", "F:\Latest Home\PureBasic\Bobs Template Backup Folder", "", #PB_FileSystem_Recursive|#PB_FileSystem_Force)
     Debug "Great...You made a backup copy of your Prefs files as well as your Templates!"
Else
     Debug "████ Something went wrong! ████"
EndIf
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: [Tool] ChangeTheme color switcher

Post by blueb »

Thanks kenmo... great addition and it works like a charm.

Now I can experiment without fear of 'redoing' all colors. :D

I took one of your prefs files, modified it with my present settings and saved it as 'BluebStyle.prefs'
This one seems easier on my eyes.. but maybe I'm jaded.

Using your tool I can switch back and forth at will... nice.

Code: Select all

; Blueb's Color Theme for PureBasic IDE
;
 
[Sections]
IncludeColors = 1
 
[Colors]
ASMKeywordColor = 255
ASMKeywordColor_Used = 1
BackgroundColor = 14150650
BackgroundColor_Used = 1
BasicKeywordColor = 8388608
BasicKeywordColor_Used = 1
CommentColor = 32768
CommentColor_Used = 1
ConstantColor = 128
ConstantColor_Used = 1
LabelColor = 8421504
LabelColor_Used = 1
NormalTextColor = 4210816
NormalTextColor_Used = 1
NumberColor = 8388608
NumberColor_Used = 1
OperatorColor = 8388608
OperatorColor_Used = 1
PointerColor = 12615808
PointerColor_Used = 1
PureKeywordColor = 16711680
PureKeywordColor_Used = 1
SeparatorColor = 8388608
SeparatorColor_Used = 1
StringColor = 33023
StringColor_Used = 1
StructureColor = 12615808
StructureColor_Used = 1
LineNumberColor = 7303023
LineNumberColor_Used = 1
LineNumberBackColor = 15263976
LineNumberBackColor_Used = 1
MarkerColor = 11184640
MarkerColor_Used = 1
CurrentLineColor = 16777215
CurrentLineColor_Used = 1
SelectionColor = 4237800
SelectionColor_Used = 1
SelectionFrontColor = 0
SelectionFrontColor_Used = 1
CursorColor = 0
CursorColor_Used = 1
Debugger_LineColor = 16771304
Debugger_LineColor_Used = 1
Debugger_LineSymbolColor = 16771304
Debugger_LineSymbolColor_Used = 1
Debugger_ErrorColor = 255
Debugger_ErrorColor_Used = 1
Debugger_ErrorSymbolColor = 255
Debugger_ErrorSymbolColor_Used = 1
Debugger_BreakPointColor = 11184640
Debugger_BreakPointColor_Used = 1
Debugger_BreakpoinSymbolColor = 11184640
Debugger_BreakpoinSymbolColor_Used = 1
DisabledBackColor = 16777215
DisabledBackColor_Used = 1
GoodBraceColor = 8388608
GoodBraceColor_Used = 1
BadBraceColor = 255
BadBraceColor_Used = 1
ProcedureBackColor = 1677721
ProcedureBackColor_Used = 1
CustomKeywordColor = 16744448
CustomKeywordColor_Used = 1
Debugger_WarningColor = 33023
Debugger_WarningColor_Used = 1
Debugger_WarningSymbolColor = 33023
Debugger_WarningSymbolColor_Used = 1
IndentColor = 32768
IndentColor_Used = 1
ModuleColor = 0
ModuleColor_Used = 1
SelectionRepeatColor = 11009968
SelectionRepeatColor_Used = 1
PlainBackground = 15138790
PlainBackground_Used = 1
ToolsPanel_FrontColor = 0
ToolsPanel_FrontColor_Used = 1
ToolsPanel_BackColor = 15786973
ToolsPanel_BackColor_Used = 1
Last edited by blueb on Mon May 20, 2019 4:17 pm, edited 1 time in total.
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Tool] ChangeTheme color switcher

Post by kenmo »

IdeasVacuum wrote:What if it made a backup preferences file of the IDE first? That would give people more confidence to try it?
It already does a simple version of that:

Code: Select all

;- Back up existing Prefs file
If (#True)
  CopyFile(PrefsFile, PrefsFile + ".backup")
EndIf
But of course I'm open to smarter backup and other suggestions.
The code is small enough you can check out what it's doing:
https://github.com/kenmo-pb/tools/blob/ ... geTheme.pb
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Tool] ChangeTheme color switcher

Post by kenmo »

blueb wrote:I took one of your prefs files, modified it with my present settings and saved it as 'BluebStyle.prefs'
This one seems easier on my eyes.. but maybe I'm jaded.
Looks good. The theme is quite different so you don't need my name and website in the file comments :)
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: [Tool] ChangeTheme color switcher

Post by blueb »

Whaaat?

You don't want to be associated with those God-awful colors? :P

Thanks again Ryan :)
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Tool] ChangeTheme color switcher

Post by kenmo »

I was saving it to my folder of themes and was surprised it was "adapted by" me :lol:
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: [Tool] ChangeTheme color switcher

Post by Michael Vogel »

Any idea to force PureBasic changing the color theme without restarting the IDE?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Tool] ChangeTheme color switcher

Post by kenmo »

Michael Vogel wrote:Any idea to force PureBasic changing the color theme without restarting the IDE?
Short answer: no, sorry. Gotta request that from the IDE developers.

Longer answer: I tried it and I'm able to immediately apply the theme colors. But there are (at least) 2 issues:
- IDE tools only receive the handle to the active Scintilla, so I can only apply colors to one open file
- I don't have handles to the compile log or the Tools sidebar, so they remain the old colors, which looks bad
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: [Tool] ChangeTheme color switcher

Post by Michael Vogel »

kenmo wrote: - IDE tools only receive the handle to the active Scintilla, so I can only apply colors to one open file
Could be fine, I think about switching between two themes only (light/dark) done by a simple Ctrl+F12 or so. If another code window hasn't been updated, it could be done by a simple shortcut.
kenmo wrote: - I don't have handles to the compile log or the Tools sidebar, so they remain the old colors, which looks bad
Typically I don't use them, so they never are visible.
If used, they are created dynamically, so it would be cool to force PureBasic to accept a new color theme without retarting (otherwise it needs to permanently check the handles if the SysTabControl32 containing the Listbox is available to update the colors).

Could you show us your code doing the life color update?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [IDE Tool] ChangeTheme color switcher

Post by kenmo »

Michael, I took a first attempt at it. Windows-only.

Add the "-a" parameter to instantly style the Scintilla without touching the prefs file.

See the source and exe at the link in the original post.
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: [IDE Tool] ChangeTheme color switcher

Post by Denis »

Nice tool kenmo!
Tks
A+
Denis
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: [IDE Tool] ChangeTheme color switcher

Post by Michael Vogel »

Cool, I like it... I am switching with Ctrl+F11 between full and normal screen and with Ctrl+F12 between dark and light theme.

Would be cool to do the whole thing without an IDE "reboot". The -a option is great, but it seems that the background colors get lost as soon the editor starts a source code (F5).

Not sure, but maybe the keyword 'bolding' will be ignored as well...
...maybe Fred could implement a possibility to trigger a "soft reboot" like it is done when calling the preferences.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [IDE Tool] ChangeTheme color switcher

Post by kenmo »

Michael Vogel wrote:The -a option is great, but it seems that the background colors get lost as soon the editor starts a source code (F5).
Ouch, that's another reason this method doesn't work well.
When you debug, the IDE changes the background color. It's not a different Scintilla style, it updates all the styles with the background in your prefs... which overwrites what my tool just set.

I think we should turn this into feature request(s) for the IDE :)
Michael Vogel wrote:Not sure, but maybe the keyword 'bolding' will be ignored as well...
Can you clarify what you mean?
Post Reply