Browse Source

* 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.

Pavel Roskin 22 years ago
parent
commit
6d1beed458
3 changed files with 27 additions and 20 deletions
  1. 6 0
      edit/ChangeLog
  2. 5 9
      edit/edit.c
  3. 16 11
      edit/editdraw.c

+ 6 - 0
edit/ChangeLog

@@ -1,5 +1,11 @@
 2002-09-23  Pavel Roskin  <proski@gnu.org>
 
+	* 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.

+ 5 - 9
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;
 }

+ 16 - 11
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;