From 8ca992e7a2d2f7be3b4e46a988443525575ca72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 14 Nov 2015 07:44:52 +0100 Subject: ui: make statusbar configurable --- ui-curses.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'ui-curses.c') diff --git a/ui-curses.c b/ui-curses.c index 0bfd9d8..68ab5b5 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -871,6 +871,14 @@ static void ui_window_options_set(UiWin *w, enum UiOption options) { win->sidebar_width = 0; } } + if (options & UI_OPTION_STATUSBAR) { + if (!win->winstatus) + win->winstatus = newwin(1, 0, 0, 0); + } else { + if (win->winstatus) + delwin(win->winstatus); + win->winstatus = NULL; + } ui_window_draw(w); } @@ -879,7 +887,7 @@ static enum UiOption ui_window_options_get(UiWin *w) { return win->options; } -static UiWin *ui_window_new(Ui *ui, View *view, File *file) { +static UiWin *ui_window_new(Ui *ui, View *view, File *file, enum UiOption options) { UiCurses *uic = (UiCurses*)ui; UiCursesWin *win = calloc(1, sizeof(UiCursesWin)); if (!win) @@ -894,7 +902,7 @@ static UiWin *ui_window_new(Ui *ui, View *view, File *file) { .syntax_style = ui_window_syntax_style, }; - if (!(win->win = newwin(0, 0, 0, 0)) || !(win->winstatus = newwin(1, 0, 0, 0))) { + if (!(win->win = newwin(0, 0, 0, 0))) { ui_window_free((UiWin*)win); return NULL; } @@ -922,6 +930,8 @@ static UiWin *ui_window_new(Ui *ui, View *view, File *file) { win->next = uic->windows; uic->windows = win; + ui_window_options_set((UiWin*)win, options); + return &win->uiwin; } @@ -952,19 +962,13 @@ static UiWin *ui_prompt_new(Ui *ui, View *view, File *file) { UiCurses *uic = (UiCurses*)ui; if (uic->prompt_win) return (UiWin*)uic->prompt_win; - UiWin *uiwin = ui_window_new(ui, view, file); + UiWin *uiwin = ui_window_new(ui, view, file, UI_OPTION_NONE); UiCursesWin *win = (UiCursesWin*)uiwin; if (!win) return NULL; uic->windows = win->next; if (uic->windows) uic->windows->prev = NULL; - if (win->winstatus) - delwin(win->winstatus); - if (win->winside) - delwin(win->winside); - win->winstatus = NULL; - win->winside = NULL; uic->prompt_win = win; return uiwin; } -- cgit v1.2.3