aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-09-26 20:21:08 +0200
committerChristoph Lohmann <20h@r-36.net>2012-09-26 20:21:08 +0200
commit23d1b03d4e657ee34d29c53199941635333faed8 (patch)
tree89f6c65b351ef48f5de8dddcaee3dba236c926d3
parentd8cf33c2077b7c95f19e8bc1930caaa60e37f2f1 (diff)
downloadst-patched-23d1b03d4e657ee34d29c53199941635333faed8.tar.bz2
st-patched-23d1b03d4e657ee34d29c53199941635333faed8.tar.xz
st-patched-23d1b03d4e657ee34d29c53199941635333faed8.zip
Implementing line drawing right.
-rw-r--r--config.def.h8
-rw-r--r--st.c52
2 files changed, 36 insertions, 24 deletions
diff --git a/config.def.h b/config.def.h
index 1f0291e..5a49b9d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -79,14 +79,6 @@ static Key key[] = {
79/* Set TERM to this */ 79/* Set TERM to this */
80#define TNAME "st-256color" 80#define TNAME "st-256color"
81 81
82/* Line drawing characters (sometime specific to each font...) */
83static char gfx[] = {
84 ['f'] = 'o',
85 ['g'] = '+',
86 ['i'] = '#',
87 [255] = 0,
88};
89
90/* double-click timeout (in milliseconds) between clicks for selection */ 82/* double-click timeout (in milliseconds) between clicks for selection */
91#define DOUBLECLICK_TIMEOUT 300 83#define DOUBLECLICK_TIMEOUT 300
92#define TRIPLECLICK_TIMEOUT (2*DOUBLECLICK_TIMEOUT) 84#define TRIPLECLICK_TIMEOUT (2*DOUBLECLICK_TIMEOUT)
diff --git a/st.c b/st.c
index 009ccb4..a64b84d 100644
--- a/st.c
+++ b/st.c
@@ -1094,6 +1094,27 @@ tmoveto(int x, int y) {
1094 1094
1095void 1095void
1096tsetchar(char *c) { 1096tsetchar(char *c) {
1097 /*
1098 * The table is proudly stolen from rxvt.
1099 */
1100 if(term.c.attr.mode & ATTR_GFX) {
1101 char *vt100_0[62] = { /* 0x41 - 0x7e */
1102 "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
1103 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
1104 0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
1105 0, 0, 0, 0, 0, 0, 0, " ", /* X - _ */
1106 "◆", "▒", "␉", "␌", "␍", "␊", "°", "±", /* ` - g */
1107 "␤", "␋", "┘", "┐", "┌", "└", "┼", "⎺", /* h - o */
1108 "⎻", "─", "⎼", "⎽", "├", "┤", "┴", "┬", /* p - w */
1109 "│", "≤", "≥", "π", "≠", "£", "·", /* x - ~ */
1110 };
1111
1112 if(c[0] >= 0x41 && c[0] <= 0x7e
1113 && vt100_0[c[0] - 0x41]) {
1114 c = vt100_0[c[0] - 0x41];
1115 }
1116 }
1117
1097 term.dirty[term.c.y] = 1; 1118 term.dirty[term.c.y] = 1;
1098 term.line[term.c.y][term.c.x] = term.c.attr; 1119 term.line[term.c.y][term.c.x] = term.c.attr;
1099 memcpy(term.line[term.c.y][term.c.x].c, c, UTF_SIZ); 1120 memcpy(term.line[term.c.y][term.c.x].c, c, UTF_SIZ);
@@ -1177,7 +1198,7 @@ tsetattr(int *attr, int l) {
1177 switch(attr[i]) { 1198 switch(attr[i]) {
1178 case 0: 1199 case 0:
1179 term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD \ 1200 term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD \
1180 | ATTR_ITALIC | ATTR_BLINK | ATTR_GFX); 1201 | ATTR_ITALIC | ATTR_BLINK);
1181 term.c.attr.fg = DefaultFG; 1202 term.c.attr.fg = DefaultFG;
1182 term.c.attr.bg = DefaultBG; 1203 term.c.attr.bg = DefaultBG;
1183 break; 1204 break;
@@ -1676,12 +1697,18 @@ tputc(char *c, int len) {
1676 strhandle(); 1697 strhandle();
1677 } else if(term.esc & ESC_ALTCHARSET) { 1698 } else if(term.esc & ESC_ALTCHARSET) {
1678 switch(ascii) { 1699 switch(ascii) {
1679 case '0': /* Line drawing crap */ 1700 case '0': /* Line drawing set */
1680 term.c.attr.mode |= ATTR_GFX; 1701 term.c.attr.mode |= ATTR_GFX;
1681 break; 1702 break;
1682 case 'B': /* Back to regular text */ 1703 case 'B': /* USASCII */
1683 term.c.attr.mode &= ~ATTR_GFX; 1704 term.c.attr.mode &= ~ATTR_GFX;
1684 break; 1705 break;
1706 case 'A': /* UK (IGNORED) */
1707 case '<': /* multinational charset (IGNORED) */
1708 case '5': /* Finnish (IGNORED) */
1709 case 'C': /* Finnish (IGNORED) */
1710 case 'K': /* German (IGNORED) */
1711 break;
1685 default: 1712 default:
1686 fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); 1713 fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii);
1687 } 1714 }
@@ -1700,10 +1727,14 @@ tputc(char *c, int len) {
1700 strescseq.type = ascii; 1727 strescseq.type = ascii;
1701 term.esc |= ESC_STR; 1728 term.esc |= ESC_STR;
1702 break; 1729 break;
1703 case ')': 1730 case '(': /* set primary charset G0 */
1704 case '(':
1705 term.esc |= ESC_ALTCHARSET; 1731 term.esc |= ESC_ALTCHARSET;
1706 break; 1732 break;
1733 case ')': /* set secondary charset G1 (IGNORED) */
1734 case '*': /* set tertiary charset G2 (IGNORED) */
1735 case '+': /* set quaternary charset G3 (IGNORED) */
1736 term.esc = 0;
1737 break;
1707 case 'D': /* IND -- Linefeed */ 1738 case 'D': /* IND -- Linefeed */
1708 if(term.c.y == term.bot) 1739 if(term.c.y == term.bot)
1709 tscrollup(term.top, 1); 1740 tscrollup(term.top, 1);
@@ -2067,7 +2098,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
2067 int winx = BORDER+x*xw.cw, winy = BORDER+y*xw.ch + dc.font.ascent, width = charlen*xw.cw; 2098 int winx = BORDER+x*xw.cw, winy = BORDER+y*xw.ch + dc.font.ascent, width = charlen*xw.cw;
2068 Font *font = &dc.font; 2099 Font *font = &dc.font;
2069 XGlyphInfo extents; 2100 XGlyphInfo extents;
2070 int i;
2071 2101
2072 /* only switch default fg/bg if term is in RV mode */ 2102 /* only switch default fg/bg if term is in RV mode */
2073 if(IS_SET(MODE_REVERSE)) { 2103 if(IS_SET(MODE_REVERSE)) {
@@ -2093,16 +2123,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
2093 XSetBackground(xw.dpy, dc.gc, dc.col[bg]); 2123 XSetBackground(xw.dpy, dc.gc, dc.col[bg]);
2094 XSetForeground(xw.dpy, dc.gc, dc.col[fg]); 2124 XSetForeground(xw.dpy, dc.gc, dc.col[fg]);
2095 2125
2096 if(base.mode & ATTR_GFX) {
2097 for(i = 0; i < bytelen; i++) {
2098 char c = gfx[(uint)s[i] % 256];
2099 if(c)
2100 s[i] = c;
2101 else if(s[i] > 0x5f)
2102 s[i] -= 0x5f;
2103 }
2104 }
2105
2106 XftTextExtentsUtf8(xw.dpy, font->xft_set, (FcChar8 *)s, bytelen, &extents); 2126 XftTextExtentsUtf8(xw.dpy, font->xft_set, (FcChar8 *)s, bytelen, &extents);
2107 width = extents.xOff; 2127 width = extents.xOff;
2108 XftDrawRect(xw.xft_draw, &dc.xft_col[bg], winx, winy - font->ascent, width, xw.ch); 2128 XftDrawRect(xw.xft_draw, &dc.xft_col[bg], winx, winy - font->ascent, width, xw.ch);