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 +++++++++++++--------- ui.h | 4 +++- vis.c | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) 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; } diff --git a/ui.h b/ui.h index 05d118d..e8beded 100644 --- a/ui.h +++ b/ui.h @@ -14,6 +14,7 @@ enum UiLayout { }; enum UiOption { + UI_OPTION_NONE = 0, UI_OPTION_LINE_NUMBERS_ABSOLUTE = 1 << 0, UI_OPTION_LINE_NUMBERS_RELATIVE = 1 << 1, UI_OPTION_SYMBOL_SPACE = 1 << 2, @@ -22,6 +23,7 @@ enum UiOption { UI_OPTION_SYMBOL_EOL = 1 << 5, UI_OPTION_SYMBOL_EOF = 1 << 6, UI_OPTION_CURSOR_LINE = 1 << 7, + UI_OPTION_STATUSBAR = 1 << 8, }; enum UiStyles { @@ -43,7 +45,7 @@ struct Ui { bool (*init)(Ui*, Vis*); void (*free)(Ui*); void (*resize)(Ui*); - UiWin* (*window_new)(Ui*, View*, File*); + UiWin* (*window_new)(Ui*, View*, File*, enum UiOption); void (*window_free)(UiWin*); void (*window_focus)(UiWin*); UiWin* (*prompt_new)(Ui*, View*, File*); diff --git a/vis.c b/vis.c index 8e033ca..e16fca4 100644 --- a/vis.c +++ b/vis.c @@ -164,7 +164,7 @@ static Win *window_new_file(Vis *vis, File *file) { win->file = file; win->jumplist = ringbuf_alloc(31); win->view = view_new(file->text, vis->lua); - win->ui = vis->ui->window_new(vis->ui, win->view, file); + win->ui = vis->ui->window_new(vis->ui, win->view, file, UI_OPTION_STATUSBAR); if (!win->jumplist || !win->view || !win->ui) { window_free(win); return NULL; -- cgit v1.2.3