aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui-terminal.c104
-rw-r--r--ui.h25
-rw-r--r--view.c20
-rw-r--r--view.h3
-rw-r--r--vis-cmds.c12
-rw-r--r--vis-lua.c30
-rw-r--r--vis.c22
-rw-r--r--vis.h2
8 files changed, 82 insertions, 136 deletions
diff --git a/ui-terminal.c b/ui-terminal.c
index 8c27416..9aaac7d 100644
--- a/ui-terminal.c
+++ b/ui-terminal.c
@@ -32,13 +32,12 @@
#define MAX_WIDTH 1024
#define MAX_HEIGHT 1024
-typedef struct UiTermWin UiTermWin;
-typedef struct {
+struct UiTerm {
Ui ui; /* generic ui interface, has to be the first struct member */
Vis *vis; /* editor instance to which this ui belongs */
- UiTermWin *windows; /* all windows managed by this ui */
- UiTermWin *selwin; /* the currently selected layout */
+ UiWin *windows; /* all windows managed by this ui */
+ UiWin *selwin; /* the currently selected layout */
char info[MAX_WIDTH]; /* info message displayed at the bottom of the screen */
int width, height; /* terminal dimensions available for all windows */
enum UiLayout layout; /* whether windows are displayed horizontally or vertically */
@@ -49,18 +48,6 @@ typedef struct {
size_t cells_size; /* #bytes allocated for 2D grid (grows only) */
Cell *cells; /* 2D grid of cells, at least as large as current terminal size */
bool doupdate; /* Whether to update the screen after refreshing contents */
-} UiTerm;
-
-struct UiTermWin {
- UiWin uiwin; /* generic interface, has to be the first struct member */
- UiTerm *ui; /* ui which manages this window */
- Win *win; /* editor window being displayed */
- int id; /* unique identifier for this window */
- int width, height; /* window dimension including status bar */
- int x, y; /* window position */
- int sidebar_width; /* width of the sidebar showing line numbers etc. */
- UiTermWin *next, *prev; /* pointers to neighbouring windows */
- enum UiOption options; /* display settings for this window */
};
#if CONFIG_CURSES
@@ -88,7 +75,7 @@ __attribute__((noreturn)) static void ui_die_msg(Ui *ui, const char *msg, ...) {
va_end(ap);
}
-static void ui_window_resize(UiTermWin *win, int width, int height) {
+static void ui_window_resize(UiWin *win, int width, int height) {
debug("ui-win-resize[%s]: %dx%d\n", win->win->file->name ? win->win->file->name : "noname", width, height);
bool status = win->options & UI_OPTION_STATUSBAR;
win->width = width;
@@ -96,7 +83,7 @@ static void ui_window_resize(UiTermWin *win, int width, int height) {
view_resize(win->win->view, width - win->sidebar_width, status ? height - 1 : height);
}
-static void ui_window_move(UiTermWin *win, int x, int y) {
+static void ui_window_move(UiWin *win, int x, int y) {
debug("ui-win-move[%s]: (%d, %d)\n", win->win->file->name ? win->win->file->name : "noname", x, y);
win->x = x;
win->y = y;
@@ -150,8 +137,7 @@ static bool color_fromstring(UiTerm *ui, CellColor *color, const char *s)
return false;
}
-static bool ui_style_define(UiWin *w, int id, const char *style) {
- UiTermWin *win = (UiTermWin*)w;
+bool ui_style_define(UiWin *win, int id, const char *style) {
UiTerm *tui = win->ui;
if (id >= UI_STYLE_MAX)
return false;
@@ -217,7 +203,7 @@ static void ui_draw_line(UiTerm *tui, int x, int y, char c, enum UiStyle style_i
}
}
-static void ui_draw_string(UiTerm *tui, int x, int y, const char *str, UiTermWin *win, enum UiStyle style_id) {
+static void ui_draw_string(UiTerm *tui, int x, int y, const char *str, UiWin *win, enum UiStyle style_id) {
debug("draw-string: [%d][%d]\n", y, x);
if (x < 0 || x >= tui->width || y < 0 || y >= tui->height)
return;
@@ -238,8 +224,7 @@ static void ui_draw_string(UiTerm *tui, int x, int y, const char *str, UiTermWin
}
}
-static void ui_window_draw(UiWin *w) {
- UiTermWin *win = (UiTermWin*)w;
+static void ui_window_draw(UiWin *win) {
UiTerm *ui = win->ui;
View *view = win->win->view;
int width = win->width, height = win->height;
@@ -290,8 +275,7 @@ static void ui_window_draw(UiWin *w) {
}
}
-static void ui_window_style_set(UiWin *w, Cell *cell, enum UiStyle id) {
- UiTermWin *win = (UiTermWin*)w;
+void ui_window_style_set(UiWin *win, Cell *cell, enum UiStyle id) {
UiTerm *tui = win->ui;
CellStyle set, style = tui->styles[win->id * UI_STYLE_MAX + id];
@@ -307,19 +291,17 @@ static void ui_window_style_set(UiWin *w, Cell *cell, enum UiStyle id) {
memcpy(&cell->style, &set, sizeof(CellStyle));
}
-static bool ui_window_style_set_pos(UiWin *w, int x, int y, enum UiStyle id) {
- UiTermWin *win = (UiTermWin*)w;
+bool ui_window_style_set_pos(UiWin *win, int x, int y, enum UiStyle id) {
UiTerm *tui = win->ui;
if (x < 0 || y < 0 || y >= win->height || x >= win->width) {
return false;
}
Cell *cell = CELL_AT_POS(tui, win->x + x, win->y + y)
- ui_window_style_set(w, cell, id);
+ ui_window_style_set(win, cell, id);
return true;
}
-static void ui_window_status(UiWin *w, const char *status) {
- UiTermWin *win = (UiTermWin*)w;
+void ui_window_status(UiWin *win, const char *status) {
if (!(win->options & UI_OPTION_STATUSBAR))
return;
UiTerm *ui = win->ui;
@@ -332,7 +314,7 @@ static void ui_arrange(Ui *ui, enum UiLayout layout) {
UiTerm *tui = (UiTerm*)ui;
tui->layout = layout;
int n = 0, m = !!tui->info[0], x = 0, y = 0;
- for (UiTermWin *win = tui->windows; win; win = win->next) {
+ for (UiWin *win = tui->windows; win; win = win->next) {
if (win->options & UI_OPTION_ONELINE)
m++;
else
@@ -341,7 +323,7 @@ static void ui_arrange(Ui *ui, enum UiLayout layout) {
int max_height = tui->height - m;
int width = (tui->width / MAX(1, n)) - 1;
int height = max_height / MAX(1, n);
- for (UiTermWin *win = tui->windows; win; win = win->next) {
+ for (UiWin *win = tui->windows; win; win = win->next) {
if (win->options & UI_OPTION_ONELINE)
continue;
n--;
@@ -370,7 +352,7 @@ static void ui_arrange(Ui *ui, enum UiLayout layout) {
if (layout == UI_LAYOUT_VERTICAL)
y = max_height;
- for (UiTermWin *win = tui->windows; win; win = win->next) {
+ for (UiWin *win = tui->windows; win; win = win->next) {
if (!(win->options & UI_OPTION_ONELINE))
continue;
ui_window_resize(win, tui->width, 1);
@@ -387,7 +369,7 @@ static void ui_draw(Ui *ui) {
debug("ui-draw\n");
UiTerm *tui = (UiTerm*)ui;
ui_arrange(ui, tui->layout);
- for (UiTermWin *win = tui->windows; win; win = win->next)
+ for (UiWin *win = tui->windows; win; win = win->next)
ui_window_draw((UiWin*)win);
if (tui->info[0])
ui_draw_string(tui, 0, tui->height-1, tui->info, NULL, UI_STYLE_INFO);
@@ -398,7 +380,7 @@ static void ui_draw(Ui *ui) {
static void ui_redraw(Ui *ui) {
UiTerm *tui = (UiTerm*)ui;
ui_term_backend_clear(tui);
- for (UiTermWin *win = tui->windows; win; win = win->next)
+ for (UiWin *win = tui->windows; win; win = win->next)
win->win->view->need_update = true;
}
@@ -432,8 +414,7 @@ static void ui_resize(Ui *ui) {
tui->height = height;
}
-static void ui_window_free(UiWin *w) {
- UiTermWin *win = (UiTermWin*)w;
+static void ui_window_free(UiWin *win) {
if (!win)
return;
UiTerm *tui = win->ui;
@@ -450,9 +431,8 @@ static void ui_window_free(UiWin *w) {
free(win);
}
-static void ui_window_focus(UiWin *w) {
- UiTermWin *new = (UiTermWin*)w;
- UiTermWin *old = new->ui->selwin;
+static void ui_window_focus(UiWin *new) {
+ UiWin *old = new->ui->selwin;
if (new->options & UI_OPTION_STATUSBAR)
new->ui->selwin = new;
if (old)
@@ -460,13 +440,12 @@ static void ui_window_focus(UiWin *w) {
new->win->view->need_update = true;
}
-static void ui_window_options_set(UiWin *w, enum UiOption options) {
- UiTermWin *win = (UiTermWin*)w;
+void ui_window_options_set(UiWin *win, enum UiOption options) {
win->options = options;
if (options & UI_OPTION_ONELINE) {
/* move the new window to the end of the list */
UiTerm *tui = win->ui;
- UiTermWin *last = tui->windows;
+ UiWin *last = tui->windows;
while (last->next)
last = last->next;
if (last != win) {
@@ -484,25 +463,11 @@ static void ui_window_options_set(UiWin *w, enum UiOption options) {
ui_draw((Ui*)win->ui);
}
-static enum UiOption ui_window_options_get(UiWin *win) {
- return ((UiTermWin*)win)->options;
-}
-
-static int ui_window_width(UiWin *win) {
- return ((UiTermWin*)win)->width;
-}
-
-static int ui_window_height(UiWin *win) {
- return ((UiTermWin*)win)->height;
-}
-
-static void ui_window_swap(UiWin *aw, UiWin *bw) {
- UiTermWin *a = (UiTermWin*)aw;
- UiTermWin *b = (UiTermWin*)bw;
+static void ui_window_swap(UiWin *a, UiWin *b) {
if (a == b || !a || !b)
return;
UiTerm *tui = a->ui;
- UiTermWin *tmp = a->next;
+ UiWin *tmp = a->next;
a->next = b->next;
b->next = tmp;
if (a->next)
@@ -521,9 +486,9 @@ static void ui_window_swap(UiWin *aw, UiWin *bw) {
else if (tui->windows == b)
tui->windows = a;
if (tui->selwin == a)
- ui_window_focus(bw);
+ ui_window_focus(b);
else if (tui->selwin == b)
- ui_window_focus(aw);
+ ui_window_focus(a);
}
static UiWin *ui_window_new(Ui *ui, Win *w, enum UiOption options) {
@@ -542,21 +507,10 @@ static UiWin *ui_window_new(Ui *ui, Win *w, enum UiOption options) {
tui->styles = styles;
tui->styles_size = styles_size;
}
- UiTermWin *win = calloc(1, sizeof(UiTermWin));
+ UiWin *win = calloc(1, sizeof(UiWin));
if (!win)
return NULL;
- win->uiwin = (UiWin) {
- .style_set = ui_window_style_set,
- .style_set_pos = ui_window_style_set_pos,
- .status = ui_window_status,
- .options_set = ui_window_options_set,
- .options_get = ui_window_options_get,
- .style_define = ui_style_define,
- .window_width = ui_window_width,
- .window_height = ui_window_height,
- };
-
tui->ids |= bit;
win->id = id;
win->ui = tui;
@@ -578,7 +532,7 @@ static UiWin *ui_window_new(Ui *ui, Win *w, enum UiOption options) {
styles[UI_STYLE_STATUS].attr |= CELL_ATTR_REVERSE;
styles[UI_STYLE_STATUS_FOCUSED].attr |= CELL_ATTR_REVERSE|CELL_ATTR_BOLD;
styles[UI_STYLE_INFO].attr |= CELL_ATTR_BOLD;
- w->view->ui = &win->uiwin;
+ w->view->ui = win;
if (tui->windows)
tui->windows->prev = win;
@@ -592,7 +546,7 @@ static UiWin *ui_window_new(Ui *ui, Win *w, enum UiOption options) {
ui_window_options_set((UiWin*)win, options);
- return &win->uiwin;
+ return win;
}
static void ui_info(Ui *ui, const char *msg, va_list ap) {
diff --git a/ui.h b/ui.h
index 45b6065..3a4bb8b 100644
--- a/ui.h
+++ b/ui.h
@@ -12,6 +12,7 @@
typedef struct Ui Ui;
typedef struct UiWin UiWin;
+typedef struct UiTerm UiTerm;
enum UiLayout {
UI_LAYOUT_HORIZONTAL,
@@ -96,16 +97,24 @@ struct Ui {
};
struct UiWin {
- void (*style_set)(UiWin*, Cell*, enum UiStyle);
- bool (*style_set_pos)(UiWin*, int x, int y, enum UiStyle);
- void (*status)(UiWin*, const char *txt);
- void (*options_set)(UiWin*, enum UiOption);
- enum UiOption (*options_get)(UiWin*);
- bool (*style_define)(UiWin*, int id, const char *style);
- int (*window_width)(UiWin*);
- int (*window_height)(UiWin*);
+ UiTerm *ui; /* ui which manages this window */
+ Win *win; /* editor window being displayed */
+ int id; /* unique identifier for this window */
+ int width, height; /* window dimension including status bar */
+ int x, y; /* window position */
+ int sidebar_width; /* width of the sidebar showing line numbers etc. */
+ UiWin *next, *prev; /* pointers to neighbouring windows */
+ enum UiOption options; /* display settings for this window */
};
+#define UI_OPTIONS_GET(ui) ((ui) ? (ui)->options : 0)
+
+bool ui_style_define(UiWin *win, int id, const char *style);
+bool ui_window_style_set_pos(UiWin *win, int x, int y, enum UiStyle id);
+void ui_window_style_set(UiWin *win, Cell *cell, enum UiStyle id);
+
enum UiLayout ui_layout_get(Ui *ui);
+void ui_window_options_set(UiWin *win, enum UiOption options);
+void ui_window_status(UiWin *win, const char *status);
#endif
diff --git a/view.c b/view.c
index 29b8c32..afc72da 100644
--- a/view.c
+++ b/view.c
@@ -74,8 +74,8 @@ void window_status_update(Vis *vis, Win *win) {
View *view = win->view;
File *file = win->file;
Text *txt = file->text;
- int width = win->ui->window_width(win->ui);
- enum UiOption options = view_options_get(view);
+ int width = win->ui->width;
+ enum UiOption options = UI_OPTIONS_GET(view->ui);
bool focused = vis->win == win;
const char *filename = file_name_get(file);
const char *mode = vis->mode->status;
@@ -153,7 +153,7 @@ void window_status_update(Vis *vis, Win *win) {
spaces = 1;
snprintf(status, sizeof(status), "%s%*s%s", left, spaces, " ", right);
- vis_window_status(win, status);
+ ui_window_status(win->ui, status);
}
void view_tabwidth_set(View *view, int tabwidth) {
@@ -203,7 +203,7 @@ static void view_clear(View *view) {
view->wrapcol = 0;
view->prevch_breakat = false;
if (view->ui)
- view->ui->style_set(view->ui, &view->cell_blank, UI_STYLE_DEFAULT);
+ ui_window_style_set(view->ui, &view->cell_blank, UI_STYLE_DEFAULT);
}
static int view_max_text_width(const View *view) {
@@ -890,11 +890,7 @@ void view_options_set(View *view, enum UiOption options) {
view->large_file = (options & UI_OPTION_LARGE_FILE);
if (view->ui)
- view->ui->options_set(view->ui, options);
-}
-
-enum UiOption view_options_get(View *view) {
- return view->ui ? view->ui->options_get(view->ui) : 0;
+ ui_window_options_set(view->ui, options);
}
bool view_breakat_set(View *view, const char *breakat) {
@@ -1351,10 +1347,6 @@ char *view_symbol_eof_get(View *view) {
return view->symbols[SYNTAX_SYMBOL_EOF]->symbol;
}
-bool view_style_define(View *view, enum UiStyle id, const char *style) {
- return view->ui->style_define(view->ui, id, style);
-}
-
void view_style(View *view, enum UiStyle style, size_t start, size_t end) {
if (end < view->start || start > view->end)
return;
@@ -1384,7 +1376,7 @@ void view_style(View *view, enum UiStyle style, size_t start, size_t end) {
do {
while (pos <= end && col < width) {
pos += line->cells[col].len;
- view->ui->style_set(view->ui, &line->cells[col++], style);
+ ui_window_style_set(view->ui, &line->cells[col++], style);
}
col = 0;
} while (pos <= end && (line = line->next));
diff --git a/view.h b/view.h
index fff6cfc..a9ebbc5 100644
--- a/view.h
+++ b/view.h
@@ -357,13 +357,10 @@ bool view_regions_save(View*, Filerange*, SelectionRegion*);
* @{
*/
void view_options_set(View*, enum UiOption options);
-enum UiOption view_options_get(View*);
bool view_breakat_set(View*, const char *breakat);
/** Set how many spaces are used to display a tab `\t` character. */
void view_tabwidth_set(View*, int tabwidth);
-/** Define a display style. */
-bool view_style_define(View*, enum UiStyle, const char *style);
/** Apply a style to a text range. */
void view_style(View*, enum UiStyle, size_t start, size_t end);
diff --git a/vis-cmds.c b/vis-cmds.c
index 6cfc932..2b3398d 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -276,7 +276,7 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select
[OPTION_SHOW_EOF] = UI_OPTION_SYMBOL_EOF,
[OPTION_STATUSBAR] = UI_OPTION_STATUSBAR,
};
- int flags = view_options_get(win->view);
+ int flags = UI_OPTIONS_GET(win->view->ui);
if (arg.b || (toggle && !(flags & values[opt_index])))
flags |= values[opt_index];
else
@@ -285,7 +285,7 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select
break;
}
case OPTION_NUMBER: {
- enum UiOption opt = view_options_get(win->view);
+ enum UiOption opt = UI_OPTIONS_GET(win->view->ui);
if (arg.b || (toggle && !(opt & UI_OPTION_LINE_NUMBERS_ABSOLUTE))) {
opt &= ~UI_OPTION_LINE_NUMBERS_RELATIVE;
opt |= UI_OPTION_LINE_NUMBERS_ABSOLUTE;
@@ -296,7 +296,7 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select
break;
}
case OPTION_NUMBER_RELATIVE: {
- enum UiOption opt = view_options_get(win->view);
+ enum UiOption opt = UI_OPTIONS_GET(win->view->ui);
if (arg.b || (toggle && !(opt & UI_OPTION_LINE_NUMBERS_RELATIVE))) {
opt &= ~UI_OPTION_LINE_NUMBERS_ABSOLUTE;
opt |= UI_OPTION_LINE_NUMBERS_RELATIVE;
@@ -307,7 +307,7 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select
break;
}
case OPTION_CURSOR_LINE: {
- enum UiOption opt = view_options_get(win->view);
+ enum UiOption opt = UI_OPTIONS_GET(win->view->ui);
if (arg.b || (toggle && !(opt & UI_OPTION_CURSOR_LINE)))
opt |= UI_OPTION_CURSOR_LINE;
else
@@ -545,7 +545,7 @@ static bool cmd_qall(Vis *vis, Win *win, Command *cmd, const char *argv[], Selec
static bool cmd_split(Vis *vis, Win *win, Command *cmd, const char *argv[], Selection *sel, Filerange *range) {
if (!win)
return false;
- enum UiOption options = view_options_get(win->view);
+ enum UiOption options = UI_OPTIONS_GET(win->view->ui);
windows_arrange(vis, UI_LAYOUT_HORIZONTAL);
if (!argv[1])
return vis_window_split(win);
@@ -558,7 +558,7 @@ static bool cmd_split(Vis *vis, Win *win, Command *cmd, const char *argv[], Sele
static bool cmd_vsplit(Vis *vis, Win *win, Command *cmd, const char *argv[], Selection *sel, Filerange *range) {
if (!win)
return false;
- enum UiOption options = view_options_get(win->view);
+ enum UiOption options = UI_OPTIONS_GET(win->view->ui);
windows_arrange(vis, UI_LAYOUT_VERTICAL);
if (!argv[1])
return vis_window_split(win);
diff --git a/vis-lua.c b/vis-lua.c
index e8911f1..4bf582a 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1788,12 +1788,12 @@ static int window_index(lua_State *L) {
}
if (strcmp(key, "width") == 0) {
- lua_pushunsigned(L, win->ui->window_width(win->ui));
+ lua_pushunsigned(L, win->ui->width);
return 1;
}
if (strcmp(key, "height") == 0) {
- lua_pushunsigned(L, win->ui->window_height(win->ui));
+ lua_pushunsigned(L, win->ui->height);
return 1;
}
@@ -1827,7 +1827,7 @@ static int window_index(lua_State *L) {
}
static int window_options_assign(Win *win, lua_State *L, const char *key, int next) {
- enum UiOption flags = view_options_get(win->view);
+ enum UiOption flags = UI_OPTIONS_GET(win->view->ui);
if (strcmp(key, "breakat") == 0 || strcmp(key, "brk") == 0) {
if (lua_isstring(L, next))
view_breakat_set(win->view, lua_tostring(L, next));
@@ -1988,7 +1988,7 @@ static int window_style_define(lua_State *L) {
Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW);
enum UiStyle id = luaL_checkunsigned(L, 2);
const char *style = luaL_checkstring(L, 3);
- bool ret = view_style_define(win->view, id, style);
+ bool ret = ui_style_define(win->view->ui, id, style);
lua_pushboolean(L, ret);
return 1;
}
@@ -2035,7 +2035,7 @@ static int window_style_pos(lua_State *L) {
enum UiStyle style = luaL_checkunsigned(L, 2);
size_t x = checkpos(L, 3);
size_t y = checkpos(L, 4);
- bool ret = win->ui->style_set_pos(win->ui, (int)x, (int)y, style);
+ bool ret = ui_window_style_set_pos(win->ui, (int)x, (int)y, style);
lua_pushboolean(L, ret);
return 1;
}
@@ -2050,7 +2050,7 @@ static int window_style_pos(lua_State *L) {
static int window_status(lua_State *L) {
Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW);
char status[1024] = "";
- int width = win->ui->window_width(win->ui);
+ int width = win->ui->width;
const char *left = luaL_checkstring(L, 2);
const char *right = luaL_optstring(L, 3, "");
int left_width = text_string_width(left, strlen(left));
@@ -2059,7 +2059,7 @@ static int window_status(lua_State *L) {
if (spaces < 1)
spaces = 1;
snprintf(status, sizeof(status)-1, "%s%*s%s", left, spaces, " ", right);
- vis_window_status(win, status);
+ ui_window_status(win->ui, status);
return 0;
}
@@ -2148,31 +2148,31 @@ static int window_options_index(lua_State *L) {
lua_pushunsigned(L, win->view->colorcolumn);
return 1;
} else if (strcmp(key, "cursorline") == 0 || strcmp(key, "cul") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_CURSOR_LINE);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_CURSOR_LINE);
return 1;
} else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) {
lua_pushboolean(L, win->expandtab);
return 1;
} else if (strcmp(key, "numbers") == 0 || strcmp(key, "nu") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_LINE_NUMBERS_ABSOLUTE);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_LINE_NUMBERS_ABSOLUTE);
return 1;
} else if (strcmp(key, "relativenumbers") == 0 || strcmp(key, "rnu") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_LINE_NUMBERS_RELATIVE);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_LINE_NUMBERS_RELATIVE);
return 1;
} else if (strcmp(key, "showeof") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_SYMBOL_EOF);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_SYMBOL_EOF);
return 1;
} else if (strcmp(key, "shownewlines") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_SYMBOL_EOL);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_SYMBOL_EOL);
return 1;
} else if (strcmp(key, "showspaces") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_SYMBOL_SPACE);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_SYMBOL_SPACE);
return 1;
} else if (strcmp(key, "showtabs") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_SYMBOL_TAB);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_SYMBOL_TAB);
return 1;
} else if (strcmp(key, "statusbar") == 0) {
- lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_STATUSBAR);
+ lua_pushboolean(L, UI_OPTIONS_GET(win->view->ui) & UI_OPTION_STATUSBAR);
return 1;
} else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) {
lua_pushinteger(L, win->view->tabwidth);
diff --git a/vis.c b/vis.c
index c1b9ae0..d03bde8 100644
--- a/vis.c
+++ b/vis.c
@@ -184,10 +184,6 @@ const char *file_name_get(File *file) {
return file->name[cwdlen] == '/' ? file->name+cwdlen+1 : file->name;
}
-void vis_window_status(Win *win, const char *status) {
- win->ui->status(win->ui, status);
-}
-
void window_selection_save(Win *win) {
Vis *vis = win->vis;
View *view = win->view;
@@ -238,7 +234,7 @@ static void window_draw_colorcolumn(Win *win) {
/* This screen line contains the cell we want to highlight */
if (cc <= line_cols + width) {
- win->ui->style_set(win->ui, &l->cells[cc - 1 - line_cols], UI_STYLE_COLOR_COLUMN);
+ ui_window_style_set(win->ui, &l->cells[cc - 1 - line_cols], UI_STYLE_COLOR_COLUMN);
line_cc_set = true;
} else {
line_cols += width;
@@ -249,7 +245,7 @@ static void window_draw_colorcolumn(Win *win) {
static void window_draw_cursorline(Win *win) {
Vis *vis = win->vis;
View *view = win->view;
- enum UiOption options = view_options_get(view);
+ enum UiOption options = UI_OPTIONS_GET(view->ui);
if (!(options & UI_OPTION_CURSOR_LINE))
return;
if (vis->mode->visual || vis->win != win)
@@ -263,7 +259,7 @@ static void window_draw_cursorline(Win *win) {
for (Line *l = view->topline; l; l = l->next) {
if (l->lineno == lineno) {
for (int x = 0; x < width; x++)
- win->ui->style_set(win->ui, &l->cells[x], UI_STYLE_CURSOR_LINE);
+ ui_window_style_set(win->ui, &l->cells[x], UI_STYLE_CURSOR_LINE);
} else if (l->lineno > lineno) {
break;
}
@@ -293,7 +289,7 @@ static void window_draw_selection(Win *win, Selection *cur) {
int col = (l == start_line) ? start_col : 0;
int end = (l == end_line) ? end_col : l->width;
while (col < end)
- win->ui->style_set(win->ui, &l->cells[col++], UI_STYLE_SELECTION);
+ ui_window_style_set(win->ui, &l->cells[col++], UI_STYLE_SELECTION);
}
}
@@ -308,7 +304,7 @@ static void window_draw_cursor_matching(Win *win, Selection *cur) {
return;
if (!view_coord_get(win->view, pos_match, &line_match, NULL, &col_match))
return;
- win->ui->style_set(win->ui, &line_match->cells[col_match], UI_STYLE_SELECTION);
+ ui_window_style_set(win->ui, &line_match->cells[col_match], UI_STYLE_SELECTION);
}
static void window_draw_cursor(Win *win, Selection *cur) {
@@ -318,7 +314,7 @@ static void window_draw_cursor(Win *win, Selection *cur) {
if (!line)
return;
Selection *primary = view_selections_primary_get(win->view);
- win->ui->style_set(win->ui, &line->cells[cur->col], primary == cur ? UI_STYLE_CURSOR_PRIMARY : UI_STYLE_CURSOR);
+ ui_window_style_set(win->ui, &line->cells[cur->col], primary == cur ? UI_STYLE_CURSOR_PRIMARY : UI_STYLE_CURSOR);
window_draw_cursor_matching(win, cur);
return;
}
@@ -351,7 +347,7 @@ static void window_draw_eof(Win *win) {
return;
for (Line *l = view->lastline->next; l; l = l->next) {
strncpy(l->cells[0].data, view_symbol_eof_get(view), sizeof(l->cells[0].data)-1);
- win->ui->style_set(win->ui, &l->cells[0], UI_STYLE_EOF);
+ ui_window_style_set(win->ui, &l->cells[0], UI_STYLE_EOF);
}
}
@@ -394,7 +390,7 @@ Win *window_new_file(Vis *vis, File *file, enum UiOption options) {
marklist_init(&win->jumplist, 32);
mark_init(&win->saved_selections);
file->refcount++;
- view_options_set(win->view, view_options_get(win->view));
+ view_options_set(win->view, UI_OPTIONS_GET(win->view->ui));
if (vis->windows)
vis->windows->prev = win;
@@ -449,7 +445,7 @@ bool vis_window_split(Win *original) {
map_copy(win->modes[i].bindings, original->modes[i].bindings);
}
win->file = original->file;
- view_options_set(win->view, view_options_get(original->view));
+ view_options_set(win->view, UI_OPTIONS_GET(original->view->ui));
view_cursors_to(win->view->selection, view_cursor_get(original->view));
vis_doupdates(win->vis, true);
return true;
diff --git a/vis.h b/vis.h
index a915c0e..057e66b 100644
--- a/vis.h
+++ b/vis.h
@@ -196,8 +196,6 @@ bool vis_window_closable(Win*);
void vis_window_close(Win*);
/** Split the window, shares the underlying file object. */
bool vis_window_split(Win*);
-/** Change status message of this window. */
-void vis_window_status(Win*, const char *status);
void vis_window_draw(Win*);
void vis_window_invalidate(Win*);
/** Focus next window. */