diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | config.h | 22 | ||||
-rw-r--r--[-rwxr-xr-x] | st.c | 80 | ||||
-rw-r--r-- | st.info | 12 |
4 files changed, 88 insertions, 27 deletions
@@ -42,6 +42,7 @@ install: all | |||
42 | @cp -f st ${DESTDIR}${PREFIX}/bin | 42 | @cp -f st ${DESTDIR}${PREFIX}/bin |
43 | @chmod 755 ${DESTDIR}${PREFIX}/bin/st | 43 | @chmod 755 ${DESTDIR}${PREFIX}/bin/st |
44 | @tic st.info | 44 | @tic st.info |
45 | @tic st-256color.info | ||
45 | 46 | ||
46 | uninstall: | 47 | uninstall: |
47 | @echo removing executable file from ${DESTDIR}${PREFIX}/bin | 48 | @echo removing executable file from ${DESTDIR}${PREFIX}/bin |
@@ -7,13 +7,21 @@ | |||
7 | /* Terminal colors */ | 7 | /* Terminal colors */ |
8 | static const char *colorname[] = { | 8 | static const char *colorname[] = { |
9 | "black", | 9 | "black", |
10 | "red", | 10 | "#CC0000", |
11 | "green", | 11 | "#4E9A06", |
12 | "yellow", | 12 | "#C4A000", |
13 | "blue", | 13 | "#3465A4", |
14 | "magenta", | 14 | "#75507B", |
15 | "cyan", | 15 | "#06989A", |
16 | "white", | 16 | "#888a85", |
17 | "#555753", | ||
18 | "#EF2929", | ||
19 | "#8AE234", | ||
20 | "#FCE94F", | ||
21 | "#729FCF", | ||
22 | "#AD7FA8", | ||
23 | "#34E2E2", | ||
24 | "#EEEEEC" | ||
17 | }; | 25 | }; |
18 | 26 | ||
19 | /* Default colors (colorname index) */ | 27 | /* Default colors (colorname index) */ |
@@ -20,7 +20,7 @@ | |||
20 | #include <X11/keysym.h> | 20 | #include <X11/keysym.h> |
21 | #include <X11/Xutil.h> | 21 | #include <X11/Xutil.h> |
22 | 22 | ||
23 | #define TNAME "xterm" | 23 | #define TNAME "st-256color" |
24 | 24 | ||
25 | /* Arbitrary sizes */ | 25 | /* Arbitrary sizes */ |
26 | #define ESC_TITLE_SIZ 256 | 26 | #define ESC_TITLE_SIZ 256 |
@@ -111,7 +111,7 @@ typedef struct { | |||
111 | 111 | ||
112 | /* Drawing Context */ | 112 | /* Drawing Context */ |
113 | typedef struct { | 113 | typedef struct { |
114 | unsigned long col[LEN(colorname)]; | 114 | unsigned long col[256]; |
115 | XFontStruct* font; | 115 | XFontStruct* font; |
116 | XFontStruct* bfont; | 116 | XFontStruct* bfont; |
117 | GC gc; | 117 | GC gc; |
@@ -154,7 +154,6 @@ static void ttyread(void); | |||
154 | static void ttyresize(int, int); | 154 | static void ttyresize(int, int); |
155 | static void ttywrite(const char *, size_t); | 155 | static void ttywrite(const char *, size_t); |
156 | 156 | ||
157 | static unsigned long xgetcol(const char *); | ||
158 | static void xclear(int, int, int, int); | 157 | static void xclear(int, int, int, int); |
159 | static void xcursor(int); | 158 | static void xcursor(int); |
160 | static void xinit(void); | 159 | static void xinit(void); |
@@ -593,9 +592,31 @@ tsetattr(int *attr, int l) { | |||
593 | case 27: | 592 | case 27: |
594 | term.c.attr.mode &= ~ATTR_REVERSE; | 593 | term.c.attr.mode &= ~ATTR_REVERSE; |
595 | break; | 594 | break; |
595 | case 38: | ||
596 | if (i + 2 < l && attr[i + 1] == 5) { | ||
597 | i += 2; | ||
598 | if (BETWEEN(attr[i], 0, 255)) | ||
599 | term.c.attr.fg = attr[i]; | ||
600 | else | ||
601 | fprintf(stderr, "erresc: bad fgcolor %d\n", attr[i]); | ||
602 | } | ||
603 | else | ||
604 | fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]); | ||
605 | break; | ||
596 | case 39: | 606 | case 39: |
597 | term.c.attr.fg = DefaultFG; | 607 | term.c.attr.fg = DefaultFG; |
598 | break; | 608 | break; |
609 | case 48: | ||
610 | if (i + 2 < l && attr[i + 1] == 5) { | ||
611 | i += 2; | ||
612 | if (BETWEEN(attr[i], 0, 255)) | ||
613 | term.c.attr.bg = attr[i]; | ||
614 | else | ||
615 | fprintf(stderr, "erresc: bad bgcolor %d\n", attr[i]); | ||
616 | } | ||
617 | else | ||
618 | fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]); | ||
619 | break; | ||
599 | case 49: | 620 | case 49: |
600 | term.c.attr.bg = DefaultBG; | 621 | term.c.attr.bg = DefaultBG; |
601 | break; | 622 | break; |
@@ -604,8 +625,12 @@ tsetattr(int *attr, int l) { | |||
604 | term.c.attr.fg = attr[i] - 30; | 625 | term.c.attr.fg = attr[i] - 30; |
605 | else if(BETWEEN(attr[i], 40, 47)) | 626 | else if(BETWEEN(attr[i], 40, 47)) |
606 | term.c.attr.bg = attr[i] - 40; | 627 | term.c.attr.bg = attr[i] - 40; |
628 | else if(BETWEEN(attr[i], 90, 97)) | ||
629 | term.c.attr.fg = attr[i] - 90 + 8; | ||
630 | else if(BETWEEN(attr[i], 100, 107)) | ||
631 | term.c.attr.fg = attr[i] - 100 + 8; | ||
607 | else | 632 | else |
608 | fprintf(stderr, "erresc: gfx attr %d unkown\n", attr[i]); | 633 | fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]); |
609 | break; | 634 | break; |
610 | } | 635 | } |
611 | } | 636 | } |
@@ -1009,16 +1034,44 @@ tresize(int col, int row) { | |||
1009 | term.col = col, term.row = row; | 1034 | term.col = col, term.row = row; |
1010 | } | 1035 | } |
1011 | 1036 | ||
1012 | unsigned long | 1037 | void |
1013 | xgetcol(const char *s) { | 1038 | tloadcols(void) { |
1039 | int i, r, g, b; | ||
1014 | XColor color; | 1040 | XColor color; |
1015 | Colormap cmap = DefaultColormap(xw.dis, xw.scr); | 1041 | Colormap cmap = DefaultColormap(xw.dis, xw.scr); |
1042 | unsigned long white = WhitePixel(xw.dis, xw.scr); | ||
1043 | |||
1044 | for(i = 0; i < 16; i++) { | ||
1045 | if (!XAllocNamedColor(xw.dis, cmap, colorname[i], &color, &color)) { | ||
1046 | dc.col[i] = white; | ||
1047 | fprintf(stderr, "Could not allocate color '%s'\n", colorname[i]); | ||
1048 | } else | ||
1049 | dc.col[i] = color.pixel; | ||
1050 | } | ||
1051 | |||
1052 | /* same colors as xterm */ | ||
1053 | for(r = 0; r < 6; r++) | ||
1054 | for(g = 0; g < 6; g++) | ||
1055 | for(b = 0; b < 6; b++) { | ||
1056 | color.red = r == 0 ? 0 : 0x3737 + 0x2828 * r; | ||
1057 | color.green = g == 0 ? 0 : 0x3737 + 0x2828 * g; | ||
1058 | color.blue = b == 0 ? 0 : 0x3737 + 0x2828 * b; | ||
1059 | if (!XAllocColor(xw.dis, cmap, &color)) { | ||
1060 | dc.col[i] = white; | ||
1061 | fprintf(stderr, "Could not allocate color %d\n", i); | ||
1062 | } else | ||
1063 | dc.col[i] = color.pixel; | ||
1064 | i++; | ||
1065 | } | ||
1016 | 1066 | ||
1017 | if(!XAllocNamedColor(xw.dis, cmap, s, &color, &color)) { | 1067 | for(r = 0; r < 24; r++, i++) { |
1018 | color.pixel = WhitePixel(xw.dis, xw.scr); | 1068 | color.red = color.green = color.blue = 0x0808 + 0x0a0a * r; |
1019 | fprintf(stderr, "Could not allocate color '%s'\n", s); | 1069 | if (!XAllocColor(xw.dis, cmap, &color)) { |
1070 | dc.col[i] = white; | ||
1071 | fprintf(stderr, "Could not allocate color %d\n", i); | ||
1072 | } else | ||
1073 | dc.col[i] = color.pixel; | ||
1020 | } | 1074 | } |
1021 | return color.pixel; | ||
1022 | } | 1075 | } |
1023 | 1076 | ||
1024 | void | 1077 | void |
@@ -1048,8 +1101,6 @@ xhints(void) | |||
1048 | 1101 | ||
1049 | void | 1102 | void |
1050 | xinit(void) { | 1103 | xinit(void) { |
1051 | int i; | ||
1052 | |||
1053 | xw.dis = XOpenDisplay(NULL); | 1104 | xw.dis = XOpenDisplay(NULL); |
1054 | xw.scr = XDefaultScreen(xw.dis); | 1105 | xw.scr = XDefaultScreen(xw.dis); |
1055 | if(!xw.dis) | 1106 | if(!xw.dis) |
@@ -1064,8 +1115,7 @@ xinit(void) { | |||
1064 | xw.ch = dc.font->ascent + dc.font->descent; | 1115 | xw.ch = dc.font->ascent + dc.font->descent; |
1065 | 1116 | ||
1066 | /* colors */ | 1117 | /* colors */ |
1067 | for(i = 0; i < LEN(colorname); i++) | 1118 | tloadcols(); |
1068 | dc.col[i] = xgetcol(colorname[i]); | ||
1069 | 1119 | ||
1070 | term.c.attr.fg = DefaultFG; | 1120 | term.c.attr.fg = DefaultFG; |
1071 | term.c.attr.bg = DefaultBG; | 1121 | term.c.attr.bg = DefaultBG; |
@@ -1173,6 +1223,8 @@ draw(int redraw_all) { | |||
1173 | Glyph base, new; | 1223 | Glyph base, new; |
1174 | char buf[DRAW_BUF_SIZ]; | 1224 | char buf[DRAW_BUF_SIZ]; |
1175 | 1225 | ||
1226 | XSetForeground(xw.dis, dc.gc, dc.col[DefaultBG]); | ||
1227 | XFillRectangle(xw.dis, xw.buf, dc.gc, 0, 0, xw.w, xw.h); | ||
1176 | for(y = 0; y < term.row; y++) { | 1228 | for(y = 0; y < term.row; y++) { |
1177 | base = term.line[y][0]; | 1229 | base = term.line[y][0]; |
1178 | i = ox = 0; | 1230 | i = ox = 0; |
@@ -1,7 +1,6 @@ | |||
1 | # Reconstructed via infocmp from file: /lib/terminfo/p/pcansi | ||
2 | st| simpleterm, | 1 | st| simpleterm, |
3 | am, | 2 | am, |
4 | ul, | 3 | ul, |
5 | mir, | 4 | mir, |
6 | msgr, | 5 | msgr, |
7 | colors#8, | 6 | colors#8, |
@@ -10,7 +9,7 @@ st| simpleterm, | |||
10 | lines#24, | 9 | lines#24, |
11 | ncv#3, | 10 | ncv#3, |
12 | pairs#64, | 11 | pairs#64, |
13 | acsc=*`#aof+g+j+k+l+m+n-o-p-q-r-s+t+u+v+w|x<y>z{{||}}-~, | 12 | acsc=*`#aof+g+j+k+l+m+n-o-p-q-r-s+t+u+v+w|x<y>z{{||}}-~, |
14 | bel=^G, | 13 | bel=^G, |
15 | bold=\E[1m, | 14 | bold=\E[1m, |
16 | cbt=\E[Z, | 15 | cbt=\E[Z, |
@@ -36,9 +35,11 @@ st| simpleterm, | |||
36 | kcud1=\E[B, | 35 | kcud1=\E[B, |
37 | kcuf1=\E[C, | 36 | kcuf1=\E[C, |
38 | kcuu1=\E[A, | 37 | kcuu1=\E[A, |
38 | kdch1=\E[3~, | ||
39 | kend=\E[4~, | ||
39 | khome=\E[1~, | 40 | khome=\E[1~, |
40 | knp=\E[6~, | 41 | knp=\E[6~, |
41 | kpp=\E[5~, | 42 | kpp=\E[5~, |
42 | op=\E[37;40m, | 43 | op=\E[37;40m, |
43 | rev=\E[7m, | 44 | rev=\E[7m, |
44 | rmacs=\E[10m, | 45 | rmacs=\E[10m, |
@@ -46,7 +47,6 @@ st| simpleterm, | |||
46 | rmul=\E[m, | 47 | rmul=\E[m, |
47 | setab=\E[4%p1%dm, | 48 | setab=\E[4%p1%dm, |
48 | setaf=\E[3%p1%dm, | 49 | setaf=\E[3%p1%dm, |
49 | # sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;12%;m, | ||
50 | sgr0=\E[0m, | 50 | sgr0=\E[0m, |
51 | smacs=\E[12m, | 51 | smacs=\E[12m, |
52 | smso=\E[7m, | 52 | smso=\E[7m, |