-/* $MirOS: contrib/code/jupp/scrn.c,v 1.19 2017/01/10 23:59:33 tg Exp $ */
+/* $MirOS: contrib/code/jupp/scrn.c,v 1.25 2017/07/09 01:19:54 tg Exp $ */
/*
* Device independant TTY interface for JOE
* Copyright
if(locale_map->type) {
/* UTF-8 char to UTF-8 terminal */
int wid;
- int uni_ctrl = 0;
- unsigned char buf[16];
- /* Deal with control characters */
- if (c<32) {
- c = c + '@';
- a ^= UNDERLINE;
- } else if (c==127) {
- c = '?';
- a ^= UNDERLINE;
- } else if (unictrl(c)) {
+ switch ((wid = unictrl(c))) {
+ case 0:
+ /* not a control character */
+ wid = joe_wcwidth(1, c);
+ break;
+ case 1:
+ c ^= 0x40;
+ default:
a ^= UNDERLINE;
- uni_ctrl = 1;
+ break;
}
if(*scrn==c && *attrf==a)
return;
- wid = joe_wcwidth(1,c);
-
*scrn = c;
*attrf = a;
if(t->ins)
cpos(t, xx, yy);
if(t->attrib != a)
set_attr(t, a);
- if (uni_ctrl) {
- joe_snprintf_1((char *)buf,16,"<%X>",c);
- ttputs(buf);
+ if (*unictrlbuf) {
+ ttputs(unictrlbuf);
} else {
+ unsigned char buf[7];
+
utf8_encode(buf,c);
ttputs(buf);
+ if (wid == 0 && xx > 0)
+ attrf[-1] |= HAS_COMBINING;
}
t->x+=wid;
while (wid>1) {
t->x++;
} else {
/* Non UTF-8 char to UTF-8 terminal */
- unsigned char buf[16];
+ unsigned char buf[7];
int wid;
/* Deal with control characters */
if(*cs<32 || *cs>=127)
break;
+ /* has a combining character attached? */
+ if (*as & HAS_COMBINING)
+ break;
+
if (*as != t->attrib)
set_attr(t, *as);
if (q > 0) {
int z, fu;
- for (z = x; z != t->co - 1 && ofst[z] == q; ++z) ;
+ for (z = x; z != t->co - 1 && ofst[z] == q; ++z)
+ ;
while (s[x] == cs[x] && x < placex)
++x;
dodelchr(t, x, y, q);
} else {
int z, fu;
- for (z = x; z != t->co - 1 && ofst[z] == q; ++z) ;
+ for (z = x; z != t->co - 1 && ofst[z] == q; ++z)
+ ;
while (s[x + q] == cs[x + q] && x - q < placex)
++x;
doinschr(t, x + q, y, s + x + q, a + x + q, -q);
doupscrl(t, y, z + q, q);
y = z - 1;
} else {
- for (r = y; r != t->li && (t->sary[r] < 0 || t->sary[r] == t->li); ++r) ;
+ for (r = y; r != t->li && (t->sary[r] < 0 || t->sary[r] == t->li); ++r)
+ ;
p = r - 1;
do {
q = t->sary[p];
if (q && q != t->li) {
- for (z = p; t->sary[z] = 0, (z && t->sary[z - 1] == q); --z) ;
+ for (z = p; t->sary[z] = 0, (z && t->sary[z - 1] == q); --z)
+ ;
dodnscrl(t, z + q, p + 1, -q);
p = z + 1;
}
for (x = top; x != top + amnt; ++x) {
t->updtab[x] = 1;
t->syntab[x] = -1;
- }
+ }
}
if (amnt > bot - top)
amnt = bot - top;
if (amnt == bot - top) {
msetI(t->updtab + top, 1, amnt);
msetI(t->syntab + top, -1, amnt);
- }
+ }
}
void nscrlup(SCRN *t, int top, int bot, int amnt)
for (x = bot - amnt; x != bot; ++x) {
t->updtab[x] = 1;
t->syntab[x] = -1;
- }
+ }
}
if (amnt > bot - top)
amnt = bot - top;
if (amnt == bot - top) {
msetI(t->updtab + bot - amnt, 1, amnt);
msetI(t->syntab + bot - amnt, -1, amnt);
- }
+ }
}
extern volatile int dostaupd;
wid = joe_wcwidth(1,c);
} else {
/* Byte mode: character is one column wide */
- wid = 1 ;
+ wid = 1;
}
- if (wid>=0) {
+ if (wid >= 0) {
if (col >= ofst) {
if (x + wid > last_col) {
/* Character crosses end of field, so fill balance of field with '>' characters instead */
++attr;
++x;
}
- } else if(wid) {
+ } else /* if (wid >(=) 0) */ {
/* Emit character */
outatr(locale_map, t, scrn, attr, x, y, c, my_atr);
x += wid;
}
} else
col += wid;
- }
+ }
}
/* Fill balance of field with spaces */
while (x < last_col) {
/* UTF-8 mode: decode character and determine its width */
c = utf8_decode(&sm,c);
if (c >= 0) {
- wid = joe_wcwidth(1,c);
+ wid = joe_wcwidth(1, c);
}
} else {
/* Byte mode: character is one column wide */
- wid = 1 ;
+ wid = 1;
}
- if (wid>=0) {
+ if (wid >= 0) {
if (col >= ofst) {
outatr(locale_map, t, scrn, attr, x, y, c, atr);
scrn += wid;