diff --git a/view.c b/view.c index 058d0add9..b1214ffce 100644 --- a/view.c +++ b/view.c @@ -29,20 +29,20 @@ * the necessary offset for the last character. */ -static const SyntaxSymbol symbols_none[] = { - [SYNTAX_SYMBOL_SPACE] = { " " }, - [SYNTAX_SYMBOL_TAB] = { " " }, - [SYNTAX_SYMBOL_TAB_FILL] = { " " }, - [SYNTAX_SYMBOL_EOL] = { " " }, - [SYNTAX_SYMBOL_EOF] = { " " }, +static const char *symbols_none[] = { + [SYNTAX_SYMBOL_SPACE] = " ", + [SYNTAX_SYMBOL_TAB] = " ", + [SYNTAX_SYMBOL_TAB_FILL] = " ", + [SYNTAX_SYMBOL_EOL] = " ", + [SYNTAX_SYMBOL_EOF] = " ", }; -static const SyntaxSymbol symbols_default[] = { - [SYNTAX_SYMBOL_SPACE] = { "·" /* Middle Dot U+00B7 */ }, - [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 const char *symbols_default[] = { + [SYNTAX_SYMBOL_SPACE] = "·", /* Middle Dot U+00B7 */ + [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_blank = { .width = 0, .len = 0, .data = " ", }; @@ -268,7 +268,7 @@ static bool view_expand_tab(View *view, Cell *cell) { int displayed_width = view->tabwidth - (view->col % view->tabwidth); for (int w = 0; w < displayed_width; ++w) { int t = (w == 0) ? SYNTAX_SYMBOL_TAB : SYNTAX_SYMBOL_TAB_FILL; - const char *symbol = view->symbols[t]->symbol; + const char *symbol = view->symbols[t]; strncpy(cell->data, symbol, sizeof(cell->data) - 1); cell->len = (w == 0) ? 1 : 0; @@ -282,7 +282,7 @@ static bool view_expand_tab(View *view, Cell *cell) { static bool view_expand_newline(View *view, Cell *cell) { size_t lineno = view->line->lineno; - const char *symbol = view->symbols[SYNTAX_SYMBOL_EOL]->symbol; + const char *symbol = view->symbols[SYNTAX_SYMBOL_EOL]; strncpy(cell->data, symbol, sizeof(cell->data) - 1); cell->width = 1; @@ -316,7 +316,7 @@ static bool view_addch(View *view, Cell *cell) { case '\n': return view_expand_newline(view, cell); case ' ': { - const char *symbol = view->symbols[SYNTAX_SYMBOL_SPACE]->symbol; + const char *symbol = view->symbols[SYNTAX_SYMBOL_SPACE]; strncpy(cell->data, symbol, sizeof(cell->data) - 1); return view_add_cell(view, cell); }} @@ -869,8 +869,8 @@ void view_options_set(View *view, enum UiOption options) { }; for (int i = 0; i < LENGTH(mapping); i++) { - view->symbols[i] = (options & mapping[i]) ? &symbols_default[i] : - &symbols_none[i]; + view->symbols[i] = (options & mapping[i]) ? symbols_default[i] : + symbols_none[i]; } if (options & UI_OPTION_LINE_NUMBERS_ABSOLUTE) @@ -1332,10 +1332,6 @@ void view_selections_normalize(View *view) { view_selections_set(prev, &range_prev); } -char *view_symbol_eof_get(View *view) { - return view->symbols[SYNTAX_SYMBOL_EOF]->symbol; -} - void view_style(View *view, enum UiStyle style, size_t start, size_t end) { if (end < view->start || start > view->end) return; diff --git a/view.h b/view.h index 63cef3ec3..ba7f0da5a 100644 --- a/view.h +++ b/view.h @@ -8,10 +8,6 @@ #include "text.h" #include "array.h" -typedef struct { - char *symbol; -} SyntaxSymbol; - enum { SYNTAX_SYMBOL_SPACE, SYNTAX_SYMBOL_TAB, @@ -69,7 +65,7 @@ typedef struct View { int selection_count; /* how many cursors do currently exist */ Line *line; /* used while drawing view content, line where next char will be drawn */ int col; /* used while drawing view content, column where next char will be drawn */ - const SyntaxSymbol *symbols[SYNTAX_SYMBOL_LAST]; /* symbols to use for white spaces etc */ + const char *symbols[SYNTAX_SYMBOL_LAST]; /* symbols to use for white spaces etc */ int tabwidth; /* how many spaces should be used to display a tab character */ Selection *selections; /* all cursors currently active */ int selection_generation; /* used to filter out newly created cursors during iteration */ @@ -351,8 +347,6 @@ void view_tabwidth_set(View*, int tabwidth); /** Apply a style to a text range. */ void view_style(View*, enum UiStyle, size_t start, size_t end); -char *view_symbol_eof_get(View*); - /** @} */ #endif diff --git a/vis.c b/vis.c index 4a025f9a2..cbdb2083c 100644 --- a/vis.c +++ b/vis.c @@ -341,7 +341,7 @@ static void window_draw_eof(Win *win) { if (view->width == 0) 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); + strncpy(l->cells[0].data, view->symbols[SYNTAX_SYMBOL_EOF], sizeof(l->cells[0].data)-1); ui_window_style_set(win->ui, &l->cells[0], UI_STYLE_EOF); } }