diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-21 17:13:58 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-21 18:01:58 +0200 |
| commit | 679552d6db9771ddbf29bd02eb8392b3f319d4cb (patch) | |
| tree | 2af606eb8fe1423908366313cdd5fbcdc9c46f45 /ui-curses.c | |
| parent | 38f00e3e8a50e1690dcb78cf1eca8b6befb7173b (diff) | |
| download | vis-679552d6db9771ddbf29bd02eb8392b3f319d4cb.tar.gz vis-679552d6db9771ddbf29bd02eb8392b3f319d4cb.tar.xz | |
ui: further separate curses related user interface code
By now ui-curses.[hc] are the only files dealing directly with
curses related functions. Integration of a proper mainloop is
still pending.
Diffstat (limited to 'ui-curses.c')
| -rw-r--r-- | ui-curses.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ui-curses.c b/ui-curses.c index 2473521..283ee16 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -371,11 +371,17 @@ static void ui_window_draw_text(UiWin *w, const Line *line) { /* add a single space in an otherwise empty line to make * the selection cohorent */ if (l->width == 1 && l->cells[0].data[0] == '\n') { - wattrset(win->win, l->cells[0].attr); + int attr = l->cells[0].attr; + if (l->cells[0].selected) + attr |= A_REVERSE; + wattrset(win->win, attr); waddstr(win->win, " \n"); } else { for (int x = 0; x < l->width; x++) { - wattrset(win->win, l->cells[x].attr); + int attr = l->cells[x].attr; + if (l->cells[x].selected) + attr |= A_REVERSE; + wattrset(win->win, attr); waddstr(win->win, l->cells[x].data); } if (l->width != win->width - win->sidebar_width) @@ -589,7 +595,7 @@ static void ui_terminal_restore(Ui *ui) { wclear(stdscr); } -Ui *ui_curses_new(void) { +Ui *ui_curses_new(Color *colors) { setlocale(LC_CTYPE, ""); if (!getenv("ESCDELAY")) set_escdelay(50); @@ -631,13 +637,18 @@ Ui *ui_curses_new(void) { .arrange = arrange, .info = info, .info_hide = info_hide, - .color_get = color_get, .haskey = ui_haskey, .getkey = ui_getkey, .terminal_save = ui_terminal_save, .terminal_restore = ui_terminal_restore, }; + for (Color *color = colors; color && color->fg; color++) { + if (color->attr == 0) + color->attr = A_NORMAL; + color->attr |= COLOR_PAIR(color_get(color->fg, color->bg)); + } + struct sigaction sa; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); |
