mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Fix vtputc() and simplify show_line by using it again
This re-introduces vtputc() as the way to show characters, which reinstates the control character handing, and simplifies show_line() in the process. vtputc now takes an "int" that is either a unicode character or a signed char (so negative values in the range [-1, -128] are considered to be the same as [128, 255]). This allows us to use it regardless of what the source of data is. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0a8b429059
commit
1edeced67c
34
display.c
34
display.c
@ -164,10 +164,17 @@ void vtmove(int row, int col)
|
||||
* This routine only puts printing characters into the virtual
|
||||
* terminal buffers. Only column overflow is checked.
|
||||
*/
|
||||
static void vtputc(unsigned char c)
|
||||
static void vtputc(int c)
|
||||
{
|
||||
struct video *vp; /* ptr to line being updated */
|
||||
|
||||
/* In case somebody passes us a signed char.. */
|
||||
if (c < 0) {
|
||||
c += 256;
|
||||
if (c < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
vp = vscreen[vtrow];
|
||||
|
||||
if (vtcol >= term.t_ncol) {
|
||||
@ -436,32 +443,11 @@ static int reframe(struct window *wp)
|
||||
static void show_line(struct line *lp)
|
||||
{
|
||||
unsigned i = 0, len = llength(lp);
|
||||
struct video *vp;
|
||||
|
||||
vp = vscreen[vtrow];
|
||||
|
||||
while (i < len) {
|
||||
unicode_t c;
|
||||
int n;
|
||||
|
||||
if (vtcol >= term.t_ncol) {
|
||||
vp->v_text[term.t_ncol - 1] = '$';
|
||||
return;
|
||||
}
|
||||
n = utf8_to_unicode(lp->l_text, i, len, &c);
|
||||
/*
|
||||
* Change tabs into spaces, and don't increment
|
||||
* the text source until we hit tabmask
|
||||
*/
|
||||
++vtcol;
|
||||
if (c == '\t') {
|
||||
c = ' ';
|
||||
if (vtcol & tabmask)
|
||||
n = 0;
|
||||
}
|
||||
if (vtcol > 0)
|
||||
vp->v_text[vtcol-1] = c;
|
||||
i += n;
|
||||
i += utf8_to_unicode(lp->l_text, i, len, &c);
|
||||
vtputc(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user