aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2024-05-24 14:53:01 -0600
committerRandy Palamar <randy@rnpnr.xyz>2024-05-24 14:53:01 -0600
commit66c7dfeec6367eac5f7b0f9eff451a0577d8eae7 (patch)
tree9b68a5eb5a08dff90fce68e41d06fd5175569e56
parent4d38c3a922818159b67bb7bede4b00fb592ee484 (diff)
downloadvis-66c7dfeec6367eac5f7b0f9eff451a0577d8eae7.tar.gz
vis-66c7dfeec6367eac5f7b0f9eff451a0577d8eae7.tar.xz
remove SyntaxSymbol redirection type
There is no reason why this isn't just a char *.
-rw-r--r--view.c38
-rw-r--r--view.h8
-rw-r--r--vis.c2
3 files changed, 19 insertions, 29 deletions
diff --git a/view.c b/view.c
index 058d0ad..b1214ff 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 63cef3e..ba7f0da 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 4a025f9..cbdb208 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);
}
}