aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/term/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/term/term.c')
-rw-r--r--sys/cmd/term/term.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/sys/cmd/term/term.c b/sys/cmd/term/term.c
index f7687b9..77ed5c2 100644
--- a/sys/cmd/term/term.c
+++ b/sys/cmd/term/term.c
@@ -627,7 +627,7 @@ ttyread(void)
written = twrite(buf, buflen, 0);
buflen -= written;
/* keep any incomplete UTF-8 byte sequence for the next call */
- if (buflen > 0)
+ if(buflen > 0)
memmove(buf, buf + written, buflen);
return ret;
}
@@ -989,7 +989,7 @@ tsetchar(rune u, Letter *attr, int x, int y)
};
/*
- * The table is proudly stolen from rxvt.
+ * table is proudly stolen from rxvt.
*/
if (term.trantbl[term.charset] == CSgfx0 &&
BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41])
@@ -2082,6 +2082,7 @@ tputc(rune u)
char c[UTFmax];
int control;
int width, len;
+ rune nu;
Letter *gp;
control = ISCONTROL(u);
@@ -2090,10 +2091,30 @@ tputc(rune u)
width = len = 1;
} else {
len = utf8·runetobyte(c, &u);
- if (!control && (width = wcwidth(u)) == -1)
+ if(!control && (width = wcwidth(u)) == -1)
width = 1;
}
+ /* combining characters */
+ if(!width) {
+ if(term.c.x > 0)
+ gp = &term.line[term.c.y][term.c.x-1];
+ else if(term.c.y > 0)
+ gp = &term.line[term.c.y-1][term.col-1];
+ else
+ return;
+
+ printf("%d + %d\n", gp->u, u);
+
+ if(!hb_unicode_compose(hb_unicode_funcs_get_default(),gp->u, u, &nu)) {
+ assert(false);
+ return;
+ }
+
+ gp->u = nu;
+ return;
+ }
+
if (IS_SET(Tprint))
tprinter(c, len);
@@ -2103,7 +2124,7 @@ tputc(rune u)
* receives a ESC, a SUB, a ST or any other C1 control
* character.
*/
- if (term.esc & Xstr) {
+ if(term.esc & Xstr) {
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
ISCONTROLC1(u)) {
term.esc &= ~(Xstart|Xstr|Xdcs);
@@ -2154,7 +2175,7 @@ check_control_code:
* because they can be embedded inside a control sequence, and
* they must not cause conflicts with sequences.
*/
- if (control) {
+ if(control) {
tcontrolcode(u);
/*
* control codes are not shown ever
@@ -2162,7 +2183,7 @@ check_control_code:
if (!term.esc)
term.lastc = 0;
return;
- } else if (term.esc & Xstart) {
+ } else if(term.esc & Xstart) {
if (term.esc & Xcsi) {
csiescseq.buf[csiescseq.len++] = u;
if (BETWEEN(u, 0x40, 0x7E)
@@ -2191,6 +2212,7 @@ check_control_code:
*/
return;
}
+
if (selected(term.c.x, term.c.y))
selclear();
@@ -2212,7 +2234,7 @@ check_control_code:
tsetchar(u, &term.c.attr, term.c.x, term.c.y);
term.lastc = u;
- if (width == 2) {
+ if(width == 2) {
gp->mode |= Gwrap;
if (term.c.x+1 < term.col) {
gp[1].u = '\0';
@@ -2234,16 +2256,16 @@ twrite(char *buf, int buflen, int show_ctrl)
int n;
for (n = 0; n < buflen; n += charsize) {
- if (IS_SET(Tutf8) && !IS_SET(Tsixel)) {
+ if(IS_SET(Tutf8) && !IS_SET(Tsixel)) {
/* process a complete utf8 char */
charsize = utf8·bytetorune(&u, buf + n);
- if (charsize == 0)
+ if(charsize == 0)
break;
} else {
u = buf[n] & 0xFF;
charsize = 1;
}
- if (show_ctrl && ISCONTROL(u)) {
+ if(show_ctrl && ISCONTROL(u)) {
if (u & 0x80) {
u &= 0x7f;
tputc('^');
@@ -2377,7 +2399,10 @@ draw(void)
cx--;
drawregion(0, 0, term.col, term.row);
- xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
+ xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
+ term.ocx, term.ocy, term.line[term.ocy][term.ocx],
+ term.line[term.ocy], term.col
+ );
term.ocx = cx;
term.ocy = term.c.y;
xfinishdraw();