Please Test Current Line Highlighting

65 views
Skip to first unread message

tbp1...@gmail.com

unread,
Aug 27, 2021, 5:36:40 PM8/27/21
to leo-editor
The attached Leo outline contains a script to highlight the line in the body that has the cursor.  You can activate it by selecting the top-most node, then pressing CTRL-b.  After this, the cursor line should become highlighted anywhere in the outline.  Other outlines will not be affected.

If you want to try it out in another outline, copy the script, paste it into the other outline, and run it with CTRL-b.

Activating the highlighting this way is a bit strange, but lets you try it out without needing to modify Leo itself or install a different version.  Eventually, the code would be included and activated when the body pane is constructed.

I'd like to know how you like the effect, and whether you think the highlight color works well enough.  

Note that the highlight color will be different for different Leo themes (and no-theme color schemes).  The script tries to calculate reasonable colors.  If the background is light, the highlight will be the same hue but darker.  If the background is dark, the highlight will be the same hue but lighter.  If the background is very light or very dark, different rules may be applied.

I have tried this out on every theme in Leo's theme directory.  The colors seem to work acceptably to me.  If you have your own theme that isn't one of the standard ones, I'm especially interested in how that works out.  And, of course, post here if you notice any bugs or anomalies.
highlight_line.leo

Viktor Ransmayr

unread,
Aug 28, 2021, 4:43:55 AM8/28/21
to leo-editor
Hello Thomas,

I did a quick test in my default environment with "theme_name = None" and it looks good to me.

I have not done any own theming work so I can't provide feedback on your other request.

With kind regards,

Viktor

jkn

unread,
Aug 28, 2021, 5:14:54 AM8/28/21
to leo-editor
I could see this being useful to me, thanks for your work on this (I haven't tested it yet).

Would the eventual intention be to add a configuration colour for this to themes? And (say) only do your 'background colour calculation' if this was missing? That would seem the best approach to me.

Thanks, Jon N

tbp1...@gmail.com

unread,
Aug 28, 2021, 8:13:04 AM8/28/21
to leo-editor
I think that would be reasonable, or it could be supplied via a setting.  I don't know enough about themes to be messing around with them yet so I haven't done anything with them so far.  I do plan to have a setting to enable the highlighting so no one has to have it if they don't want it.  Would a highlight color setting work for you, do you think?

Edward K. Ream

unread,
Aug 28, 2021, 11:30:50 AM8/28/21
to leo-editor
On Fri, Aug 27, 2021 at 4:36 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
The attached Leo outline contains a script to highlight the line in the body that has the cursor.  You can activate it by selecting the top-most node, then pressing CTRL-b. 

Thanks for this work.  I didn't see any highlighting, but then I'm using a dark theme.

I'd like to add this feature early in the 6.5 development cycle. I would rather not complicate the 6.4 release work.

Edward

tbp1...@gmail.com

unread,
Aug 28, 2021, 2:00:07 PM8/28/21
to leo-editor
Odd, I tried it out on every theme in Leo's theme directory and highlighting showed up on all of them, even the darkest.  An earlier version didn't show on very dark themes, so I changed the way the highlight color is calculated.

Well, we'll get that sorted out. I agree, it would be better for 6.5 instead of trying to get something so new into 6.4.

I have a technical question.  The code I'm using gets the fg and bg colors from c.active_stylesheet. Can this ever change during a Leo session? I would rather do it once during initialization than each time the cursor moves.  It seems to me that the active stylesheet won't change unless the theme is changed, but currently the theme can't be changed without closing Leo and restarting.

tbp1...@gmail.com

unread,
Aug 28, 2021, 3:01:34 PM8/28/21
to leo-editor
Here are screen shots for the line highlighting for nine of Leo's themes.  I got them by starting Leo with --theme=<theme file>  and pressing CTRL-B after selecting the script's top-level node.  The highlight color may seem a little faint for the very dark themes, and maybe it should be changed in some way.  Don't forget, though, that with the very dark themes one's eyes will be used to seeing the dark screen, and the highlight color will stand out more than appears in these little swatches.

The basic approach for selecting the highlight color is that it should have the same hue as the theme's background color, but a lighter or darker luminosity value.  Otherwise we would have to figure out a way to change the hue, and that is no simple problem if it is to be done harmoniously.

line-hilite-examples.png

tbp1...@gmail.com

unread,
Aug 28, 2021, 7:15:51 PM8/28/21
to leo-editor
Here is a tweaked version of the highlight script.  I added a setting to specify a highlight color - @string line-highlight-color. This string can be any CSS color name that Qt recognizes, such as black, cyan, lightgrey, etc.  Or it can be a #xxxxxx  CSS color number such as #839496.  If the setting contains an invalid color string, the script will ignore it and compute a highlight color.

I also brightened up the highlight color a bit for very dark backgrounds.

As before, to activate the line highlighting, select the top level node and press CTRL-b to run it.  After this, the currently selected line in the outline should be highlighted.  To try it in another outline, copy the entire script to the other outline and activate it.  To check out the color setting, add or change the @string line-highlight-color setting and reload settings.
highlight_line.leo

lewis

unread,
Aug 31, 2021, 12:40:56 AM8/31/21
to leo-editor
I tested the latest tweak in another leo outline, with the @string line-highlight-color setting in myLeoSettings file and it worked fine.
Nice work.

Lewis

tbp1...@gmail.com

unread,
Aug 31, 2021, 9:24:18 AM8/31/21
to leo-editor
Thanks, @Lewis.  After Leo 6.4 final is out, we'll get it into Leo itself - no more need to run it as an added script for each outline.  I already have that code working.  
Reply all
Reply to author
Forward
0 new messages