Better color schemes (e.g. solarized) are now possible

320 views
Skip to first unread message

Edward K. Ream

unread,
Oct 22, 2011, 10:45:06 AM10/22/11
to leo-editor
Rev 4637 of the trunk contains some important improvements to Leo's
color settings and related code. Here is the checkin log:

QQQQQ

Support (mostly) Solarized colors:

- fixed qtBody.setEditorColors so that both foreground and background
colors can be set.

- Added reference section (not active) in leoSettings.leo showing how
to enable solarized colors, including colors for syntax highlighting.

Still to do:

- With solarized colors, we would like the foreground text of selected
text
to be exactly the same color as unselected (colorized) text.

This can not be done using the Qt Stylesheet alone: instead, Leo
would
have to define a custom role for highlightedText. See:
http://doc.qt.nokia.com/4.7-snapshot/qpalette.html#ColorRole-enum

**Important**:

This work is not really about Solarized colors: it is about additional
coloring options.

Like all settings, it is perfectly ok to change whatever values you
like,
regardless of what Ethan Schoonover might prefer.

For my old eyes, low contrast Solarized scheme is problematic,
and I can not condone the solarized yellow and green colors.
QQQQQ

Imo, Solarized has other problems.

It assumes that there are only 8 syntax colors available (besides the
neutral "base" colors). But Leo's syntax coloring scheme permits
dozens of kinds of colors. No language description (in leo/modes)
uses all available color tags, but imo there is not the slightest
reason to restrict oneself to 8 colors.

Furthermore, the design requirements of Solarized, while theoretically
"elegant", are simply dubious, imo. What matters is readability, not
notions of balanced contrast.

In short, I might advertise Leo as "Solarized ready" without endorsing
Solarized in any way. I'll be experimenting with alternative schemes
today...

Edward

P.S. Not sure how difficult it will be to add a custom role that will
have the foreground text not to change as it is highlighted. Leo's
existing scheme, using a single gray background and white foreground,
seems very tame in comparison with the Solarized way.

When the new way becomes available, it will require a user option to
put it into effect. As I said, it can't be done with just a Qt
stylesheet.

EKR

Edward K. Ream

unread,
Oct 22, 2011, 1:02:35 PM10/22/11
to leo-editor
On Sat, Oct 22, 2011 at 9:45 AM, Edward K. Ream <edre...@gmail.com> wrote:

> Still to do:
>
> - With solarized colors, we would like the foreground text of selected
> text to be exactly the same color as unselected (colorized) text.
>
>  This can not be done using the Qt Stylesheet alone: instead, Leo
> would have to define a custom role for highlightedText.

My initial efforts have failed. Giving a role a new brush doesn't
work, because it seems that the stylesheet affects the new brush as
well as the old. There may be an easy solution, but at present I have
no clue about what it is. I may have to ask the Qt folks...

Edward

P.S. Here is my experimental code in the ctor for the leoQtBody class:

if 0: # xxx test: disable foreground color change for selected text.
palette = qtWidget.palette()
highlight_foreground_brush =
palette.brush(palette.Active,palette.HighlightedText) # white.
highlight_background_brush =
palette.brush(palette.Active,palette.Highlight) # dark blue
normal_brush = palette.brush(palette.Active,palette.Text)
g.trace('foreground',highlight_foreground_brush.color().name())
g.trace('background',highlight_background_brush.color().name())
highlight_foreground_brush.setColor(QtGui.QColor('red'))
g.trace('foreground',highlight_foreground_brush.color().name())
palette.setBrush(palette.HighlightedText,highlight_foreground_brush)

The new name becomes red, but highlighted text is colored as before.

EKR

Reply all
Reply to author
Forward
0 new messages