aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-10-01 10:46:09 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-01 10:46:09 -0700
commitdbc51bf97222bee5845d3d7a5bd1d91be05e4416 (patch)
treeea31a8c199a4b76bb93fe71457ee69edd7ba98a6
parentef92bc8cd9ad58da15a1f6f311c234e991551710 (diff)
downloaduemacs-dbc51bf97222bee5845d3d7a5bd1d91be05e4416.tar.gz
Handle 8-bit characters better in display
This code still assumes a latin1 kind of "one byte, one character" setup. UTF-8 input/output (even if the data is encoded in latin-1) is a separate issue.
-rw-r--r--display.c49
-rw-r--r--efunc.h2
2 files changed, 36 insertions, 15 deletions
diff --git a/display.c b/display.c
index ef8bdff..e15384e 100644
--- a/display.c
+++ b/display.c
@@ -155,7 +155,7 @@ void vtmove(int row, int col)
* This routine only puts printing characters into the virtual
* terminal buffers. Only column overflow is checked.
*/
-void vtputc(int c)
+void vtputc(unsigned char c)
{
register VIDEO *vp; /* ptr to line being updated */
@@ -164,20 +164,39 @@ void vtputc(int c)
if (vtcol >= term.t_ncol) {
++vtcol;
vp->v_text[term.t_ncol - 1] = '$';
- } else if (c < 0x20 || c == 0x7F) {
- if (c == '\t') {
- do {
- vtputc(' ');
- } while (((vtcol + taboff) & tabmask) != 0);
- } else {
- vtputc('^');
- vtputc(c ^ 0x40);
- }
- } else {
- if (vtcol >= 0)
- vp->v_text[vtcol] = c;
- ++vtcol;
+ return;
+ }
+
+ if (c == '\t') {
+ do {
+ vtputc(' ');
+ } while (((vtcol + taboff) & tabmask) != 0);
+ return;
+ }
+
+ if (c < 0x20) {
+ vtputc('^');
+ vtputc(c ^ 0x40);
+ return;
+ }
+
+ if (c == 0x7f) {
+ vtputc('^');
+ vtputc('?');
+ return;
+ }
+
+ if (c >= 0x80 && c < 0xA0) {
+ static const char hex[] = "0123456789abcdef";
+ vtputc('\\');
+ vtputc(hex[c >> 4]);
+ vtputc(hex[c & 15]);
+ return;
}
+
+ if (vtcol >= 0)
+ vp->v_text[vtcol] = c;
+ ++vtcol;
}
/*
@@ -505,6 +524,8 @@ void updpos(void)
curcol |= tabmask;
else if (c < 0x20 || c == 0x7f)
++curcol;
+ else if (c >= 0x80 && c <= 0xa0)
+ curcol+=2;
++curcol;
}
diff --git a/efunc.h b/efunc.h
index 777c411..d06bae6 100644
--- a/efunc.h
+++ b/efunc.h
@@ -141,7 +141,7 @@ extern void vtinit(void);
extern void vtfree(void);
extern void vttidy(void);
extern void vtmove(int row, int col);
-extern void vtputc(int c);
+extern void vtputc(unsigned char c);
extern void vteeol(void);
extern int upscreen(int f, int n);
extern int update(int force);