Yesterday saw breakthroughs and simplifications regarding Leo's theme files, .leo files in the leo/themes folders. This post summarizes yesterday's work, all contained in the ekr-theme branch. See
#1792.
Aha re testing themes
Leo loads the settings in theme files second-to-last, that is, just before loading the actual .leo file being loaded. This means leoSettings.leo and myLeoSettings.leo affect theme files.
Theme files can (and must) deal with the environment leoSettings.leo provides, but theme files (and their devs) can't know what will be in myLeoSettings.leo.
In the past, I have disabled myLeoSettings.leo completely while testing theme files, but this is clumsy: I lose useful settings that won't affect theme files, settings such as abbreviations, @command scripts, split direction, and find-panel settings.
Aha: test theme files with a minimal @settings node in myLeoSettings.leo.
So simple: Replace my usual @settings tree with a minimal @settings tree. As an aid to doing this, Leo's code (in ekr-theme) ignores comments after @settings. So during testing my two @settings trees look like this:
- @@@settings (full)
- @settings (minimal)
Simplifying theme files
Previously, theme files contained @theme trees. Iirc, only settings contained within an @theme tree actually took effect.
Looking at theme files with fresh eyes, I suddenly realized that the @theme is a (confusing!) holdover from the bad old early days, when users were told to cut and paste @theme nodes into their myLeoSettings.leo. Now, these nodes are not needed.
Leo's settings node (in ekr-theme) no longer treats @theme nodes as a special case. This means:
- All settings in theme nodes have effect.
- Settings nodes should contain only settings that affect Leo's appearance.
- There is no need for @theme nodes.
- There is no need for the confusing distinction between theme settings and other settings.
These simplifications cascade into further simplifications. Confusing organizer nodes disappear, and a simpler organization presents itself, as you can see by looking at the new theme files.
Functional changes to theme files
When I started this project I said that I would make no "real" changes to theme files. This is mostly still true, with the following important exceptions:
1. Theme files no longer contain the @string theme-name setting. This setting serves no purpose at all within theme files. In fact, this setting can only have effect within myLeoSettings.leo. This setting causes Leo to load the theme file, and does nothing else.
2. All theme files now specify font sizes in points (pt) rather than pixels (px). Using pixels to specify font sizes is brain dead. I am responsible for this, and I fear theme devs followed my lead.
3. At present, all theme files use 12 point fonts everywhere, except possibly for the so-called small fonts, which use 10 points. This new "policy" may not be what some theme devs want. If not, let me know. I'll be happy to change any theme so it uses different sizes.
Additional changes
The following changes do not have any functional effect on themes, but they are worth mentioning:
1. Theme files must not set @string target-language. That would invalidate the corresponding setting in myLeoSettings.leo. Instead, theme files now use @language rest (or @language md) to specify coloring.
2. I have used the preferred names for settings in theme files. Settings names have the form x-y-z rather than x_y_z.
3. The @string color-theme setting is no longer considered a "theme related setting". Indeed, that distinction no longer exists. Comments in the setting node make clear that this setting specifies the path to a folder containing icons. The name "color-theme" is poorly chosen, but I don't dare change it now. Understand?
Testing
The ekr-theme branch is ready for testing. I will work on it further today.
Theme devs, please ensure that your theme looks as you want it to. If not, please let me know.
Summary
Using a minimal @settings tree in myLeoSettings.leo simplifies the (complex!) task of developing theme files. Leo now ignores comments in @settings nodes, which helps keep track of multiple @settings nodes.
Leo no longer special cases @theme trees within @settings files. As a result, theme files no longer use @theme trees.
All settings in theme files now have effect. Theme files should contain only appearance-related settings. In particular, theme files no longer contain @string target-language settings.
The result of all these changes is a collapse in the complexity of theme files. Apart from font sizes, all themes should
behave exactly as before. If not, please let me know immediately.
Edward