Skip to content

Commit

Permalink
Display ASCII-127 (DEL) character as ^?
Browse files Browse the repository at this point in the history
  • Loading branch information
rgburke committed Feb 16, 2016
1 parent 44c8e46 commit 498bc78
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 498bc78

Please sign in to comment.