summaryrefslogtreecommitdiff
path: root/refresh.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2006-10-10 06:46:36 +0000
committerRich Felker <dalias@aerifal.cx>2006-10-10 06:46:36 +0000
commit0a545de895fb861fac88edea716e0b0a5d52f0ff (patch)
tree7c379742c4d3a833087fdc6d9db9926bbed8139b /refresh.c
parent12cb31c57a432d1ee4cc4ed7715a0f49ea55f1d6 (diff)
downloaduuterm-0a545de895fb861fac88edea716e0b0a5d52f0ff.tar.gz
finally, support for decomposing characters -- this makes it possible
to display accented characters using the base character glyphs with overstriking combining marks. (needs contextual glyphs to make this look good, obviously)
Diffstat (limited to 'refresh.c')
-rw-r--r--refresh.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/refresh.c b/refresh.c
index ef9aa7f..7410866 100644
--- a/refresh.c
+++ b/refresh.c
@@ -3,19 +3,21 @@
#include "uuterm.h"
#include "ucf.h"
-static void extract_cell(unsigned *ch, struct uucell *cell)
+static void extract_cell(unsigned *ch, size_t max, struct uucell *cell)
{
- int i;
+ int i, l;
unsigned b;
for (b=i=0; i<3; i++) b |= cell->c[i] << 8*i;
- ch[0] = b;
- ch -= 2;
- for (; i<sizeof(cell->c)+1 && cell->c[i]; i++)
- ch[i] = uu_combine_involution(b, cell->c[i]);
- if (cell->a & UU_ATTR_UL)
- ch[i++] = '_'; //0x0332;
- for (; i<sizeof(cell->c)+1; i++)
- ch[i] = 0;
+ l = uu_decompose_char(b, ch, max);
+ ch += l; max -= l;
+ for (; i<sizeof(cell->c) && cell->c[i]; i++) {
+ l = uu_decompose_char(uu_combine_involution(b, cell->c[i]), ch, max);
+ ch += l; max -= l;
+ }
+ if ((cell->a & UU_ATTR_UL) && max)
+ max--, *ch++ = '_'; //0x0332;
+ for (; max; max--) *ch++ = 0;
+ ch[-1] = 0;
}
const void *ascii_get_glyph(unsigned);
@@ -30,18 +32,19 @@ static const void *lookup_glyph(struct ucf *f, int i, unsigned *this, unsigned *
return 0;
}
+#define CH_LEN 16
void uuterm_refresh_row(struct uudisp *d, struct uurow *row, int x1, int x2)
{
- unsigned ch[4][sizeof(row->cells[0].c)+1], *chp;
+ unsigned ch[4][CH_LEN], *chp;
int x, i;
int width, part;
- if (x1) extract_cell(ch[(x1-1)&3], &row->cells[x1-1]);
+ if (x1) extract_cell(ch[(x1-1)&3], CH_LEN, &row->cells[x1-1]);
else memset(ch[3], 0, sizeof(ch[3]));
- extract_cell(ch[x1&3], &row->cells[x1]);
+ extract_cell(ch[x1&3], CH_LEN, &row->cells[x1]);
for (x=x1; x<=x2; x++) {
- extract_cell(ch[(x+1)&3], &row->cells[x+1]);
+ extract_cell(ch[(x+1)&3], CH_LEN, &row->cells[x+1]);
if (ch[x&3][0] == UU_FULLWIDTH) {
width = 2; part = 0; chp = ch[(x+1)&3];
} else if (ch[(x+3)&3][0] == UU_FULLWIDTH) {