diff options
| author | Philipp Emanuel Weidmann <pew@worldwidemann.com> | 2017-06-04 17:36:55 +0530 |
|---|---|---|
| committer | Philipp Emanuel Weidmann <pew@worldwidemann.com> | 2017-06-04 17:36:55 +0530 |
| commit | bfcf2210da1f83d4138425febf96d3afb60fdfac (patch) | |
| tree | f1e6366432517950b816410af7e36be4f7d7d11a | |
| parent | 7f487178cff9f43896b3462b2ebbd94eca5078d9 (diff) | |
| download | vis-bfcf2210da1f83d4138425febf96d3afb60fdfac.tar.gz vis-bfcf2210da1f83d4138425febf96d3afb60fdfac.tar.xz | |
Add option to hide EOF marker
| -rw-r--r-- | man/vis.1 | 3 | ||||
| -rw-r--r-- | sam.c | 6 | ||||
| -rw-r--r-- | view.c | 12 | ||||
| -rw-r--r-- | view.h | 2 | ||||
| -rw-r--r-- | vis-cmds.c | 2 | ||||
| -rw-r--r-- | vis-prompt.c | 2 | ||||
| -rw-r--r-- | vis.c | 4 |
7 files changed, 26 insertions, 5 deletions
@@ -1315,6 +1315,9 @@ Whether to display replacement symbol instead of newlines. .It Cm show-spaces Op Cm off Whether to display replacement symbol instead of blank cells. . +.It Cm show-eof Op Cm on +Whether to display replacement symbol for lines after the end of the file. +. .It Cm savemethod Op Ar auto How the current file should be saved, .Ar atomic @@ -289,6 +289,7 @@ enum { OPTION_SHOW_SPACES, OPTION_SHOW_TABS, OPTION_SHOW_NEWLINES, + OPTION_SHOW_EOF, OPTION_NUMBER, OPTION_NUMBER_RELATIVE, OPTION_CURSOR_LINE, @@ -338,6 +339,11 @@ static const OptionDef options[] = { VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, VIS_HELP("Display replacement symbol for newlines") }, + [OPTION_SHOW_EOF] = { + { "show-eof" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, + VIS_HELP("Display replacement symbol for lines after the end of the file") + }, [OPTION_NUMBER] = { { "numbers", "nu" }, VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, @@ -19,6 +19,7 @@ enum { SYNTAX_SYMBOL_TAB, SYNTAX_SYMBOL_TAB_FILL, SYNTAX_SYMBOL_EOL, + SYNTAX_SYMBOL_EOF, SYNTAX_SYMBOL_LAST, }; @@ -98,6 +99,7 @@ static const SyntaxSymbol symbols_none[] = { [SYNTAX_SYMBOL_TAB] = { " " }, [SYNTAX_SYMBOL_TAB_FILL] = { " " }, [SYNTAX_SYMBOL_EOL] = { " " }, + [SYNTAX_SYMBOL_EOF] = { " " }, }; static const SyntaxSymbol symbols_default[] = { @@ -105,6 +107,7 @@ static const SyntaxSymbol symbols_default[] = { [SYNTAX_SYMBOL_TAB] = { "›" /* Single Right-Pointing Angle Quotation Mark U+203A */ }, [SYNTAX_SYMBOL_TAB_FILL] = { " " }, [SYNTAX_SYMBOL_EOL] = { "↵" /* Downwards Arrow with Corner Leftwards U+21B5 */ }, + [SYNTAX_SYMBOL_EOF] = { "~" }, }; static Cell cell_unused; @@ -421,7 +424,7 @@ void view_draw(View *view) { /* resync position of cursors within visible area */ for (Cursor *c = view->cursors; c; c = c->next) { size_t pos = view_cursors_pos(c); - if (!view_coord_get(view, pos, &c->line, &c->row, &c->col) && + if (!view_coord_get(view, pos, &c->line, &c->row, &c->col) && c == view->cursor) { c->line = view->topline; c->row = 0; @@ -514,7 +517,7 @@ View *view_new(Text *text) { }; view->text = text; view->tabwidth = 8; - view_options_set(view, 0); + view_options_set(view, UI_OPTION_SYMBOL_EOF); if (!view_resize(view, 1, 1)) { view_free(view); @@ -830,6 +833,7 @@ void view_options_set(View *view, enum UiOption options) { [SYNTAX_SYMBOL_TAB] = UI_OPTION_SYMBOL_TAB, [SYNTAX_SYMBOL_TAB_FILL] = UI_OPTION_SYMBOL_TAB_FILL, [SYNTAX_SYMBOL_EOL] = UI_OPTION_SYMBOL_EOL, + [SYNTAX_SYMBOL_EOF] = UI_OPTION_SYMBOL_EOF, }; for (int i = 0; i < LENGTH(mapping); i++) { @@ -1347,6 +1351,10 @@ Text *view_text(View *view) { return view->text; } +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); } @@ -195,6 +195,8 @@ Cursor *view_cursors_column(View*, int column); /* get next cursor (i.e. on another line) in zero based column */ Cursor *view_cursors_column_next(Cursor*, int column); +char *view_symbol_eof_get(View*); + bool view_style_define(View*, enum UiStyle, const char *style); void view_style(View*, enum UiStyle, size_t start, size_t end); @@ -269,11 +269,13 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor case OPTION_SHOW_SPACES: case OPTION_SHOW_TABS: case OPTION_SHOW_NEWLINES: + case OPTION_SHOW_EOF: { const int values[] = { [OPTION_SHOW_SPACES] = UI_OPTION_SYMBOL_SPACE, [OPTION_SHOW_TABS] = UI_OPTION_SYMBOL_TAB|UI_OPTION_SYMBOL_TAB_FILL, [OPTION_SHOW_NEWLINES] = UI_OPTION_SYMBOL_EOL, + [OPTION_SHOW_EOF] = UI_OPTION_SYMBOL_EOF, }; int flags = view_options_get(win->view); if (arg.b || (toggle && !(flags & values[opt_index]))) diff --git a/vis-prompt.c b/vis-prompt.c index a08a19f..a243803 100644 --- a/vis-prompt.c +++ b/vis-prompt.c @@ -129,7 +129,7 @@ static const char *prompt_esc(Vis *vis, const char *keys, const Arg *arg) { static const char *prompt_up(Vis *vis, const char *keys, const Arg *arg) { vis_motion(vis, VIS_MOVE_LINE_UP); vis_window_mode_unmap(vis->win, VIS_MODE_INSERT, "<Up>"); - view_options_set(vis->win->view, UI_OPTION_NONE); + view_options_set(vis->win->view, UI_OPTION_SYMBOL_EOF); return keys; } @@ -306,7 +306,7 @@ static void window_draw_cursorline(Win *win) { return; if (view_cursors_multiple(view)) return; - + int width = view_width_get(view); CellStyle style = win->ui->style_get(win->ui, UI_STYLE_CURSOR_LINE); Cursor *cursor = view_cursors_primary_get(view); @@ -420,7 +420,7 @@ static void window_draw_eof(Win *win) { return; CellStyle style = win->ui->style_get(win->ui, UI_STYLE_EOF); for (Line *l = view_lines_last(view)->next; l; l = l->next) { - strcpy(l->cells[0].data, "~"); + strcpy(l->cells[0].data, view_symbol_eof_get(view)); l->cells[0].style = style; } } |
