diff --git a/edit/ChangeLog b/edit/ChangeLog index 6b0af1b04..6290afce8 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,5 +1,11 @@ 2002-09-23 Pavel Roskin + * edit.c (edit_move_forward3): Use caret notation for code 127 + and below code 32. + * editdraw.c (edit_draw_this_line): Likewise. Print '.' for + other non-printable characters and remove this code from ... + (print_to_widget): ... here. + * edit.c (edit_move_forward3): Show '\r' as ^M. * editdraw.c (edit_draw_this_line): Likewise. Use MOD_ABNORMAL attribute. diff --git a/edit/edit.c b/edit/edit.c index ad3227062..7846f58e4 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -1214,21 +1214,17 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto) return p - 1; } c = edit_get_byte (edit, p); - /* '\r' is shown as ^M, so we must advance 2 characters */ - if (c == '\r') - col += 2; - else if (c == '\t') col += TAB_SIZE - col % TAB_SIZE; - else - col++; - /*if(edit->nroff ... */ - if (c == '\n') { + else if (c == '\n') { if (upto) return col; else return p; - } + } else if (c < 32 || c == 127) + col += 2; /* Caret notation for control characters */ + else + col++; } return col; } diff --git a/edit/editdraw.c b/edit/editdraw.c index 315435ebc..7abce0c07 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -211,9 +211,8 @@ static void print_to_widget (WEdit * edit, long row, int start_col, float start_ color = *p >> 16; if (style & MOD_ABNORMAL) { - /* Non-printable - show as a dot on black background */ + /* Non-printable - use black background */ color = 0; - textchar = '.'; } if (!(style & (0xFF - MOD_ABNORMAL - MOD_CURSOR))) lowlevel_set_color (color); @@ -299,23 +298,29 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col, while (--i) *(p++) = c; break; - case '\r': - /* Display '\r' as ^M, just like vi does */ - *(p++) = '^'; - *p |= (256 * MOD_ABNORMAL); - *(p++) = 'M'; - *p |= (256 * MOD_ABNORMAL); - col += 2; - break; default: #ifdef HAVE_CHARSET if (c >= 0 && c <= 255) c = conv_displ[ c ]; #endif + /* Caret notation for control characters */ + if (c < 32) { + *(p++) = '^' | (256 * MOD_ABNORMAL); + *(p++) = (c + 0x40) | (256 * MOD_ABNORMAL); + col += 2; + break; + } + if (c == 127) { + *(p++) = '^' | (256 * MOD_ABNORMAL); + *(p++) = '?' | (256 * MOD_ABNORMAL); + col += 2; + break; + } + if (is_printable (c)) { *(p++) |= c; } else { - *(p++) |= (256 * MOD_ABNORMAL); + *(p++) = '.' | (256 * MOD_ABNORMAL); } col++; break;