dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit d1f4984228dff45fd1d77a8a4bbb6312de6dbb4f
parent 60f402c3a145fc250b718827713da7e4709beaa1
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Sat, 14 May 2011 15:35:04 +0200

madtty: cleanup color api

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
dvtm.c | 4++--
madtty.c | 10+++++-----
madtty.h | 2+-
statusbar.c | 2+-
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dvtm.c b/dvtm.c @@ -476,10 +476,10 @@ draw_border(Client *c) { int x, y, o; if (sel == c) { wattrset(c->window, SELECTED_ATTR); - madtty_color_set(c->window, SELECTED_FG, SELECTED_BG); + wcolor_set(c->window, madtty_color_get(SELECTED_FG, SELECTED_BG), NULL); } else { wattrset(c->window, NORMAL_ATTR); - madtty_color_set(c->window, NORMAL_FG, NORMAL_BG); + wcolor_set(c->window, madtty_color_get(NORMAL_FG, NORMAL_BG), NULL); } getyx(c->window, y, x); curs_set(0); diff --git a/madtty.c b/madtty.c @@ -1306,7 +1306,7 @@ void madtty_draw(madtty_t *t, WINDOW *win, int srow, int scol) if (row->bg[j] == -1) row->bg[j] = t->defbg; wattrset(win, (attr_t)row->attr[j] << NCURSES_ATTR_SHIFT); - madtty_color_set(win, row->fg[j], row->bg[j]); + wcolor_set(win, madtty_color_get(row->fg[j], row->bg[j]), NULL); } if (is_utf8 && row->text[j] >= 128) { char buf[MB_CUR_MAX + 1]; @@ -1501,13 +1501,13 @@ static unsigned color_hash(short f, short b) return ((f+1) * COLORS) + b + 1; } -void madtty_color_set(WINDOW *win, short fg, short bg) +short madtty_color_get(short fg, short bg) { static unsigned palette_cur = COLOR_PALETTE_START; if (use_color_palette) { if (fg == -1 && bg == -1) { - wcolor_set(win, 0, NULL); + return 0; } else { unsigned c = color_hash(fg, bg); if (color2palette[c] == 0) { @@ -1521,7 +1521,7 @@ void madtty_color_set(WINDOW *win, short fg, short bg) /* possibly use mvwinch/mvchgat to update palette */ } } - wcolor_set(win, color2palette[c], NULL); + return color2palette[c]; } } else { if (has_default_colors) { @@ -1530,7 +1530,7 @@ void madtty_color_set(WINDOW *win, short fg, short bg) if (bg == -1) bg = COLOR_BLACK; } - wcolor_set(win, (7-fg)*8 + bg, NULL); + return (7-fg)*8 + bg; } } diff --git a/madtty.h b/madtty.h @@ -72,7 +72,7 @@ void madtty_keypress_sequence(madtty_t *, const char *seq); void madtty_mouse(madtty_t *t, int x, int y, mmask_t mask); void madtty_dirty(madtty_t *t); void madtty_draw(madtty_t *, WINDOW *win, int startrow, int startcol); -void madtty_color_set(WINDOW *win, short fg, short bg); +short madtty_color_get(short fg, short bg); void madtty_scroll(madtty_t *, int rows); void madtty_noscroll(madtty_t *); diff --git a/statusbar.c b/statusbar.c @@ -28,7 +28,7 @@ drawbar() { return; curs_set(0); attrset(BAR_ATTR); - madtty_color_set(stdscr, BAR_FG, BAR_BG); + wcolor_set(stdscr, madtty_color_get(BAR_FG, BAR_BG), NULL); mvaddch(by, 0, '['); if (mbstowcs(wbuf, stext, sizeof stext) == (size_t)-1) return;