This a progress report on #766 Create a Themes menu and simplify theme 
settings <https://github.com/leo-editor/leo-editor/issues/766>.

This post discusses two topics:

- How to create a Themes menu.
- How to make developing themes easier for devs.

I have just partially fixed #780: @tabwidth -2 in @data 
qt-gui-plugin-style-sheet crashes Leo on startup 
<https://github.com/leo-editor/leo-editor/issues/780>.
The crash no longer happens, but imo Leo directives should be removed 
before doing @-constant substitutions. Other than that, the @constant 
machinery will remain unchanged.

*How to create a Themes menu*

An Aha! makes this easy.  The new Themes menu will simply load a *theme 
file* *as if they were settings files*.  Each theme file will be a regular 
.leo file, with an @settings tree containing:

- (Optional) Settings related to syntax coloring.
- (Optional) A single @theme tree.

So a theme file could change to syntax coloring only, or could install a 
complete theme, with corresponding syntax coloring options. Leo should have 
at least the following theme files:

- SolarizedDarkTheme.leo
- SoarizedLightTheme.leo
- LegacyLightTheme.leo
- SolarizedSyntaxColoring.leo
- LegacySyntaxColoring.leo

*How to make developing themes easier for devs*

Chris George submitted a superb new theme for #764: Improve the screen shot 
on Leo's home page <https://github.com/leo-editor/leo-editor/issues/764>.

The following remarks are based on my experiences adapting his theme.  I 
was happy to do this work, because it clarified the issues in creating 
themes.

The @theme tree contained a lot of cruft left over from when themes were 
created by a script.  Such scripts are completely unnecessary now that 
@data nodes can contain a tree of nodes. I reorganized the @theme tree as 
follows:

1. All css relating to a single Leo widget (body, log, tree, etc.) are now 
gathered in a separate child of the @data node.  This avoid duplication and 
confusion.

2. With a few exceptions, I eliminated settings used in only one place. Now 
the value of the setting used directly in the css, in the proper node.  
This value might still be an @ constant, but this eliminates one level of 
settings indirection hell.

The remaining settings in the @theme tree are:

- Settings used in multiple places.  Especially font-related settings, but 
also various @color settings.
- Syntax-coloring settings. These are not used in the @data node.

Theme files will probably contain a copy of the color definitions now in 
leoSettings.leo.

*Summary*

Theme files are .leo files contain an @settings tree for syntax coloring 
and/or themes. Picking a theme will load these files as if they were 
settings files.

Rev b2ed012 adds a disabled @theme Leo Solarized Dark theme that looks good 
on both Windows and Linux.  This @theme node will be the basis of all theme 
files.

@-constant replacement will remain unchanged, but reducing @constant 
indirection is often a good idea.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to