1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 15:26:23 -05:00

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.
This commit is contained in:
Linus Torvalds 2005-10-01 10:46:09 -07:00
parent ef92bc8cd9
commit dbc51bf972
2 changed files with 36 additions and 15 deletions

View File

@ -155,7 +155,7 @@ void vtmove(int row, int col)
* This routine only puts printing characters into the virtual * This routine only puts printing characters into the virtual
* terminal buffers. Only column overflow is checked. * terminal buffers. Only column overflow is checked.
*/ */
void vtputc(int c) void vtputc(unsigned char c)
{ {
register VIDEO *vp; /* ptr to line being updated */ register VIDEO *vp; /* ptr to line being updated */
@ -164,20 +164,39 @@ void vtputc(int c)
if (vtcol >= term.t_ncol) { if (vtcol >= term.t_ncol) {
++vtcol; ++vtcol;
vp->v_text[term.t_ncol - 1] = '$'; vp->v_text[term.t_ncol - 1] = '$';
} else if (c < 0x20 || c == 0x7F) { return;
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;
} }
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; curcol |= tabmask;
else if (c < 0x20 || c == 0x7f) else if (c < 0x20 || c == 0x7f)
++curcol; ++curcol;
else if (c >= 0x80 && c <= 0xa0)
curcol+=2;
++curcol; ++curcol;
} }

View File

@ -141,7 +141,7 @@ extern void vtinit(void);
extern void vtfree(void); extern void vtfree(void);
extern void vttidy(void); extern void vttidy(void);
extern void vtmove(int row, int col); extern void vtmove(int row, int col);
extern void vtputc(int c); extern void vtputc(unsigned char c);
extern void vteeol(void); extern void vteeol(void);
extern int upscreen(int f, int n); extern int upscreen(int f, int n);
extern int update(int force); extern int update(int force);