Progress re themes. Theme devs, pls read

60 views
Skip to first unread message

Edward K. Ream

unread,
Dec 22, 2020, 6:46:37 AM12/22/20
to leo-editor
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

Edward K. Ream

unread,
Dec 22, 2020, 9:54:31 AM12/22/20
to leo-editor
On Tue, Dec 22, 2020 at 5:46 AM Edward K. Ream <edre...@gmail.com> wrote:

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:

I should emphasize that I made zero changes to style sheets.

I did change the various EKR dark themes so that the trailing whitespace indicator is visible This was a buglet in the themes. Otoh, I disabled it after about 30 seconds of usage :-) I find it way too annoying.

Edward

Edward K. Ream

unread,
Dec 22, 2020, 10:28:00 AM12/22/20
to leo-editor
On Tuesday, December 22, 2020 at 5:46:37 AM UTC-6 Edward K. Ream wrote:

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.

How did I ever live without the git-diff-pr command? It reminds me that I did make another significant change to text settings:

Old: @string font-family = Inconsolata, Droid Sans Mono, DejaVu Sans Mono
New: @string font-family = DejaVu Sans Mono

I did this because Inconsolata is unacceptable on my Windows machine.

The fundamental problem is that there is no way to select fonts based on the platform. As I write this, I see that the workaround will be to change the load order:

@string font-family = DejaVu Sans Mono, Inconsolata,  Droid Sans Mono

I'll do this today.

Edward

Edward K. Ream

unread,
Dec 22, 2020, 10:41:19 AM12/22/20
to leo-editor
On Tuesday, December 22, 2020 at 5:46:37 AM UTC-6 Edward K. Ream wrote:

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.

Only in a few places. Style sheets refer to settings with underscores, and I'm not sure whether Leo's stylesheet machinery could handle a change. Safer not to find out. I have chosen to leave underscores alone.

I plan no further work on @1792. I'll wait at least a week to merge ekr-theme into devel. Now is the time for testing.

Edward

tbp1...@gmail.com

unread,
Dec 22, 2020, 12:21:24 PM12/22/20
to leo-editor
I'm currently using

@string font-family = Consolas, Droid Sans Mono, DejaVu Sans Mono

I think that that Consolas comes with Windows and I like it better than some of the alternatives.  Apparently it can be installed on Linux in some manner.  I should probably move the DajaVu font ahead of the Droid, but at any rate this setting seems to work all right on both Windows and Linux.

Edward K. Ream

unread,
Dec 22, 2020, 2:35:24 PM12/22/20
to leo-editor
On Tue, Dec 22, 2020 at 11:21 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I'm currently using

@string font-family = Consolas, Droid Sans Mono, DejaVu Sans Mono

I think that that Consolas comes with Windows and I like it better than some of the alternatives.  Apparently it can be installed on Linux in some manner.  I should probably move the DajaVu font ahead of the Droid, but at any rate this setting seems to work all right on both Windows and Linux.

Thanks for these comments. Consolas does look fairly good.

Devs, please feel free to change the font setting as you please in your own themes.

Edward

gar

unread,
Dec 26, 2020, 3:18:17 AM12/26/20
to leo-e...@googlegroups.com
But still, how can I reduce leo's font size with a theme applied w/o modifying the theme outline itself?
Playing with `@string font-size`is still gives absolutely nothing.
In my opinion the inability to change font size easily is the great miss of leo's styling. Cause default fonts are INCREDIBLY huge.

вт, 22 дек. 2020 г. в 22:35, Edward K. Ream <edre...@gmail.com>:
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS0woyZXozs7YMwwpLdri9-Uf4p6%2Bg_TExMevotVmygnWw%40mail.gmail.com.

Edward K. Ream

unread,
Dec 26, 2020, 4:09:12 AM12/26/20
to leo-editor
On Sat, Dec 26, 2020 at 2:18 AM gar <gar...@gmail.com> wrote:
But still, how can I reduce leo's font size with a theme applied w/o modifying the theme outline itself?

You can't, because the setting is in the theme file.

Yes, I know this isn't optimal. The question is, do we want to force everyone to change their present workflow. It's a close call.

Edward

tbp1...@gmail.com

