aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Emanuel Weidmann <pew@worldwidemann.com>2017-06-04 17:36:55 +0530
committerPhilipp Emanuel Weidmann <pew@worldwidemann.com>2017-06-04 17:36:55 +0530
commitbfcf2210da1f83d4138425febf96d3afb60fdfac (patch)
treef1e6366432517950b816410af7e36be4f7d7d11a
parent7f487178cff9f43896b3462b2ebbd94eca5078d9 (diff)
downloadvis-bfcf2210da1f83d4138425febf96d3afb60fdfac.tar.gz
vis-bfcf2210da1f83d4138425febf96d3afb60fdfac.tar.xz
Add option to hide EOF marker
-rw-r--r--man/vis.13
-rw-r--r--sam.c6
-rw-r--r--view.c12
-rw-r--r--view.h2
-rw-r--r--vis-cmds.c2
-rw-r--r--vis-prompt.c2
-rw-r--r--vis.c4
7 files changed, 26 insertions, 5 deletions
diff --git a/man/vis.1 b/man/vis.1
index ce32178..c78bd66 100644
--- a/man/vis.1
+++ b/man/vis.1
@@ -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
diff --git a/sam.c b/sam.c
index 19894bf..e6eb35a 100644
--- a/sam.c
+++ b/sam.c
@@ -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,
diff --git a/view.c b/view.c
index 76410aa..ee46f3a 100644
--- a/view.c
+++ b/view.c
@@ -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);
}
diff --git a/view.h b/view.h
index a6d455e..a7c8195 100644
--- a/view.h
+++ b/view.h
@@ -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);
diff --git a/vis-cmds.c b/vis-cmds.c
index ec70231..a49195e 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -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;
}
diff --git a/vis.c b/vis.c
index dc2c984..f3cd6d6 100644
--- a/vis.c
+++ b/vis.c
@@ -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;
}
}