From 498bc78dc6db87fb44c14d62ca30077c2b23e89f Mon Sep 17 00:00:00 2001 From: Richard Burke Date: Tue, 16 Feb 2016 21:52:05 +0000 Subject: Display ASCII-127 (DEL) character as ^? --- view.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index 3afa3e8..6cac448 100644 --- a/view.c +++ b/view.c @@ -336,8 +336,9 @@ static bool view_addch(View *view, Cell *cell) { int width; size_t lineno = view->line->lineno; + unsigned char ch = (unsigned char)cell->data[0]; - switch (cell->data[0]) { + switch (ch) { case '\t': cell->width = 1; width = view->tabwidth - (view->col % view->tabwidth); @@ -386,17 +387,17 @@ static bool view_addch(View *view, Cell *cell) { view->col = 0; return true; default: - if ((unsigned char)cell->data[0] < 128 && !isprint((unsigned char)cell->data[0])) { + if (ch < 128 && !isprint(ch)) { /* non-printable ascii char, represent it as ^(char + 64) */ *cell = (Cell) { - .data = { '^', cell->data[0] + 64, '\0' }, + .data = { '^', ch == 127 ? '?' : ch + 64, '\0' }, .len = 1, .width = 2, .attr = cell->attr, }; } - if (cell->data[0] == ' ') { + if (ch == ' ') { strncpy(cell->data, view->symbols[SYNTAX_SYMBOL_SPACE]->symbol, sizeof(cell->data)-1); cell->attr = view->symbols[SYNTAX_SYMBOL_SPACE]->style; -- cgit v1.2.3