aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-09-04 20:34:43 +0200
committerChristoph Lohmann <20h@r-36.net>2012-09-04 20:34:43 +0200
commit59fe59d3d1f922ec3a99c758e54ab88cfdf939be (patch)
treeba6807ed3caad0199e6686b73a3b115027ce527c
parent98b6f84bfcb63cff54f8aee87191432fa769346c (diff)
downloadst-59fe59d3d1f922ec3a99c758e54ab88cfdf939be.tar.gz
st-59fe59d3d1f922ec3a99c758e54ab88cfdf939be.zip
Unifying the old style.
-rw-r--r--st.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/st.c b/st.c
index b143582..d483d85 100644
--- a/st.c
+++ b/st.c
@@ -785,7 +785,7 @@ ttynew(void) {
785 close(s); 785 close(s);
786 cmdfd = m; 786 cmdfd = m;
787 signal(SIGCHLD, sigchld); 787 signal(SIGCHLD, sigchld);
788 if (opt_io && !(fileio = fopen(opt_io, "w"))) { 788 if(opt_io && !(fileio = fopen(opt_io, "w"))) {
789 fprintf(stderr, "Error opening %s:%s\n", 789 fprintf(stderr, "Error opening %s:%s\n",
790 opt_io, strerror(errno)); 790 opt_io, strerror(errno));
791 } 791 }
@@ -884,7 +884,7 @@ treset(void) {
884 }, .x = 0, .y = 0, .state = CURSOR_DEFAULT}; 884 }, .x = 0, .y = 0, .state = CURSOR_DEFAULT};
885 885
886 memset(term.tabs, 0, term.col * sizeof(*term.tabs)); 886 memset(term.tabs, 0, term.col * sizeof(*term.tabs));
887 for (i = TAB; i < term.col; i += TAB) 887 for(i = TAB; i < term.col; i += TAB)
888 term.tabs[i] = 1; 888 term.tabs[i] = 1;
889 term.top = 0, term.bot = term.row - 1; 889 term.top = 0, term.bot = term.row - 1;
890 term.mode = MODE_WRAP; 890 term.mode = MODE_WRAP;
@@ -1203,7 +1203,7 @@ void
1203tsetmode(bool priv, bool set, int *args, int narg) { 1203tsetmode(bool priv, bool set, int *args, int narg) {
1204 int *lim, mode; 1204 int *lim, mode;
1205 1205
1206 for (lim = args + narg; args < lim; ++args) { 1206 for(lim = args + narg; args < lim; ++args) {
1207 if(priv) { 1207 if(priv) {
1208 switch(*args) { 1208 switch(*args) {
1209 case 1: 1209 case 1:
@@ -1212,7 +1212,7 @@ tsetmode(bool priv, bool set, int *args, int narg) {
1212 case 5: /* DECSCNM -- Reverve video */ 1212 case 5: /* DECSCNM -- Reverve video */
1213 mode = term.mode; 1213 mode = term.mode;
1214 MODBIT(term.mode,set, MODE_REVERSE); 1214 MODBIT(term.mode,set, MODE_REVERSE);
1215 if (mode != term.mode) 1215 if(mode != term.mode)
1216 redraw(); 1216 redraw();
1217 break; 1217 break;
1218 case 7: 1218 case 7:
@@ -1237,11 +1237,11 @@ tsetmode(bool priv, bool set, int *args, int narg) {
1237 case 1047: 1237 case 1047:
1238 if(IS_SET(MODE_ALTSCREEN)) 1238 if(IS_SET(MODE_ALTSCREEN))
1239 tclearregion(0, 0, term.col-1, term.row-1); 1239 tclearregion(0, 0, term.col-1, term.row-1);
1240 if ((set && !IS_SET(MODE_ALTSCREEN)) || 1240 if((set && !IS_SET(MODE_ALTSCREEN)) ||
1241 (!set && IS_SET(MODE_ALTSCREEN))) { 1241 (!set && IS_SET(MODE_ALTSCREEN))) {
1242 tswapscreen(); 1242 tswapscreen();
1243 } 1243 }
1244 if (*args != 1049) 1244 if(*args != 1049)
1245 break; 1245 break;
1246 /* pass through */ 1246 /* pass through */
1247 case 1048: 1247 case 1048:
@@ -1334,7 +1334,7 @@ csihandle(void) {
1334 break; 1334 break;
1335 case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */ 1335 case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */
1336 DEFAULT(csiescseq.arg[0], 1); 1336 DEFAULT(csiescseq.arg[0], 1);
1337 while (csiescseq.arg[0]--) 1337 while(csiescseq.arg[0]--)
1338 tputtab(1); 1338 tputtab(1);
1339 break; 1339 break;
1340 case 'J': /* ED -- Clear screen */ 1340 case 'J': /* ED -- Clear screen */
@@ -1399,7 +1399,7 @@ csihandle(void) {
1399 break; 1399 break;
1400 case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */ 1400 case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */
1401 DEFAULT(csiescseq.arg[0], 1); 1401 DEFAULT(csiescseq.arg[0], 1);
1402 while (csiescseq.arg[0]--) 1402 while(csiescseq.arg[0]--)
1403 tputtab(0); 1403 tputtab(0);
1404 break; 1404 break;
1405 case 'd': /* VPA -- Move to <row> */ 1405 case 'd': /* VPA -- Move to <row> */
@@ -1530,15 +1530,15 @@ void
1530tputtab(bool forward) { 1530tputtab(bool forward) {
1531 unsigned x = term.c.x; 1531 unsigned x = term.c.x;
1532 1532
1533 if (forward) { 1533 if(forward) {
1534 if (x == term.col) 1534 if(x == term.col)
1535 return; 1535 return;
1536 for (++x; x < term.col && !term.tabs[x]; ++x) 1536 for(++x; x < term.col && !term.tabs[x]; ++x)
1537 /* nothing */ ; 1537 /* nothing */ ;
1538 } else { 1538 } else {
1539 if (x == 0) 1539 if(x == 0)
1540 return; 1540 return;
1541 for (--x; x > 0 && !term.tabs[x]; --x) 1541 for(--x; x > 0 && !term.tabs[x]; --x)
1542 /* nothing */ ; 1542 /* nothing */ ;
1543 } 1543 }
1544 tmoveto(x, term.c.y); 1544 tmoveto(x, term.c.y);
@@ -1548,8 +1548,9 @@ void
1548tputc(char *c) { 1548tputc(char *c) {
1549 char ascii = *c; 1549 char ascii = *c;
1550 1550
1551 if (fileio) 1551 if(fileio)
1552 putc(ascii, fileio); 1552 putc(ascii, fileio);
1553
1553 if(term.esc & ESC_START) { 1554 if(term.esc & ESC_START) {
1554 if(term.esc & ESC_CSI) { 1555 if(term.esc & ESC_CSI) {
1555 csiescseq.buf[csiescseq.len++] = ascii; 1556 csiescseq.buf[csiescseq.len++] = ascii;
@@ -1568,7 +1569,7 @@ tputc(char *c) {
1568 break; 1569 break;
1569 default: 1570 default:
1570 strescseq.buf[strescseq.len++] = ascii; 1571 strescseq.buf[strescseq.len++] = ascii;
1571 if (strescseq.len+1 >= STR_BUF_SIZ) { 1572 if(strescseq.len+1 >= STR_BUF_SIZ) {
1572 term.esc = 0; 1573 term.esc = 0;
1573 strhandle(); 1574 strhandle();
1574 } 1575 }
@@ -1746,13 +1747,13 @@ tresize(int col, int row) {
1746 term.line[i] = calloc(col, sizeof(Glyph)); 1747 term.line[i] = calloc(col, sizeof(Glyph));
1747 term.alt [i] = calloc(col, sizeof(Glyph)); 1748 term.alt [i] = calloc(col, sizeof(Glyph));
1748 } 1749 }
1749 if (col > term.col) { 1750 if(col > term.col) {
1750 bool *bp = term.tabs + term.col; 1751 bool *bp = term.tabs + term.col;
1751 1752
1752 memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); 1753 memset(bp, 0, sizeof(*term.tabs) * (col - term.col));
1753 while (--bp > term.tabs && !*bp) 1754 while(--bp > term.tabs && !*bp)
1754 /* nothing */ ; 1755 /* nothing */ ;
1755 for (bp += TAB; bp < term.tabs + col; bp += TAB) 1756 for(bp += TAB; bp < term.tabs + col; bp += TAB)
1756 *bp = 1; 1757 *bp = 1;
1757 } 1758 }
1758 /* update terminal size */ 1759 /* update terminal size */
@@ -1805,7 +1806,7 @@ xloadcols(void) {
1805 1806
1806 for(r = 0; r < 24; r++, i++) { 1807 for(r = 0; r < 24; r++, i++) {
1807 color.red = color.green = color.blue = 0x0808 + 0x0a0a * r; 1808 color.red = color.green = color.blue = 0x0808 + 0x0a0a * r;
1808 if (!XAllocColor(xw.dpy, xw.cmap, &color)) { 1809 if(!XAllocColor(xw.dpy, xw.cmap, &color)) {
1809 dc.col[i] = white; 1810 dc.col[i] = white;
1810 fprintf(stderr, "Could not allocate color %d\n", i); 1811 fprintf(stderr, "Could not allocate color %d\n", i);
1811 } else 1812 } else
@@ -2227,11 +2228,11 @@ void
2227cmessage(XEvent *e) { 2228cmessage(XEvent *e) {
2228 /* See xembed specs 2229 /* See xembed specs
2229 http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html */ 2230 http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html */
2230 if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) { 2231 if(e->xclient.message_type == xw.xembed && e->xclient.format == 32) {
2231 if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) { 2232 if(e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
2232 xw.state |= WIN_FOCUSED; 2233 xw.state |= WIN_FOCUSED;
2233 xseturgency(0); 2234 xseturgency(0);
2234 } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) { 2235 } else if(e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
2235 xw.state &= ~WIN_FOCUSED; 2236 xw.state &= ~WIN_FOCUSED;
2236 } 2237 }
2237 draw(); 2238 draw();
@@ -2322,7 +2323,7 @@ main(int argc, char *argv[]) {
2322 if(++i < argc) opt_embed = argv[i]; 2323 if(++i < argc) opt_embed = argv[i];
2323 break; 2324 break;
2324 case 'f': 2325 case 'f':
2325 if (++i < argc) opt_io = argv[i]; 2326 if(++i < argc) opt_io = argv[i];
2326 break; 2327 break;
2327 case 'e': 2328 case 'e':
2328 /* eat every remaining arguments */ 2329 /* eat every remaining arguments */