summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2013-04-09 13:09:44 +0200
committerMichael Schroeder <mls@suse.de>2013-04-09 13:09:44 +0200
commitd94037c08a6dd30845b27cd76d99663e06aaabb2 (patch)
treefceeaf1c64d9b1465095a2338d828392774bad2b
parentbc7e9d9e368ee7713a331c9eb60030bf54bb2287 (diff)
downloadscreen-d94037c08a6dd30845b27cd76d99663e06aaabb2.tar.gz
Support non-BMP utf8 characters
-rw-r--r--src/ansi.c88
-rw-r--r--src/display.c10
-rw-r--r--src/encoding.c132
-rw-r--r--src/image.h12
-rw-r--r--src/layer.c3
-rw-r--r--src/mark.c23
-rw-r--r--src/resize.c20
-rw-r--r--src/window.c4
8 files changed, 249 insertions, 43 deletions
diff --git a/src/ansi.c b/src/ansi.c
index d88e153..471b35f 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -683,6 +683,7 @@ register int len;
mc.image = c;
mc.mbcs = 0;
mc.font = '0';
+ mc.fontx = 0;
mcp = recode_mchar(&mc, 0, UTF8);
debug2("%02x %02x\n", mcp->image, mcp->font);
c = mcp->image | mcp->font << 8;
@@ -708,7 +709,7 @@ register int len;
if (oy < 0)
oy = 0;
copy_mline2mchar(&omc, &curr->w_mlines[oy], ox);
- if (omc.image == 0xff && omc.font == 0xff)
+ if (omc.image == 0xff && omc.font == 0xff && omc.fontx == 0)
{
ox--;
if (ox >= 0)
@@ -839,7 +840,10 @@ register int len;
curr->w_rend.image = c;
#ifdef UTF8
if (curr->w_encoding == UTF8)
- curr->w_rend.font = c >> 8;
+ {
+ curr->w_rend.font = c >> 8;
+ curr->w_rend.fontx = c >> 16;
+ }
#endif
#ifdef DW_CHARS
curr->w_rend.mbcs = curr->w_mbcs;
@@ -2378,10 +2382,18 @@ struct mchar *mc;
ml->font = null;
p->w_FontL = p->w_charsets[p->w_ss ? p->w_ss : p->w_Charset] = 0;
p->w_FontR = p->w_charsets[p->w_ss ? p->w_ss : p->w_CharsetR] = 0;
- mc->font = p->w_rend.font = 0;
+ mc->font = mc->fontx = p->w_rend.font = 0;
WMsg(p, 0, "Warning: no space for font - turned off");
}
}
+ if (mc->fontx && ml->fontx == null)
+ {
+ if ((ml->fontx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
+ {
+ ml->fontx = null;
+ mc->fontx = 0;
+ }
+ }
#endif
#ifdef COLOR
if (mc->color && ml->color == null)
@@ -2519,6 +2531,9 @@ int n, ys, ye, bce;
if (ml->font != null)
free(ml->font);
ml->font = null;
+ if (ml->fontx != null)
+ free(ml->fontx);
+ ml->fontx = null;
#endif
#ifdef COLOR
if (ml->color != null)
@@ -2564,6 +2579,9 @@ int n, ys, ye, bce;
if (ml->font != null)
free(ml->font);
ml->font = null;
+ if (ml->fontx != null)
+ free(ml->fontx);
+ ml->fontx = null;
#endif
#ifdef COLOR
if (ml->color != null)
@@ -2680,7 +2698,10 @@ int x, y;
if (p->w_encoding != UTF8)
ml->font[x + 1] |= 0x80;
else if (p->w_encoding == UTF8 && c->mbcs)
- ml->font[x + 1] = c->mbcs;
+ {
+ ml->font[x + 1] = c->mbcs;
+ ml->fontx[x + 1] = 0;
+ }
# else
ml->font[x + 1] |= 0x80;
# endif
@@ -2711,7 +2732,10 @@ int x, y;
if (p->w_encoding != UTF8)
ml->font[x + 1] |= 0x80;
else if (p->w_encoding == UTF8 && c->mbcs)
- ml->font[x + 1] = c->mbcs;
+ {
+ ml->font[x + 1] = c->mbcs;
+ ml->fontx[x + 1] = 0;
+ }
# else
ml->font[x + 1] |= 0x80;
# endif
@@ -2767,22 +2791,40 @@ int x, y;
MKillDwRight(p, ml, x);
MKillDwLeft(p, ml, x + n - 1);
bcopy(s, (char *)ml->image + x, n);
- b = ml->attr + x;
- for (i = n; i-- > 0;)
- *b++ = r->attr;
+ if (ml->attr != null)
+ {
+ b = ml->attr + x;
+ for (i = n; i-- > 0;)
+ *b++ = r->attr;
+ }
#ifdef FONT
- b = ml->font + x;
- for (i = n; i-- > 0;)
- *b++ = r->font;
+ if (ml->font != null)
+ {
+ b = ml->font + x;
+ for (i = n; i-- > 0;)
+ *b++ = r->font;
+ }
+ if (ml->fontx != null)
+ {
+ b = ml->fontx + x;
+ for (i = n; i-- > 0;)
+ *b++ = r->fontx;
+ }
#endif
#ifdef COLOR
- b = ml->color + x;
- for (i = n; i-- > 0;)
- *b++ = r->color;
+ if (ml->color != null)
+ {
+ b = ml->color + x;
+ for (i = n; i-- > 0;)
+ *b++ = r->color;
+ }
# ifdef COLORS256
- b = ml->colorx + x;
- for (i = n; i-- > 0;)
- *b++ = r->colorx;
+ if (ml->colorx != null)
+ {
+ b = ml->colorx + x;
+ for (i = n; i-- > 0;)
+ *b++ = r->colorx;
+ }
# endif
#endif
}
@@ -2840,6 +2882,9 @@ struct mline *ml;
q = ml->font; o = hml->font; hml->font = q; ml->font = null;
if (o != null)
free(o);
+ q = ml->fontx; o = hml->fontx; hml->fontx = q; ml->fontx = null;
+ if (o != null)
+ free(o);
#endif
#ifdef COLOR
@@ -2881,6 +2926,15 @@ int ys, ye;
break;
# endif
#endif
+#ifdef UTF8
+ if (p->encoding == UTF8)
+ {
+ if (ml->font != null && bcmp((char*)ml->font, null, p->w_width))
+ break;
+ if (ml->fontx != null && bcmp((char*)ml->fontx, null, p->w_width))
+ break;
+ }
+#endif
}
debug1("MFindUsedLine returning %d\n", y);
return y;
diff --git a/src/display.c b/src/display.c
index 94c05f1..61fff7d 100644
--- a/src/display.c
+++ b/src/display.c
@@ -594,7 +594,7 @@ int c;
# ifdef UTF8
if (D_encoding == UTF8)
{
- c = (c & 255) | (unsigned char)D_rend.font << 8;
+ c = (c & 255) | (unsigned char)D_rend.font << 8 | (unsigned char)D_rend.fontx << 16;
# ifdef DW_CHARS
if (D_mbcs)
{
@@ -1882,6 +1882,10 @@ struct mchar *mc;
#ifdef FONT
if (D_rend.font != mc->font)
SetFont(mc->font);
+#ifdef UTF8
+ if (D_encoding == UTF8)
+ D_rend.fontx = mc->fontx;
+#endif
#endif
}
@@ -1934,6 +1938,10 @@ int x;
#ifdef FONT
if (D_rend.font != ml->font[x])
SetFont(ml->font[x]);
+#ifdef UTF8
+ if (D_encoding == UTF8)
+ D_rend.fontx = ml->fontx[x];
+#endif
#endif
}
diff --git a/src/encoding.c b/src/encoding.c
index 6c1567a..5582c7c 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -514,6 +514,8 @@ int from, to;
if (rmc.font == 0) /* latin1 is the same in unicode */
return mc;
c = rmc.image | (rmc.font << 8);
+ if (from == UTF8)
+ c |= rmc.fontx << 16;
#ifdef DW_CHARS
if (rmc.mbcs)
{
@@ -526,6 +528,8 @@ int from, to;
c = recode_char_to_encoding(c, to);
rmc.image = c & 255;
rmc.font = c >> 8 & 255;
+ if (to == UTF8)
+ rmc.fontx = c >> 16 & 255;
return &rmc;
}
@@ -542,7 +546,7 @@ int from, to;
if (from == to || (from != UTF8 && to != UTF8) || w == 0)
return ml;
- if (ml->font == null && encodings[from].deffont == 0)
+ if (ml->font == null && ml->fontx == null && encodings[from].deffont == 0)
return ml;
if (w > maxlen)
{
@@ -556,7 +560,11 @@ int from, to;
rml[i].font = malloc(w);
else
rml[i].font = realloc(rml[i].font, w);
- if (rml[i].image == 0 || rml[i].font == 0)
+ if (rml[i].fontx == 0)
+ rml[i].fontx = malloc(w);
+ else
+ rml[i].fontx = realloc(rml[i].fontx, w);
+ if (rml[i].image == 0 || rml[i].font == 0 || rml[i].fontx == 0)
{
maxlen = 0;
return ml; /* sorry */
@@ -578,6 +586,12 @@ int from, to;
for (i = 0; i < w; i++)
debug1("%c", "0123456789abcdef"[(ml->font[i] ) & 15]);
debug("\n");
+ for (i = 0; i < w; i++)
+ debug1("%c", "0123456789abcdef"[(ml->fontx[i] >> 4) & 15]);
+ debug("\n");
+ for (i = 0; i < w; i++)
+ debug1("%c", "0123456789abcdef"[(ml->fontx[i] ) & 15]);
+ debug("\n");
rl = rml + last;
rl->attr = ml->attr;
@@ -590,6 +604,8 @@ int from, to;
for (i = 0; i < w; i++)
{
c = ml->image[i] | (ml->font[i] << 8);
+ if (from == UTF8)
+ c |= ml->fontx[i] << 16;
if (from != UTF8 && c < 256)
c |= encodings[from].deffont << 8;
#ifdef DW_CHARS
@@ -603,6 +619,8 @@ int from, to;
i++;
c2 = ml->image[i] | (ml->font[i] << 8);
c = recode_char_dw_to_encoding(c, &c2, to);
+ if (to == UTF8)
+ rl->fontx[i - 1] = c >> 16 & 255;
rl->font[i - 1] = c >> 8 & 255;
rl->image[i - 1] = c & 255;
c = c2;
@@ -613,6 +631,8 @@ int from, to;
c = recode_char_to_encoding(c, to);
rl->image[i] = c & 255;
rl->font[i] = c >> 8 & 255;
+ if (to == UTF8)
+ rl->fontx[i] = c >> 16 & 255;
}
last ^= 1;
debug("recode_mline: to\n");
@@ -628,14 +648,20 @@ int from, to;
for (i = 0; i < w; i++)
debug1("%c", "0123456789abcdef"[(rl->font[i] ) & 15]);
debug("\n");
+ for (i = 0; i < w; i++)
+ debug1("%c", "0123456789abcdef"[(rl->fontx[i] >> 4) & 15]);
+ debug("\n");
+ for (i = 0; i < w; i++)
+ debug1("%c", "0123456789abcdef"[(rl->fontx[i] ) & 15]);
+ debug("\n");
return rl;
}
struct combchar {
- unsigned short c1;
- unsigned short c2;
- unsigned short next;
- unsigned short prev;
+ unsigned int c1;
+ unsigned int c2;
+ unsigned int next;
+ unsigned int prev;
};
struct combchar **combchars;
@@ -649,10 +675,20 @@ int c;
AddUtf8(combchars[c - 0xd800]->c1);
c = combchars[c - 0xd800]->c2;
}
+ if (c >= 0x10000)
+ {
+ if (c >= 0x200000)
+ {
+ AddChar((c & 0x3000000) >> 12 ^ 0xf8);
+ c = (c & 0xffffff) ^ ((0xf0 ^ 0x80) << 18);
+ }
+ AddChar((c & 0x1fc0000) >> 18 ^ 0xf0);
+ c = (c & 0x3ffff) ^ ((0xe0 ^ 0x80) << 12);
+ }
if (c >= 0x800)
{
- AddChar((c & 0xf000) >> 12 | 0xe0);
- c = (c & 0x0fff) | 0x1000;
+ AddChar((c & 0x7f000) >> 12 ^ 0xe0);
+ c = (c & 0x0fff) ^ ((0xc0 ^ 0x80) << 6);
}
if (c >= 0x80)
{
@@ -683,10 +719,24 @@ char *p;
int c;
{
int l = 1;
+ if (c >= 0x10000)
+ {
+ if (c >= 0x200000)
+ {
+ if (p)
+ *p++ = (c & 0x3000000) >> 12 ^ 0xf8;
+ l++;
+ c = (c & 0xffffff) ^ ((0xf0 ^ 0x80) << 18);
+ }
+ if (p)
+ *p++ = (c & 0x1fc0000) >> 18 ^ 0xf0;
+ l++;
+ c = (c & 0x3ffff) ^ ((0xe0 ^ 0x80) << 12);
+ }
if (c >= 0x800)
{
if (p)
- *p++ = (c & 0xf000) >> 12 | 0xe0;
+ *p++ = (c & 0x7f000) >> 12 ^ 0xe0;
l++;
c = (c & 0x0fff) | 0x1000;
}
@@ -758,8 +808,13 @@ int c, *utf8charp;
*utf8charp = utf8char = (c & 0x80000000) ? c : 0;
if (utf8char)
return -1;
+#if 0
if (c & 0xffff0000)
c = UCS_REPL; /* sorry, only know 16bit Unicode */
+#else
+ if (c & 0xff800000)
+ c = UCS_REPL; /* sorry, only know 23bit Unicode */
+#endif
if (c >= 0xd800 && (c <= 0xdfff || c == 0xfffe || c == 0xffff))
c = UCS_REPL; /* illegal code */
return c;
@@ -803,11 +858,13 @@ int encoding;
#else
ml = &p->w_mlines[j];
#endif
- if (ml->font == null && encodings[p->w_encoding].deffont == 0)
+ if (ml->font == null && ml->fontx == 0 && encodings[p->w_encoding].deffont == 0)
continue;
for (i = 0; i < p->w_width; i++)
{
c = ml->image[i] | (ml->font[i] << 8);
+ if (p->w_encoding == UTF8)
+ c |= ml->fontx[i] << 16;
if (p->w_encoding != UTF8 && c < 256)
c |= encodings[p->w_encoding].deffont << 8;
if (c < 256)
@@ -829,8 +886,22 @@ int encoding;
{
int c2;
i++;
- c2 = ml->image[i] | (ml->font[i] << 8);
+ c2 = ml->image[i] | (ml->font[i] << 8) | (ml->fontx[i] << 16);
c = recode_char_dw_to_encoding(c, &c2, encoding);
+ if (encoding == UTF8)
+ {
+ if (c > 0x10000 && ml->fontx == null)
+ {
+ if ((ml->fontx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
+ {
+ ml->fontx = null;
+ break;
+ }
+ }
+ ml->fontx[i - 1] = c >> 16 & 255;
+ }
+ else
+ ml->fontx = 0;
ml->font[i - 1] = c >> 8 & 255;
ml->image[i - 1] = c & 255;
c = c2;
@@ -841,6 +912,20 @@ int encoding;
c = recode_char_to_encoding(c, encoding);
ml->image[i] = c & 255;
ml->font[i] = c >> 8 & 255;
+ if (encoding == UTF8)
+ {
+ if (c > 0x10000 && ml->fontx == null)
+ {
+ if ((ml->fontx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
+ {
+ ml->fontx = null;
+ break;
+ }
+ }
+ ml->fontx[i] = c >> 16 & 255;
+ }
+ else
+ ml->fontx = 0;
}
}
p->w_encoding = encoding;
@@ -1039,7 +1124,7 @@ struct mchar *mc;
int root, i, c1;
int isdouble;
- c1 = mc->image | (mc->font << 8);
+ c1 = mc->image | (mc->font << 8) | mc->fontx << 16;
isdouble = c1 >= 0x1100 && utf8_isdouble(c1);
if (!combchars)
{
@@ -1102,6 +1187,7 @@ struct mchar *mc;
combchars[i]->c2 = c;
mc->image = i & 0xff;
mc->font = (i >> 8) + 0xd8;
+ mc->fontx = 0;
debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800);
comb_tofront(root, i);
}
@@ -1220,6 +1306,15 @@ struct win *p;
p->w_c1 = 0;
}
+/* decoded char: 32-bit <fontx><font><c2><c>
+ * fontx: non-bmp utf8
+ * c2: multi-byte character
+ * font is always zero for utf8
+ * returns: -1 need more bytes
+ * -2 decode error
+ */
+
+
int
DecodeChar(c, encoding, statep)
int c;
@@ -1231,7 +1326,12 @@ int *statep;
debug2("Decoding char %02x for encoding %d\n", c, encoding);
#ifdef UTF8
if (encoding == UTF8)
- return FromUtf8(c, statep);
+ {
+ c = FromUtf8(c, statep);
+ if (c >= 0x10000)
+ c = (c & 0x7f0000) << 8 | (c & 0xffff);
+ return c;
+ }
#endif
if (encoding == SJIS)
{
@@ -1345,7 +1445,7 @@ int *fontp;
}
return 3;
}
- f = c >> 16;
+ f = (c >> 16) & 0xff;
#ifdef UTF8
if (encoding == UTF8)
@@ -1368,8 +1468,10 @@ int *fontp;
}
return ToUtf8(bp, c);
}
- if ((c & 0xff00) && f == 0) /* is_utf8? */
+ if (f == 0 && (c & 0x7f00ff00) != 0) /* is_utf8? */
{
+ if (c >= 0x10000)
+ c = (c & 0x7f0000) >> 8 | (c & 0xffff);
# ifdef DW_CHARS
if (utf8_isdouble(c))
{
diff --git a/src/image.h b/src/image.h
index c105949..2e9b1a6 100644
--- a/src/image.h
+++ b/src/image.h
@@ -33,8 +33,10 @@
#ifdef FONT
# define IFFONT(x) x
+# define IFFONTX(x) x
#else
# define IFFONT(x)
+# define IFFONTX(x)
#endif
#ifdef COLOR
@@ -59,6 +61,7 @@ struct mchar {
unsigned char image;
unsigned char attr;
IFFONT( unsigned char font; )
+IFFONTX( unsigned char fontx; )
IFCOLOR( unsigned char color; )
IFCOLORX(unsigned char colorx; )
IFDWCHAR(unsigned char mbcs; )
@@ -68,6 +71,7 @@ struct mline {
unsigned char *image;
unsigned char *attr;
IFFONT( unsigned char *font; )
+IFFONTX( unsigned char *fontx; )
IFCOLOR( unsigned char *color; )
IFCOLORX(unsigned char *colorx; )
};
@@ -78,6 +82,7 @@ IFCOLORX(unsigned char *colorx; )
bcopy((char *)(ml)->image, (char *)mline_old.image, (n)); \
bcopy((char *)(ml)->attr, (char *)mline_old.attr, (n)); \
IFFONT( bcopy((char *)(ml)->font, (char *)mline_old.font, (n)); ) \
+IFFONTX( bcopy((char *)(ml)->fontx, (char *)mline_old.fontx, (n)); ) \
IFCOLOR( bcopy((char *)(ml)->color, (char *)mline_old.color, (n)); ) \
IFCOLORX(bcopy((char *)(ml)->colorx, (char *)mline_old.colorx, (n)); ) \
} while (0)
@@ -86,6 +91,7 @@ IFCOLORX(bcopy((char *)(ml)->colorx, (char *)mline_old.colorx, (n)); ) \
bcopy((char *)(ml)->image + (xf), (char *)(ml)->image + (xt), (n)); \
bcopy((char *)(ml)->attr + (xf), (char *)(ml)->attr + (xt), (n)); \
IFFONT( bcopy((char *)(ml)->font + (xf), (char *)(ml)->font + (xt), (n)); ) \
+IFFONTX( bcopy((char *)(ml)->fontx + (xf), (char *)(ml)->fontx + (xt), (n)); ) \
IFCOLOR( bcopy((char *)(ml)->color + (xf), (char *)(ml)->color + (xt), (n)); ) \
IFCOLORX(bcopy((char *)(ml)->colorx + (xf), (char *)(ml)->colorx + (xt), (n));) \
} while (0)
@@ -94,6 +100,7 @@ IFCOLORX(bcopy((char *)(ml)->colorx + (xf), (char *)(ml)->colorx + (xt), (n));)
bclear((char *)(ml)->image + (x), (n)); \
if ((ml)->attr != null) bzero((char *)(ml)->attr + (x), (n)); \
IFFONT( if ((ml)->font != null) bzero((char *)(ml)->font + (x), (n)); ) \
+IFFONTX( if ((ml)->fontx != null) bzero((char *)(ml)->fontx + (x), (n)); ) \
IFCOLOR( if ((ml)->color!= null) bzero((char *)(ml)->color + (x), (n)); ) \
IFCOLORX(if ((ml)->colorx!= null) bzero((char *)(ml)->colorx + (x), (n)); ) \
} while (0)
@@ -102,6 +109,7 @@ IFCOLORX(if ((ml)->colorx!= null) bzero((char *)(ml)->colorx + (x), (n)); ) \
(ml1)->image[x] == (ml2)->image[x] \
&& (ml1)->attr[x] == (ml2)->attr[x] \
IFFONT( && (ml1)->font[x] == (ml2)->font[x] ) \
+IFFONTX( && (ml1)->fontx[x] == (ml2)->fontx[x] ) \
IFCOLOR( && (ml1)->color[x] == (ml2)->color[x] ) \
IFCOLORX(&& (ml1)->colorx[x] == (ml2)->colorx[x] ) \
)
@@ -110,6 +118,7 @@ IFCOLORX(&& (ml1)->colorx[x] == (ml2)->colorx[x] ) \
(mc1)->image == (mc2)->image \
&& (mc1)->attr == (mc2)->attr \
IFFONT( && (mc1)->font == (mc2)->font ) \
+IFFONTX( && (mc1)->fontx == (mc2)->fontx ) \
IFCOLOR( && (mc1)->color == (mc2)->color ) \
IFCOLORX(&& (mc1)->colorx == (mc2)->colorx ) \
)
@@ -118,6 +127,7 @@ IFCOLORX(&& (mc1)->colorx == (mc2)->colorx ) \
(mc)->image == (ml)->image[x] \
&& (mc)->attr == (ml)->attr[x] \
IFFONT( && (mc)->font == (ml)->font[x] ) \
+IFFONTX( && (mc)->fontx == (ml)->fontx[x] ) \
IFCOLOR( && (mc)->color == (ml)->color[x] ) \
IFCOLORX(&& (mc)->colorx == (ml)->colorx[x] ) \
)
@@ -126,6 +136,7 @@ IFCOLORX(&& (mc)->colorx == (ml)->colorx[x] ) \
(ml)->image[x] = (mc)->image; \
(ml)->attr[x] = (mc)->attr; \
IFFONT( (ml)->font[x] = (mc)->font; ) \
+IFFONTX( (ml)->fontx[x] = (mc)->fontx; ) \
IFCOLOR( (ml)->color[x] = (mc)->color; ) \
IFCOLORX((ml)->colorx[x] = (mc)->colorx; ) \
} while (0)
@@ -134,6 +145,7 @@ IFCOLORX((ml)->colorx[x] = (mc)->colorx; ) \
(mc)->image = (ml)->image[x]; \
(mc)->attr = (ml)->attr[x]; \
IFFONT( (mc)->font = (ml)->font[x]; ) \
+IFFONTX( (mc)->fontx = (ml)->fontx[x]; ) \
IFCOLOR( (mc)->color = (ml)->color[x]; ) \
IFCOLORX((mc)->colorx = (ml)->colorx[x]; ) \
IFDWCHAR((mc)->mbcs = 0; ) \
diff --git a/src/layer.c b/src/layer.c
index 1ae7972..acf91d8 100644
--- a/src/layer.c
+++ b/src/layer.c
@@ -68,6 +68,7 @@ int off;
mml.attr = ml->attr + off;
#ifdef FONT
mml.font = ml->font + off;
+ mml.fontx = ml->fontx + off;
#endif
#ifdef COLOR
mml.color = ml->color + off;
@@ -409,7 +410,7 @@ int x, y;
SetRendition(r);
s2 = s + xs2 - x - vp->v_xoff;
#ifdef UTF8
- if (D_encoding == UTF8 && l->l_encoding != UTF8 && (r->font || l->l_encoding))
+ if (D_encoding == UTF8 && l->l_encoding != UTF8 && (r->font || r->fontx || l->l_encoding))
{
struct mchar mc;
mc = *r;
diff --git a/src/mark.c b/src/mark.c
index 80c605f..0e5b2b6 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -283,8 +283,8 @@ char *pt;
unsigned char *im;
struct mline *ml;
#ifdef FONT
- int cf, font;
- unsigned char *fo;
+ int cf, cfx, font;
+ unsigned char *fo, *fox;
#endif
markdata->second = 0;
@@ -332,6 +332,7 @@ char *pt;
im = ml->image + j;
#ifdef FONT
fo = ml->font + j;
+ fox = ml->fontx + j;
font = ASCII;
#endif
for (; j <= to; j++)
@@ -339,10 +340,11 @@ char *pt;
c = (unsigned char)*im++;
#ifdef FONT
cf = (unsigned char)*fo++;
+ cfx = (unsigned char)*fox++;
# ifdef UTF8
if (fore->w_encoding == UTF8)
{
- c |= cf << 8;
+ c |= cf << 8 | cfx << 16;
if (c == UCS_HIDDEN)
continue;
c = ToUtf8_comb(pt, c);
@@ -1234,7 +1236,10 @@ int tx, ty, line;
mc = mchar_so;
#ifdef FONT
if (pastefont)
- mc.font = ml->font[x];
+ {
+ mc.font = ml->font[x];
+ mc.fontx = ml->fontx[x];
+ }
#endif
mc.image = ml->image[x];
}
@@ -1354,7 +1359,10 @@ int isblank;
break;
#ifdef FONT
if (pastefont)
- mchar_marked.font = ml->font[x];
+ {
+ mchar_marked.font = ml->font[x];
+ mchar_marked.fontx = ml->fontx[x];
+ }
#endif
mchar_marked.image = ml->image[x];
#ifdef DW_CHARS
@@ -1433,7 +1441,10 @@ struct mchar *rend;
{
#ifdef FONT
if (pastefont)
- mchar_marked.font = ml->font[x];
+ {
+ mchar_marked.font = ml->font[x];
+ mchar_marked.fontx = ml->fontx[x];
+ }
#endif
rend->image = mchar_marked.image;
if (!cmp_mchar(rend, &mchar_marked))
diff --git a/src/resize.c b/src/resize.c
index 3c2b90f..362fc9a 100644
--- a/src/resize.c
+++ b/src/resize.c
@@ -428,6 +428,8 @@ struct mline *ml;
#ifdef FONT
if (ml->font && ml->font != null)
free(ml->font);
+ if (ml->fontx && ml->fontx != null)
+ free(ml->fontx);
#endif
#ifdef COLOR
if (ml->color && ml->color != null)
@@ -449,6 +451,7 @@ int w;
ml->attr = null;
#ifdef FONT
ml->font = null;
+ ml->fontx = null;
#endif
#ifdef COLOR
ml->color = null;
@@ -485,6 +488,13 @@ int xf, xt, l, w;
}
if (mlt->font != null)
bcopy((char *)mlf->font + xf, (char *)mlt->font + xt, l);
+ if (mlf->fontx != null && mlt->fontx == null)
+ {
+ if ((mlt->fontx = (unsigned char *)calloc(w, 1)) == 0)
+ mlt->fontx = null, r = -1;
+ }
+ if (mlt->fontx != null)
+ bcopy((char *)mlf->fontx + xf, (char *)mlt->fontx + xt, l);
#endif
#ifdef COLOR
if (mlf->color != null && mlt->color == null)
@@ -531,6 +541,7 @@ int wi;
mline_old.attr = (unsigned char *)xrealloc((char *)mline_old.attr, maxwidth);
#ifdef FONT
mline_old.font = (unsigned char *)xrealloc((char *)mline_old.font, maxwidth);
+ mline_old.fontx = (unsigned char *)xrealloc((char *)mline_old.fontx, maxwidth);
#endif
#ifdef COLOR
mline_old.color = (unsigned char *)xrealloc((char *)mline_old.color, maxwidth);
@@ -538,7 +549,7 @@ int wi;
mline_old.colorx = (unsigned char *)xrealloc((char *)mline_old.colorx, maxwidth);
# endif
#endif
- if (!(blank && null && mline_old.image && mline_old.attr IFFONT(&& mline_old.font) IFCOLOR(&& mline_old.color) IFCOLORX(&& mline_old.colorx)))
+ if (!(blank && null && mline_old.image && mline_old.attr IFFONT(&& mline_old.font) IFFONTX(&& mline_old.fontx) IFCOLOR(&& mline_old.color) IFCOLORX(&& mline_old.colorx)))
Panic(0, "%s", strnomem);
MakeBlankLine(blank, maxwidth);
@@ -550,7 +561,9 @@ int wi;
mline_null.attr = null;
#ifdef FONT
mline_blank.font = null;
- mline_null.font = null;
+ mline_null.font = null;
+ mline_blank.fontx = null;
+ mline_null.fontx = null;
#endif
#ifdef COLOR
mline_blank.color = null;
@@ -571,6 +584,7 @@ int wi;
RESET_AFC(ml->image, blank); \
RESET_AFC(ml->attr, null); \
IFFONT(RESET_AFC(ml->font, null)); \
+ IFFONT(RESET_AFC(ml->fontx, null)); \
IFCOLOR(RESET_AFC(ml->color, null)); \
IFCOLORX(RESET_AFC(ml->colorx, null)); \
} \
@@ -1017,7 +1031,7 @@ int wi, he, hi;
if (p->w_encoding == UTF8)
{
for (l = 0; l < p->w_width; l++)
- ASSERT(ml->image[l] >= ' ' || ml->font[l]);
+ ASSERT(ml->image[l] >= ' ' || ml->font[l] || ml->fontx);
}
else
#endif
diff --git a/src/window.c b/src/window.c
index 1c6f5b6..0023065 100644
--- a/src/window.c
+++ b/src/window.c
@@ -403,6 +403,7 @@ struct mchar *rend;
register unsigned char *p, *i;
#ifdef FONT
register unsigned char *f;
+ register unsigned char *fx;
#endif
#ifdef COLOR
register unsigned char *c;
@@ -424,6 +425,7 @@ struct mchar *rend;
p = fore->w_mlines[y].attr + x1;
#ifdef FONT
f = fore->w_mlines[y].font + x1;
+ fx = fore->w_mlines[y].fontx + x1;
# ifdef DW_CHARS
if (is_dw_font(rend->font))
return EXPENSIVE;
@@ -448,6 +450,8 @@ struct mchar *rend;
#ifdef FONT
if (*f++ != rend->font)
return EXPENSIVE;
+ if (*fx++ != rend->fontx)
+ return EXPENSIVE;
#endif
#ifdef COLOR
if (*c++ != rend->color)