--- rxvt-unicode/src/defaultfont.C 2003/11/24 17:28:08 1.1 +++ rxvt-unicode/src/defaultfont.C 2003/11/27 20:09:00 1.3 @@ -23,9 +23,9 @@ #include "rxvt.h" #include "defaultfont.h" -#define DISPLAY R->Xdisplay -#define DRAWABLE R->TermWin.vt -#define GC R->TermWin.gc +#define DISPLAY r->Xdisplay +#define DRAWABLE r->TermWin.vt +#define GC r->TermWin.gc const struct rxvt_fallback_font { codeset cs; @@ -165,11 +165,62 @@ XClearArea (DISPLAY, DRAWABLE, x, y, w, h, FALSE); else if (color >= 0) { - XSetForeground (DISPLAY, GC, R->PixColors[color]); + XSetForeground (DISPLAY, GC, r->PixColors[color]); XFillRectangle (DISPLAY, DRAWABLE, GC, x, y, w, h); } } +static const char *linedraw_cmds[128] = { + "1hH", "2hH", "1vV", "2vV", + 0, 0, 0, 0, + 0, 0, 0, 0, + "1HV", "2H1V", "1H2V", "2HV", + + // 2510 + "1hV", "2h1V", "1h2V", "2hV", + "1Hv", "2H1v", "1H2v", "2Hv", + "1hv", "2h1v", "1h2v", "2hv", + "1HvV", "2H1vV", "1HV2v", "1Hv2V", + + // 2520 + "1H2vV", "2Hv1V", "2HV1v", "2HvV", + "1hvV", "2h1vV", "1hV2v", "1hv2V", + "1h2vV", "2hv1V", "1v2hV", "2hvV", + "1hHV", "2h1HV", "2H1hV", "2hH1V", + + // 2530 + "1hH2V", "2hV1H", "1h2HV", "2hHV", + "1hHv", "1vH2h", "1hv2H", "1v2hH", + "1hH2v", "1H2hv", "1h2Hv", "2hHv", + "1hHvV", "1vVH2h", "1hvV2H", "1vV2hH", + + // 2540 + "1hHV2v", "1hHv2V", "1hH2vV", "1HV2hv", + "1hV2Hv", "1Hv2hV", "1hv2HV", "1V2hHv", + "1v2hHV", "1H2hvV", "1h2HvV", "2hHvV", + 0, 0, 0, 0, + + // 2550 + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + // 2560 + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + // 2570 + 0, "1a", "1b", "1ab", + "1h", "1v", "1H", "1V", + "2h", "2v", "2H", "2V", + "1h2H", "1v2V", "1H2h", "1V2v" + + // to be done +}; + struct rxvt_font_default : rxvt_font { bool load (int maxheight) { @@ -181,8 +232,13 @@ bool has_codepoint (uint32_t unicode) { - if (unicode <= 0x001f - || (unicode >= 0x80 && unicode <= 0x9f)) + if (unicode <= 0x001f) + return true; + if (unicode >= 0x0080 && unicode <= 0x009f) + return true; + + if (unicode >= 0x2500 && unicode <= 0x257f + && linedraw_cmds[unicode - 0x2500]) return true; switch (unicode) @@ -204,21 +260,63 @@ const text_t *text, int len, int fg, int bg) { - clear_rect (x, y, R->TermWin.fwidth * len, R->TermWin.fheight, bg); + clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); + + XSetForeground (DISPLAY, GC, r->PixColors[fg]); while (len--) { - switch (*text++) + text_t t = *text++; + + if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) { - case NOCHAR: - case ZERO_WIDTH_CHAR: - break; - default: - XSetForeground (DISPLAY, GC, R->PixColors[fg]); - XDrawRectangle (DISPLAY, DRAWABLE, GC, x + 2, y + 2, R->TermWin.fwidth - 5, R->TermWin.fheight - 5); + const char *p = linedraw_cmds[t - 0x2500]; + + int x0 = x, x1 = x + (r->TermWin.fwidth - 1) / 2, x2 = x + r->TermWin.fwidth - 1; + int y0 = y, y1 = y + (r->TermWin.fheight - 1) / 2, y2 = y + r->TermWin.fheight - 1; + + XGCValues gcv; + + gcv.cap_style = CapButt; + XChangeGC (DISPLAY, GC, GCCapStyle, &gcv); + + while (*p) + { + switch (*p++) + { + case '1': + gcv.line_width = 0; + XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); + break; + + case '2': + gcv.line_width = 2; + XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); + break; + + case 'h': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y1, x1, y1); break; + case 'H': XDrawLine (DISPLAY, DRAWABLE, GC, x1, y1, x2, y1); break; + case 'v': XDrawLine (DISPLAY, DRAWABLE, GC, x1, y0, x1, y1); break; + case 'V': XDrawLine (DISPLAY, DRAWABLE, GC, x1, y1, x1, y2); break; + case 'a': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y2, x2, y0); break; + case 'b': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y0, x2, y2); break; + } + } + + gcv.line_width = 0; + XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); } + else + switch (*text++) + { + case NOCHAR: + case ZERO_WIDTH_CHAR: + break; + default: + XDrawRectangle (DISPLAY, DRAWABLE, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); + } - x += R->TermWin.fwidth; + x += r->TermWin.fwidth; } } @@ -406,14 +504,14 @@ // but the result still isn't perfect /. bool slow = prop - || width != R->TermWin.fwidth - || height != R->TermWin.fheight; + || width != r->TermWin.fwidth + || height != r->TermWin.fheight; - int base = R->TermWin.fbase; + int base = r->TermWin.fbase; XGCValues v; - v.foreground = R->PixColors[fg]; - v.background = R->PixColors[bg]; + v.foreground = r->PixColors[fg]; + v.background = r->PixColors[bg]; v.font = f->fid; if (enc2b) @@ -427,7 +525,7 @@ } else { - clear_rect (x, y, R->TermWin.fwidth * len, R->TermWin.fheight, bg); + clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); @@ -438,7 +536,7 @@ if (xc->byte1 || xc->byte2) XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); - x += R->TermWin.fwidth; + x += r->TermWin.fwidth; xc++; len--; } while (len); @@ -458,7 +556,7 @@ } else { - clear_rect (x, y, R->TermWin.fwidth * len, R->TermWin.fheight, bg); + clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); @@ -469,7 +567,7 @@ if (*xc) XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); - x += R->TermWin.fwidth; + x += r->TermWin.fwidth; xc++; len--; } while (len); @@ -546,7 +644,7 @@ { if (f) { - XftFontClose (R->Xdisplay, f); + XftFontClose (DISPLAY, f); f = 0; } @@ -572,7 +670,7 @@ clear (); - f = XftFontOpenName (R->Xdisplay, DefaultScreen (R->Xdisplay), name); + f = XftFontOpenName (DISPLAY, DefaultScreen (DISPLAY), name); if (!f) return false; @@ -588,8 +686,8 @@ XGlyphInfo g1, g2; FcChar8 c; - c = 'i'; XftTextExtents8 (R->Xdisplay, f, &c, 1, &g1); - c = 'W'; XftTextExtents8 (R->Xdisplay, f, &c, 1, &g2); + c = 'i'; XftTextExtents8 (DISPLAY, f, &c, 1, &g1); + c = 'W'; XftTextExtents8 (DISPLAY, f, &c, 1, &g2); prop = prop || g1.xOff != g2.xOff; // don't simply trust the font @@ -634,7 +732,7 @@ bool rxvt_font_xft::has_codepoint (uint32_t unicode) { - return XftCharExists (R->Xdisplay, f, unicode); + return XftCharExists (DISPLAY, f, unicode); } void @@ -643,19 +741,22 @@ int fg, int bg) { if (!d) - d = XftDrawCreate (R->Xdisplay, DRAWABLE, XVISUAL, XCMAP); + { + dR; + d = XftDrawCreate (DISPLAY, DRAWABLE, XVISUAL, XCMAP); + } if (bg >= 0 && bg != Color_bg) - XftDrawRect (d, &R->PixColors[bg].c, x, y, R->TermWin.fwidth * len, R->TermWin.fheight); + XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); else - clear_rect (x, y, R->TermWin.fwidth * len, R->TermWin.fheight, bg); + clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); - if (!prop && width == R->TermWin.fwidth) + if (!prop && width == r->TermWin.fwidth) { if (sizeof (text_t) == sizeof (FcChar16)) - XftDrawString16 (d, &R->PixColors[fg].c, f, x, y + R->TermWin.fbase, (const FcChar16 *)text, len); + XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); else - XftDrawString32 (d, &R->PixColors[fg].c, f, x, y + R->TermWin.fbase, (const FcChar32 *)text, len); + XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, len); } else { @@ -664,12 +765,12 @@ if (*text != NOCHAR && *text != ' ') { if (sizeof (text_t) == sizeof (FcChar16)) - XftDrawString16 (d, &R->PixColors[fg].c, f, x, y + R->TermWin.fbase, (const FcChar16 *)text, 1); + XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, 1); else - XftDrawString32 (d, &R->PixColors[fg].c, f, x, y + R->TermWin.fbase, (const FcChar32 *)text, 1); + XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, 1); } - x += R->TermWin.fwidth; + x += r->TermWin.fwidth; text++; len--; } @@ -679,9 +780,9 @@ ///////////////////////////////////////////////////////////////////////////// -rxvt_fontset::rxvt_fontset (pR) +rxvt_fontset::rxvt_fontset (rxvt_t r) #ifdef EXPLICIT_CONTEXT -: rxvt_term(R) +: r(r) #endif { clear (); @@ -730,7 +831,7 @@ else f = new rxvt_font_x11; - f->set_term (aR); + f->set_term (r); f->set_name (strdup (name)); f->cs = cs;