unread,
Dec 26, 2020, 5:35:25 AM12/26/20
to leo-editor
It's a matter of adding or changing a setting in myLeoSettings.leo vs changing a setting in a theme outline.  Not much different.  More of a difficulty is knowing what particular settings to change.

In my case, I copied one of the dark themes and used that renamed copy to try to reduce the font size and one or two other items, like font family and gutter settings.  I put it into my .leo/themes directory, where Leo will look for it.  Usually on a Linux system .leo/themes is at ~/.leo/themes and on a Windows system it's at %USERPROFILE%/.leo/themes. Either is not hard to navigate to.  You do need to create the themes directory yourself.

Alternatively if you don't use any theme (set it to None or a non-existent theme), you get the old Leo color scheme, and you can still modify that in myLeoSettings - although changing all the settings one by one over to a dark theme, say, would be an unpleasantly long and difficult task.

gar

unread,
Dec 26, 2020, 9:10:39 AM12/26/20
to leo-e...@googlegroups.com
It's a matter of adding or changing a setting in myLeoSettings.leo vs changing a setting in a theme outline.  Not much different.  More of a difficulty is knowing what particular settings to change.
Great difference actually. When you setup a fresh computer - you need to copy not a single file but a bulk of them. And somehow remember that you cannot easily change the settings - you must change the theme itself. And do it for every theme you're going to use. Good deal, yeah?

In my case, I copied one of the dark themes and used that renamed copy to try to reduce the font size and one or two other items, like font family and gutter settings.  I put it into my .leo/themes directory, where Leo will look for it.  Usually on a Linux system .leo/themes is at ~/.leo/themes and on a Windows system it's at %USERPROFILE%/.leo/themes. Either is not hard to navigate to.  You do need to create the themes directory yourself.
compare with ":colorsheme <name>".

Alternatively if you don't use any theme (set it to None or a non-existent theme), you get the old Leo color scheme, and you can still modify that in myLeoSettings - although changing all the settings one by one over to a dark theme, say, would be an unpleasantly long and difficult task.
Well.. Default settings operate with  one set of options, whilst themes - with another. This concerns fonts at least. And theme's set cannot be overridden on myLeoSettings.
Oh, that's a nightmare.  Actually, leo's learning curve is much longer then vim's one. Nothing works out of the box intuitively.

tbp1...@gmail.com

unread,
Dec 26, 2020, 9:27:31 AM12/26/20
to leo-editor
On Saturday, December 26, 2020 at 9:10:39 AM UTC-5 gar wrote:
It's a matter of adding or changing a setting in myLeoSettings.leo vs changing a setting in a theme outline.  Not much different.  More of a difficulty is knowing what particular settings to change.
Great difference actually. When you setup a fresh computer - you need to copy not a single file but a bulk of them. And somehow remember that you cannot easily change the settings - you must change the theme itself. And do it for every theme you're going to use. Good deal, yeah?

Not that I like the new design all that much (I mean not being able to override at least a few key settings using myLeoSettings), but I don't think the fresh computer aspect itself is very unpleasant.  That's because I already copy my workbook.leo from an existing Leo installation when I set up a new virtual machine.  When I'm looking at ~/.leo, I notice the themes directory and that reminds me to copy it.  And I generally copy myLeoSettings.leo, too, or at least some of its settings.  So I get a second reminder about my theme file.

How a new user would know about any of this is hard for me to see.  At a minimum, a menu item that offers to change the font size would be easy to find and use.  Changing the font is probably what many new users will want to do soon after opening Leo.  It's easy to think of ways this could be implemented, some more of a hack than others.

gar

unread,
Dec 26, 2020, 12:12:20 PM12/26/20
to leo-e...@googlegroups.com
How a new user would know about any of this is hard for me to see.  At a minimum, a menu item that offers to change the font size would be easy to find and use.  Changing the font is probably what many new users will want to do soon after opening Leo.  It's easy to think of ways this could be implemented, some more of a hack than others.

Absolutely true!
Also I noticed that when theme outline is loaded - Leo applies the theme. So why not implement a dropdown menu with all found themes so users can change look and feel on the fly?
Reply all
Reply to author
Forward
0 new messages