aboutsummaryrefslogtreecommitdiff
path: root/ui-curses.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-10-12 13:47:36 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-10-14 10:33:26 +0200
commit277c6b4897e11a5449fc1cfab3ab6e83307a7989 (patch)
treea8b34ab47c11dfd9995ef03d9fae1613dde2be67 /ui-curses.c
parent9e391f5e3b2baaee0bf73e5273daf84be8a76ce2 (diff)
downloadvis-277c6b4897e11a5449fc1cfab3ab6e83307a7989.tar.gz
vis-277c6b4897e11a5449fc1cfab3ab6e83307a7989.tar.xz
view: cleanup option handling
Diffstat (limited to 'ui-curses.c')
-rw-r--r--ui-curses.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/ui-curses.c b/ui-curses.c
index 7e74919..cd26508 100644
--- a/ui-curses.c
+++ b/ui-curses.c
@@ -798,26 +798,27 @@ static void ui_window_focus(UiWin *w) {
ui_window_draw(w);
}
-static void ui_window_options(UiWin *w, enum UiOption options) {
+static void ui_window_options_set(UiWin *w, enum UiOption options) {
UiCursesWin *win = (UiCursesWin*)w;
win->options = options;
- switch (options) {
- case UI_OPTION_LINE_NUMBERS_NONE:
+ if (options & (UI_OPTION_LINE_NUMBERS_ABSOLUTE|UI_OPTION_LINE_NUMBERS_RELATIVE)) {
+ if (!win->winside)
+ win->winside = newwin(1, 1, 1, 1);
+ } else {
if (win->winside) {
delwin(win->winside);
win->winside = NULL;
win->sidebar_width = 0;
}
- break;
- case UI_OPTION_LINE_NUMBERS_ABSOLUTE:
- case UI_OPTION_LINE_NUMBERS_RELATIVE:
- if (!win->winside)
- win->winside = newwin(1, 1, 1, 1);
- break;
}
ui_window_draw(w);
}
+static enum UiOption ui_window_options_get(UiWin *w) {
+ UiCursesWin *win = (UiCursesWin*)w;
+ return win->options;
+}
+
static UiWin *ui_window_new(Ui *ui, View *view, File *file) {
UiCurses *uic = (UiCurses*)ui;
UiCursesWin *win = calloc(1, sizeof(UiCursesWin));
@@ -828,7 +829,8 @@ static UiWin *ui_window_new(Ui *ui, View *view, File *file) {
.draw = ui_window_draw,
.draw_status = ui_window_draw_status,
.draw_text = ui_window_draw_text,
- .options = ui_window_options,
+ .options_set = ui_window_options_set,
+ .options_get = ui_window_options_get,
.reload = ui_window_reload,
.syntax_style = ui_window_syntax_style,
};