diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-09-01 16:26:12 +0200 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-09-01 16:26:12 +0200 |
commit | ef69118028afad1938951a1f7dff8db2aa557879 (patch) | |
tree | f0ddc8ebde8fc90f78c53ab2891fe7a42c93a89f /st.c | |
parent | f732ca5f1f03a0a496a07aa6bda15f6c363a2484 (diff) | |
download | st-ef69118028afad1938951a1f7dff8db2aa557879.tar.gz st-ef69118028afad1938951a1f7dff8db2aa557879.zip |
factor and cleanup code.
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -387,10 +387,10 @@ dump(char c) { | |||
387 | 387 | ||
388 | void | 388 | void |
389 | ttyread(void) { | 389 | ttyread(void) { |
390 | char buf[BUFSIZ] = {0}; | 390 | char buf[BUFSIZ]; |
391 | int ret; | 391 | int ret; |
392 | 392 | ||
393 | if((ret = read(cmdfd, buf, BUFSIZ)) < 0) | 393 | if((ret = read(cmdfd, buf, LEN(buf))) < 0) |
394 | die("Couldn't read from shell: %s\n", SERRNO); | 394 | die("Couldn't read from shell: %s\n", SERRNO); |
395 | else | 395 | else |
396 | tputs(buf, ret); | 396 | tputs(buf, ret); |
@@ -465,8 +465,7 @@ tscrolldown (int n) { | |||
465 | 465 | ||
466 | LIMIT(n, 0, term.bot-term.top+1); | 466 | LIMIT(n, 0, term.bot-term.top+1); |
467 | 467 | ||
468 | for(i = 0; i < n; i++) | 468 | tclearregion(0, term.bot-n+1, term.col-1, term.bot); |
469 | memset(term.line[term.bot-i], 0, term.col*sizeof(Glyph)); | ||
470 | 469 | ||
471 | for(i = term.bot; i >= term.top+n; i--) { | 470 | for(i = term.bot; i >= term.top+n; i--) { |
472 | temp = term.line[i]; | 471 | temp = term.line[i]; |
@@ -481,8 +480,7 @@ tscrollup (int n) { | |||
481 | Line temp; | 480 | Line temp; |
482 | LIMIT(n, 0, term.bot-term.top+1); | 481 | LIMIT(n, 0, term.bot-term.top+1); |
483 | 482 | ||
484 | for(i = 0; i < n; i++) | 483 | tclearregion(0, term.top, term.col-1, term.top+n-1); |
485 | memset(term.line[term.top+i], 0, term.col*sizeof(Glyph)); | ||
486 | 484 | ||
487 | for(i = term.top; i <= term.bot-n; i++) { | 485 | for(i = term.top; i <= term.bot-n; i++) { |
488 | temp = term.line[i]; | 486 | temp = term.line[i]; |
@@ -957,7 +955,8 @@ tputc(char c) { | |||
957 | term.esc = 0; | 955 | term.esc = 0; |
958 | csiparse(), csihandle(); | 956 | csiparse(), csihandle(); |
959 | } | 957 | } |
960 | } else if(term.esc & ESC_OSC) { | 958 | /* TODO: handle other OSC */ |
959 | } else if(term.esc & ESC_OSC) { | ||
961 | if(c == ';') { | 960 | if(c == ';') { |
962 | term.titlelen = 0; | 961 | term.titlelen = 0; |
963 | term.esc = ESC_START | ESC_TITLE; | 962 | term.esc = ESC_START | ESC_TITLE; |
@@ -1201,18 +1200,18 @@ xinit(void) { | |||
1201 | xloadcols(); | 1200 | xloadcols(); |
1202 | 1201 | ||
1203 | /* windows */ | 1202 | /* windows */ |
1204 | xw.h = term.row * xw.ch + 2*BORDER; | 1203 | xw.bufh = term.row * xw.ch; |
1205 | xw.w = term.col * xw.cw + 2*BORDER; | 1204 | xw.bufw = term.col * xw.cw; |
1205 | xw.h = xw.bufh + 2*BORDER; | ||
1206 | xw.w = xw.bufw + 2*BORDER; | ||
1206 | xw.win = XCreateSimpleWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0, | 1207 | xw.win = XCreateSimpleWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0, |
1207 | xw.w, xw.h, 0, | 1208 | xw.w, xw.h, 0, |
1208 | dc.col[DefaultBG], | 1209 | dc.col[DefaultBG], |
1209 | dc.col[DefaultBG]); | 1210 | dc.col[DefaultBG]); |
1210 | xw.bufw = xw.w - 2*BORDER; | ||
1211 | xw.bufh = xw.h - 2*BORDER; | ||
1212 | xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr)); | 1211 | xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr)); |
1213 | /* gc */ | 1212 | /* gc */ |
1214 | dc.gc = XCreateGC(xw.dis, xw.win, 0, NULL); | 1213 | dc.gc = XCreateGC(xw.dis, xw.win, 0, NULL); |
1215 | 1214 | ||
1216 | /* event mask */ | 1215 | /* event mask */ |
1217 | XSelectInput(xw.dis, xw.win, ExposureMask | KeyPressMask | 1216 | XSelectInput(xw.dis, xw.win, ExposureMask | KeyPressMask |
1218 | | StructureNotifyMask | FocusChangeMask | PointerMotionMask | 1217 | | StructureNotifyMask | FocusChangeMask | PointerMotionMask |