diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-04-11 11:03:24 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-04-11 11:04:23 +0200 |
| commit | be1fb4cc4edf9cc861831961cac1d0400a87db36 (patch) | |
| tree | 96ab40297d9558eb43b130cbd1392e5873489f11 /ui-curses.c | |
| parent | 3ea63f3951dd8e1c624966d6966ea8ca0e359b09 (diff) | |
| download | vis-be1fb4cc4edf9cc861831961cac1d0400a87db36.tar.gz vis-be1fb4cc4edf9cc861831961cac1d0400a87db36.tar.xz | |
Further ui separation, eliminate global state
Diffstat (limited to 'ui-curses.c')
| -rw-r--r-- | ui-curses.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/ui-curses.c b/ui-curses.c index 6012dc1..f92d787 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -77,6 +77,12 @@ struct UiCursesWin { enum UiOption options; /* display settings for this window */ }; +static volatile sig_atomic_t need_resize; /* TODO */ + +static void sigwinch_handler(int sig) { + need_resize = true; +} + static unsigned int color_hash(short fg, short bg) { if (fg == -1) fg = COLORS; @@ -231,22 +237,6 @@ static void ui_window_update(UiCursesWin *win) { wnoutrefresh(win->win); } -static void update(Ui *ui) { - UiCurses *uic = (UiCurses*)ui; - for (UiCursesWin *win = uic->windows; win; win = win->next) { - if (win != uic->selwin) - ui_window_update(win); - } - - if (uic->selwin) - ui_window_update(uic->selwin); - if (uic->prompt_title[0]) { - wnoutrefresh(uic->prompt_win->win); - ui_window_update(uic->prompt_win); - } - doupdate(); -} - static void arrange(Ui *ui, enum UiLayout layout) { UiCurses *uic = (UiCurses*)ui; uic->layout = layout; @@ -321,6 +311,26 @@ static void ui_resize(Ui *ui) { ui_resize_to(ui, width, height); } +static void update(Ui *ui) { + UiCurses *uic = (UiCurses*)ui; + if (need_resize) { + ui_resize(ui); + need_resize = false; + } + for (UiCursesWin *win = uic->windows; win; win = win->next) { + if (win != uic->selwin) + ui_window_update(win); + } + + if (uic->selwin) + ui_window_update(uic->selwin); + if (uic->prompt_title[0]) { + wnoutrefresh(uic->prompt_win->win); + ui_window_update(uic->prompt_win); + } + doupdate(); +} + static void ui_window_free(UiWin *w) { UiCursesWin *win = (UiCursesWin*)w; if (!win) @@ -559,6 +569,13 @@ Ui *ui_curses_new(void) { .color_get = color_get, }; + struct sigaction sa; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sa.sa_handler = sigwinch_handler; + sigaction(SIGWINCH, &sa, NULL); + sigaction(SIGCONT, &sa, NULL); + ui_resize(ui); return ui; |
