vamolessa / pepper

simple and opinionated modal code editor for your terminal
https://vamolessa.github.io/pepper/
373 stars 15 forks source link

Allow configuring cursor foreground #3

Closed leahneukirchen closed 2 years ago

leahneukirchen commented 3 years ago

Many color themes use a bright cursor but otherwise light text on dark background, so it would be good to use a different color for the character under cursor then (as terminal emulators do).

I guess one color is good enough for all cursors for now.

vamolessa commented 3 years ago

hmm I'm still thinking about it. At first I would like to keep things simple and avoid having to compute if a color has good contrast against another one. And we would just leave it to theme authors to carefully chose cursor colors. However, we could also consider having, for each cursor color, an associated "text color", although that would create even more color entries in the config.

leahneukirchen commented 3 years ago

Yeah, the latter was what I had in mind. But maybe using the default background color as foreground color works already, I'll try it. :)

leahneukirchen commented 3 years ago

Using this now for the meantime:

--- a/src/ui.rs
+++ b/src/ui.rs
@@ -330,7 +330,7 @@ fn draw_buffer(buf: &mut Vec<u8>, editor: &Editor, view: &View, has_focus: bool)
                 if draw_state != DrawState::Cursor {
                     draw_state = DrawState::Cursor;
                     set_background_color(buf, cursor_color);
-                    set_foreground_color(buf, text_color);
+                    set_foreground_color(buf, background_color);
                 }
             } else if inside_cursor_range {
                 if draw_state != DrawState::Selection(token_kind) {
vamolessa commented 2 years ago

Will close this as the cursor contrast should be handled by the theme.