aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xst.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/st.c b/st.c
index db5e04f..a571a28 100755
--- a/st.c
+++ b/st.c
@@ -39,7 +39,8 @@
39 39
40/* Attribute, Cursor, Character state, Terminal mode, Screen draw mode */ 40/* Attribute, Cursor, Character state, Terminal mode, Screen draw mode */
41enum { ATTR_NULL=0 , ATTR_REVERSE=1 , ATTR_UNDERLINE=2, ATTR_BOLD=4, ATTR_GFX=8 }; 41enum { ATTR_NULL=0 , ATTR_REVERSE=1 , ATTR_UNDERLINE=2, ATTR_BOLD=4, ATTR_GFX=8 };
42enum { CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, CURSOR_HIDE, CURSOR_DRAW, CURSOR_SAVE, CURSOR_LOAD }; 42enum { CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, CURSOR_HIDE, CURSOR_DRAW,
43 CURSOR_SAVE, CURSOR_LOAD };
43enum { GLYPH_SET=1, GLYPH_DIRTY=2 }; 44enum { GLYPH_SET=1, GLYPH_DIRTY=2 };
44enum { MODE_WRAP=1, MODE_INSERT=2, MODE_APPKEYPAD=4 }; 45enum { MODE_WRAP=1, MODE_INSERT=2, MODE_APPKEYPAD=4 };
45enum { ESC_START=1, ESC_CSI=2, ESC_OSC=4, ESC_TITLE=8, ESC_ALTCHARSET=16 }; 46enum { ESC_START=1, ESC_CSI=2, ESC_OSC=4, ESC_TITLE=8, ESC_ALTCHARSET=16 };
@@ -879,7 +880,7 @@ tputc(char c) {
879 printf("esc unhandled charset: ESC ( %c\n", c); 880 printf("esc unhandled charset: ESC ( %c\n", c);
880 } 881 }
881 term.esc = 0; 882 term.esc = 0;
882 } else { 883 } else {
883 switch(c) { 884 switch(c) {
884 case '[': 885 case '[':
885 term.esc |= ESC_CSI; 886 term.esc |= ESC_CSI;
@@ -972,7 +973,7 @@ tputc(char c) {
972} 973}
973 974
974void 975void
975tputs(char *s, int len) { 976tputs(char *s, int len) {
976 for(; len > 0; len--) 977 for(; len > 0; len--)
977 tputc(*s++); 978 tputc(*s++);
978} 979}
@@ -1024,8 +1025,8 @@ void
1024xclear(int x1, int y1, int x2, int y2) { 1025xclear(int x1, int y1, int x2, int y2) {
1025 XSetForeground(xw.dis, dc.gc, dc.col[DefaultBG]); 1026 XSetForeground(xw.dis, dc.gc, dc.col[DefaultBG]);
1026 XFillRectangle(xw.dis, xw.buf, dc.gc, 1027 XFillRectangle(xw.dis, xw.buf, dc.gc,
1027 x1 * xw.cw, y1 * xw.ch, 1028 x1 * xw.cw, y1 * xw.ch,
1028 (x2-x1+1) * xw.cw, (y2-y1+1) * xw.ch); 1029 (x2-x1+1) * xw.cw, (y2-y1+1) * xw.ch);
1029} 1030}
1030 1031
1031void 1032void
@@ -1033,12 +1034,14 @@ xhints(void)
1033{ 1034{
1034 XClassHint chint = {TNAME, TNAME}; 1035 XClassHint chint = {TNAME, TNAME};
1035 XWMHints wmhint = {.flags = InputHint, .input = 1}; 1036 XWMHints wmhint = {.flags = InputHint, .input = 1};
1036 XSizeHints shint = { 1037 XSizeHints shint = {
1037 .flags = PSize | PResizeInc, 1038 .flags = PSize | PResizeInc | PBaseSize,
1038 .height = xw.h, /* XXX: doesn't seem to work, see run() */ 1039 .height = xw.h,
1039 .width = xw.w, 1040 .width = xw.w,
1040 .height_inc = xw.ch, 1041 .height_inc = xw.ch,
1041 .width_inc = xw.cw, 1042 .width_inc = xw.cw,
1043 .base_height = 2*BORDER,
1044 .base_width = 2*BORDER,
1042 }; 1045 };
1043 XSetWMProperties(xw.dis, xw.win, NULL, NULL, NULL, 0, &shint, &wmhint, &chint); 1046 XSetWMProperties(xw.dis, xw.win, NULL, NULL, NULL, 0, &shint, &wmhint, &chint);
1044} 1047}
@@ -1071,7 +1074,7 @@ xinit(void) {
1071 xw.h = term.row * xw.ch + 2*BORDER; 1074 xw.h = term.row * xw.ch + 2*BORDER;
1072 xw.w = term.col * xw.cw + 2*BORDER; 1075 xw.w = term.col * xw.cw + 2*BORDER;
1073 xw.win = XCreateSimpleWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0, 1076 xw.win = XCreateSimpleWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0,
1074 xw.w, xw.h, 0, 1077 xw.w, xw.h, 0,
1075 dc.col[DefaultBG], 1078 dc.col[DefaultBG],
1076 dc.col[DefaultBG]); 1079 dc.col[DefaultBG]);
1077 xw.bufw = xw.w - 2*BORDER; 1080 xw.bufw = xw.w - 2*BORDER;
@@ -1081,7 +1084,7 @@ xinit(void) {
1081 dc.gc = XCreateGC(xw.dis, xw.win, 0, NULL); 1084 dc.gc = XCreateGC(xw.dis, xw.win, 0, NULL);
1082 XMapWindow(xw.dis, xw.win); 1085 XMapWindow(xw.dis, xw.win);
1083 xhints(); 1086 xhints();
1084 XStoreName(xw.dis, xw.win, TNAME); 1087 XStoreName(xw.dis, xw.win, "st");
1085 XSync(xw.dis, 0); 1088 XSync(xw.dis, 0);
1086} 1089}
1087 1090
@@ -1103,7 +1106,7 @@ xdraws(char *s, Glyph base, int x, int y, int len) {
1103 for(i = 0; i < len; i++) 1106 for(i = 0; i < len; i++)
1104 s[i] = gfx[s[i]]; 1107 s[i] = gfx[s[i]];
1105 1108
1106 XSetFont(xw.dis, dc.gc, base.mode & ATTR_BOLD ? dc.bfont->fid : dc.font->fid); 1109 XSetFont(xw.dis, dc.gc, base.mode & ATTR_BOLD ? dc.bfont->fid : dc.font->fid);
1107 XDrawImageString(xw.dis, xw.buf, dc.gc, winx, winy, s, len); 1110 XDrawImageString(xw.dis, xw.buf, dc.gc, winx, winy, s, len);
1108 1111
1109 if(base.mode & ATTR_UNDERLINE) 1112 if(base.mode & ATTR_UNDERLINE)
@@ -1135,7 +1138,6 @@ xcursor(int mode) {
1135 } 1138 }
1136} 1139}
1137 1140
1138
1139#ifdef DEBUG 1141#ifdef DEBUG
1140/* basic drawing routines */ 1142/* basic drawing routines */
1141void 1143void
@@ -1148,7 +1150,7 @@ xdrawc(int x, int y, Glyph g) {
1148} 1150}
1149 1151
1150void 1152void
1151draw_(int dummy) { 1153draw(int dummy) {
1152 int x, y; 1154 int x, y;
1153 1155
1154 xclear(0, 0, term.col-1, term.row-1); 1156 xclear(0, 0, term.col-1, term.row-1);
@@ -1162,8 +1164,9 @@ draw_(int dummy) {
1162 XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER); 1164 XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
1163 XFlush(xw.dis); 1165 XFlush(xw.dis);
1164} 1166}
1165#endif
1166 1167
1168#else
1169/* optimized drawing routine */
1167void 1170void
1168draw(int redraw_all) { 1171draw(int redraw_all) {
1169 int i, x, y, ox; 1172 int i, x, y, ox;
@@ -1192,6 +1195,8 @@ draw(int redraw_all) {
1192 XFlush(xw.dis); 1195 XFlush(xw.dis);
1193} 1196}
1194 1197
1198#endif
1199
1195void 1200void
1196expose(XEvent *ev) { 1201expose(XEvent *ev) {
1197 draw(SCREEN_REDRAW); 1202 draw(SCREEN_REDRAW);