summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c434
1 files changed, 89 insertions, 345 deletions
diff --git a/st.c b/st.c
index 8b687d7..62def59 100644
--- a/st.c
+++ b/st.c
@@ -35,7 +35,6 @@
#define ESC_ARG_SIZ 16
#define STR_BUF_SIZ ESC_BUF_SIZ
#define STR_ARG_SIZ ESC_ARG_SIZ
-#define HISTSIZE 2000
/* macros */
#define IS_SET(flag) ((term.mode & (flag)) != 0)
@@ -43,11 +42,6 @@
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
#define ISDELIM(u) (u && wcschr(worddelimiters, u))
-#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
- term.scr + HISTSIZE + 1) % HISTSIZE] : \
- term.line[(y) - term.scr])
-#define STRESCARGREST(n) ((n) == 0 ? strescseq.buf : strescseq.argp[(n)-1] + 1)
-#define STRESCARGJUST(n) (*(strescseq.argp[n]) = '\0', STRESCARGREST(n))
enum term_mode {
MODE_WRAP = 1 << 0,
@@ -121,9 +115,6 @@ typedef struct {
int col; /* nb col */
Line *line; /* screen */
Line *alt; /* alternate screen */
- Line hist[HISTSIZE]; /* history buffer */
- int histi; /* history index */
- int scr; /* scroll back */
int *dirty; /* dirtyness of lines */
TCursor c; /* cursor */
int ocx; /* old cursor col */
@@ -157,7 +148,7 @@ typedef struct {
char *buf; /* allocated raw string */
size_t siz; /* allocation size */
size_t len; /* raw string length */
- char *argp[STR_ARG_SIZ]; /* pointers to the end of nth argument */
+ char *args[STR_ARG_SIZ];
int narg; /* nb of args */
} STREscape;
@@ -170,6 +161,7 @@ static void csidump(void);
static void csihandle(void);
static void csiparse(void);
static void csireset(void);
+static void osc_color_response(int, int, int);
static int eschandle(uchar);
static void strdump(void);
static void strhandle(void);
@@ -193,8 +185,8 @@ static void tnewline(int);
static void tputtab(int);
static void tputc(Rune);
static void treset(void);
-static void tscrollup(int, int, int);
-static void tscrolldown(int, int, int);
+static void tscrollup(int, int);
+static void tscrolldown(int, int);
static void tsetattr(const int *, int);
static void tsetchar(Rune, const Glyph *, int, int);
static void tsetdirt(int, int);
@@ -358,25 +350,10 @@ utf8validate(Rune *u, size_t i)
return i;
}
-static const char base64_digits[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
- 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, -1, 0, 0, 0, 0, 1,
- 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
char
base64dec_getc(const char **src)
{
- while (**src && !isprint(**src))
+ while (**src && !isprint((unsigned char)**src))
(*src)++;
return **src ? *((*src)++) : '='; /* emulate padding if string ends */
}
@@ -386,6 +363,13 @@ base64dec(const char *src)
{
size_t in_len = strlen(src);
char *result, *dst;
+ static const char base64_digits[256] = {
+ [43] = 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+ 0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0,
+ 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+ };
if (in_len % 4)
in_len += 4 - (in_len % 4);
@@ -425,10 +409,10 @@ tlinelen(int y)
{
int i = term.col;
- if (TLINE(y)[i - 1].mode & ATTR_WRAP)
+ if (term.line[y][i - 1].mode & ATTR_WRAP)
return i;
- while (i > 0 && TLINE(y)[i - 1].u == ' ')
+ while (i > 0 && term.line[y][i - 1].u == ' ')
--i;
return i;
@@ -537,7 +521,7 @@ selsnap(int *x, int *y, int direction)
* Snap around if the word wraps around at the end or
* beginning of a line.
*/
- prevgp = &TLINE(*y)[*x];
+ prevgp = &term.line[*y][*x];
prevdelim = ISDELIM(prevgp->u);
for (;;) {
newx = *x + direction;
@@ -552,14 +536,14 @@ selsnap(int *x, int *y, int direction)
yt = *y, xt = *x;
else
yt = newy, xt = newx;
- if (!(TLINE(yt)[xt].mode & ATTR_WRAP))
+ if (!(term.line[yt][xt].mode & ATTR_WRAP))
break;
}
if (newx >= tlinelen(newy))
break;
- gp = &TLINE(newy)[newx];
+ gp = &term.line[newy][newx];
delim = ISDELIM(gp->u);
if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
|| (delim && gp->u != prevgp->u)))
@@ -580,14 +564,14 @@ selsnap(int *x, int *y, int direction)
*x = (direction < 0) ? 0 : term.col - 1;
if (direction < 0) {
for (; *y > 0; *y += direction) {
- if (!(TLINE(*y-1)[term.col-1].mode
+ if (!(term.line[*y-1][term.col-1].mode
& ATTR_WRAP)) {
break;
}
}
} else if (direction > 0) {
for (; *y < term.row-1; *y += direction) {
- if (!(TLINE(*y)[term.col-1].mode
+ if (!(term.line[*y][term.col-1].mode
& ATTR_WRAP)) {
break;
}
@@ -618,13 +602,13 @@ getsel(void)
}
if (sel.type == SEL_RECTANGULAR) {
- gp = &TLINE(y)[sel.nb.x];
+ gp = &term.line[y][sel.nb.x];
lastx = sel.ne.x;
} else {
- gp = &TLINE(y)[sel.nb.y == y ? sel.nb.x : 0];
+ gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1;
}
- last = &TLINE(y)[MIN(lastx, linelen-1)];
+ last = &term.line[y][MIN(lastx, linelen-1)];
while (last >= gp && last->u == ' ')
--last;
@@ -734,14 +718,8 @@ sigchld(int a)
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
- if (pid != p) {
- if (p == 0 && wait(&stat) < 0)
- die("wait: %s\n", strerror(errno));
-
- /* reinstall sigchld handler */
- signal(SIGCHLD, sigchld);
+ if (pid != p)
return;
- }
if (WIFEXITED(stat) && WEXITSTATUS(stat))
die("child exited with status %d\n", WEXITSTATUS(stat));
@@ -866,9 +844,6 @@ void
ttywrite(const char *s, size_t n, int may_echo)
{
const char *next;
- Arg arg = (Arg) { .i = term.scr };
-
- kscrolldown(&arg);
if (may_echo && IS_SET(MODE_ECHO))
twrite(s, n, 1);
@@ -964,7 +939,7 @@ ttyresize(int tw, int th)
}
void
-ttyhangup()
+ttyhangup(void)
{
/* Send SIGHUP to shell */
kill(pid, SIGHUP);
@@ -1068,11 +1043,6 @@ tnew(int col, int row)
treset();
}
-int tisaltscr(void)
-{
- return IS_SET(MODE_ALTSCREEN);
-}
-
void
tswapscreen(void)
{
@@ -1085,53 +1055,13 @@ tswapscreen(void)
}
void
-kscrolldown(const Arg* a)
-{
- int n = a->i;
-
- if (n < 0)
- n = term.row + n;
-
- if (n > term.scr)
- n = term.scr;
-
- if (term.scr > 0) {
- term.scr -= n;
- selscroll(0, -n);
- tfulldirt();
- }
-}
-
-void
-kscrollup(const Arg* a)
-{
- int n = a->i;
-
- if (n < 0)
- n = term.row + n;
-
- if (term.scr <= HISTSIZE-n) {
- term.scr += n;
- selscroll(0, n);
- tfulldirt();
- }
-}
-
-void
-tscrolldown(int orig, int n, int copyhist)
+tscrolldown(int orig, int n)
{
int i;
Line temp;
LIMIT(n, 0, term.bot-orig+1);
- if (copyhist) {
- term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE;
- temp = term.hist[term.histi];
- term.hist[term.histi] = term.line[term.bot];
- term.line[term.bot] = temp;
- }
-
tsetdirt(orig, term.bot-n);
tclearregion(0, term.bot-n+1, term.col-1, term.bot);
@@ -1141,28 +1071,17 @@ tscrolldown(int orig, int n, int copyhist)
term.line[i-n] = temp;
}
- if (term.scr == 0)
- selscroll(orig, n);
+ selscroll(orig, n);
}
void
-tscrollup(int orig, int n, int copyhist)
+tscrollup(int orig, int n)
{
int i;
Line temp;
LIMIT(n, 0, term.bot-orig+1);
- if (copyhist) {
- term.histi = (term.histi + 1) % HISTSIZE;
- temp = term.hist[term.histi];
- term.hist[term.histi] = term.line[orig];
- term.line[orig] = temp;
- }
-
- if (term.scr > 0 && term.scr < HISTSIZE)
- term.scr = MIN(term.scr + n, HISTSIZE-1);
-
tclearregion(0, orig, term.col-1, orig+n-1);
tsetdirt(orig+n, term.bot);
@@ -1172,8 +1091,7 @@ tscrollup(int orig, int n, int copyhist)
term.line[i+n] = temp;
}
- if (term.scr == 0)
- selscroll(orig, -n);
+ selscroll(orig, -n);
}
void
@@ -1202,7 +1120,7 @@ tnewline(int first_col)
int y = term.c.y;
if (y == term.bot) {
- tscrollup(term.top, 1, 1);
+ tscrollup(term.top, 1);
} else {
y++;
}
@@ -1367,14 +1285,14 @@ void
tinsertblankline(int n)
{
if (BETWEEN(term.c.y, term.top, term.bot))
- tscrolldown(term.c.y, n, 0);
+ tscrolldown(term.c.y, n);
}
void
tdeleteline(int n)
{
if (BETWEEN(term.c.y, term.top, term.bot))
- tscrollup(term.c.y, n, 0);
+ tscrollup(term.c.y, n);
}
int32_t
@@ -1811,11 +1729,11 @@ csihandle(void)
break;
case 'S': /* SU -- Scroll <n> line up */
DEFAULT(csiescseq.arg[0], 1);
- tscrollup(term.top, csiescseq.arg[0], 0);
+ tscrollup(term.top, csiescseq.arg[0]);
break;
case 'T': /* SD -- Scroll <n> line down */
DEFAULT(csiescseq.arg[0], 1);
- tscrolldown(term.top, csiescseq.arg[0], 0);
+ tscrolldown(term.top, csiescseq.arg[0]);
break;
case 'L': /* IL -- Insert <n> blank lines */
DEFAULT(csiescseq.arg[0], 1);
@@ -1884,33 +1802,6 @@ csihandle(void)
goto unknown;
}
break;
- case 't': /* title stack operations */
- switch (csiescseq.arg[0]) {
- case 22: /* pust current title on stack */
- switch (csiescseq.arg[1]) {
- case 0:
- case 1:
- case 2:
- xpushtitle();
- break;
- default:
- goto unknown;
- }
- break;
- case 23: /* pop last title from stack */
- switch (csiescseq.arg[1]) {
- case 0:
- case 1:
- case 2:
- xsettitle(NULL, 1);
- break;
- default:
- goto unknown;
- }
- break;
- default:
- goto unknown;
- }
}
}
@@ -1945,39 +1836,28 @@ csireset(void)
}
void
-osc4_color_response(int num)
+osc_color_response(int num, int index, int is_osc4)
{
int n;
char buf[32];
unsigned char r, g, b;
- if (xgetcolor(num, &r, &g, &b)) {
- fprintf(stderr, "erresc: failed to fetch osc4 color %d\n", num);
+ if (xgetcolor(is_osc4 ? num : index, &r, &g, &b)) {
+ fprintf(stderr, "erresc: failed to fetch %s color %d\n",
+ is_osc4 ? "osc4" : "osc",
+ is_osc4 ? num : index);
return;
}
- n = snprintf(buf, sizeof buf, "\033]4;%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
- num, r, r, g, g, b, b);
-
- ttywrite(buf, n, 1);
-}
-
-void
-osc_color_response(int index, int num)
-{
- int n;
- char buf[32];
- unsigned char r, g, b;
-
- if (xgetcolor(index, &r, &g, &b)) {
- fprintf(stderr, "erresc: failed to fetch osc color %d\n", index);
- return;
+ n = snprintf(buf, sizeof buf, "\033]%s%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
+ is_osc4 ? "4;" : "", num, r, r, g, g, b, b);
+ if (n < 0 || n >= sizeof(buf)) {
+ fprintf(stderr, "error: %s while printing %s response\n",
+ n < 0 ? "snprintf failed" : "truncation occurred",
+ is_osc4 ? "osc4" : "osc");
+ } else {
+ ttywrite(buf, n, 1);
}
-
- n = snprintf(buf, sizeof buf, "\033]%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
- num, r, r, g, g, b, b);
-
- ttywrite(buf, n, 1);
}
void
@@ -1985,32 +1865,36 @@ strhandle(void)
{
char *p = NULL, *dec;
int j, narg, par;
+ const struct { int idx; char *str; } osc_table[] = {
+ { defaultfg, "foreground" },
+ { defaultbg, "background" },
+ { defaultcs, "cursor" }
+ };
term.esc &= ~(ESC_STR_END|ESC_STR);
- strescseq.buf[strescseq.len] = '\0';
+ strparse();
+ par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0;
switch (strescseq.type) {
case ']': /* OSC -- Operating System Command */
- strparse();
- par = (narg = strescseq.narg) ? atoi(STRESCARGJUST(0)) : 0;
switch (par) {
case 0:
if (narg > 1) {
- xsettitle(STRESCARGREST(1), 0);
- xseticontitle(STRESCARGREST(1));
+ xsettitle(strescseq.args[1]);
+ xseticontitle(strescseq.args[1]);
}
return;
case 1:
if (narg > 1)
- xsettitle(STRESCARGREST(1), 0);
+ xseticontitle(strescseq.args[1]);
return;
case 2:
if (narg > 1)
- xsettitle(STRESCARGREST(1), 0);
+ xsettitle(strescseq.args[1]);
return;
case 52:
if (narg > 2 && allowwindowops) {
- dec = base64dec(STRESCARGJUST(2));
+ dec = base64dec(strescseq.args[2]);
if (dec) {
xsetsel(dec);
xclipcopy();
@@ -2019,88 +1903,35 @@ strhandle(void)
}
}
return;
- /*
- case 10:
- if (narg < 2)
- break;
-
- p = STRESCARGREST(1);
-
- if (!strcmp(p, "?"))
- osc_color_response(defaultfg, 10);
- else if (xsetcolorname(defaultfg, p))
- fprintf(stderr, "erresc: invalid foreground color: %s\n", p);
- else
- redraw();
- return;
+ case 10:
case 11:
- if (narg < 2)
- break;
-
- p = STRESCARGREST(1);
-
- if (!strcmp(p, "?"))
- osc_color_response(defaultbg, 11);
- else if (xsetcolorname(defaultbg, p))
- fprintf(stderr, "erresc: invalid background color: %s\n", p);
- else
- redraw();
- return;
case 12:
if (narg < 2)
break;
-
- p = STRESCARGREST(1);
-
- if (!strcmp(p, "?"))
- osc_color_response(defaultcs, 12);
- else if (xsetcolorname(defaultcs, p))
- fprintf(stderr, "erresc: invalid cursor color: %s\n", p);
- else
- redraw();
+ p = strescseq.args[1];
+ if ((j = par - 10) < 0 || j >= LEN(osc_table))
+ break; /* shouldn't be possible */
+
+ if (!strcmp(p, "?")) {
+ osc_color_response(par, osc_table[j].idx, 0);
+ } else if (xsetcolorname(osc_table[j].idx, p)) {
+ fprintf(stderr, "erresc: invalid %s color: %s\n",
+ osc_table[j].str, p);
+ } else {
+ tfulldirt();
+ }
return;
- */
- case 10: /* set foreground color */
- if (narg < 2)
- break;
-
- p = STRESCARGJUST(1);
- if (xsetcolorname(defaultfg, p))
- fprintf(stderr, "erresc: invalid foreground color %s\n", p);
- else
- redraw();
- break;
- case 11: /* set background color */
- if (narg < 2)
- break;
-
- p = STRESCARGJUST(1);
- if (xsetcolorname(defaultbg, p))
- fprintf(stderr, "erresc: invalid background color %s\n", p);
- else
- redraw();
- break;
- case 12: /* set cursor color */
- if (narg < 2)
- break;
-
- p = STRESCARGJUST(1);
- if (xsetcolorname(defaultcs, p))
- fprintf(stderr, "erresc: invalid cursor color %s\n", p);
- else
- redraw();
- break;
case 4: /* color set */
if (narg < 3)
break;
- p = STRESCARGJUST(2);
+ p = strescseq.args[2];
/* FALLTHROUGH */
case 104: /* color reset */
- j = (narg > 1) ? atoi(STRESCARGJUST(1)) : -1;
+ j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
- if (p && !strcmp(p, "?"))
- osc4_color_response(j);
- else if (xsetcolorname(j, p)) {
+ if (p && !strcmp(p, "?")) {
+ osc_color_response(j, 0, 1);
+ } else if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1)
return; /* color reset without parameter */
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
@@ -2110,15 +1941,13 @@ strhandle(void)
* TODO if defaultbg color is changed, borders
* are dirty
*/
- if (j == defaultbg)
- xclearwin();
- redraw();
+ tfulldirt();
}
return;
}
break;
case 'k': /* old title set compatibility */
- xsettitle(strescseq.buf, 0);
+ xsettitle(strescseq.args[0]);
return;
case 'P': /* DCS -- Device Control String */
case '_': /* APC -- Application Program Command */
@@ -2137,74 +1966,22 @@ strparse(void)
char *p = strescseq.buf;
strescseq.narg = 0;
+ strescseq.buf[strescseq.len] = '\0';
if (*p == '\0')
return;
while (strescseq.narg < STR_ARG_SIZ) {
+ strescseq.args[strescseq.narg++] = p;
while ((c = *p) != ';' && c != '\0')
- p++;
- strescseq.argp[strescseq.narg++] = p;
+ ++p;
if (c == '\0')
return;
- p++;
+ *p++ = '\0';
}
}
void
-externalpipe(const Arg *arg)
-{
- int to[2];
- char buf[UTF_SIZ];
- void (*oldsigpipe)(int);
- Glyph *bp, *end;
- int lastpos, n, newline;
-
- if (pipe(to) == -1)
- return;
-
- switch (fork()) {
- case -1:
- close(to[0]);
- close(to[1]);
- return;
- case 0:
- dup2(to[0], STDIN_FILENO);
- close(to[0]);
- close(to[1]);
- execvp(((char **)arg->v)[0], (char **)arg->v);
- fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]);
- perror("failed");
- exit(0);
- }
-
- close(to[0]);
- /* ignore sigpipe for now, in case child exists early */
- oldsigpipe = signal(SIGPIPE, SIG_IGN);
- newline = 0;
- for (n = 0; n < term.row; n++) {
- bp = term.line[n];
- lastpos = MIN(tlinelen(n) + 1, term.col) - 1;
- if (lastpos < 0)
- break;
- end = &bp[lastpos + 1];
- for (; bp < end; ++bp)
- if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
- break;
- if ((newline = term.line[n][lastpos].mode & ATTR_WRAP))
- continue;
- if (xwrite(to[1], "\n", 1) < 0)
- break;
- newline = 0;
- }
- if (newline)
- (void)xwrite(to[1], "\n", 1);
- close(to[1]);
- /* restore */
- signal(SIGPIPE, oldsigpipe);
-}
-
-void
strdump(void)
{
size_t i;
@@ -2258,28 +2035,6 @@ tprinter(char *s, size_t len)
}
void
-iso14755(const Arg *arg)
-{
- FILE *p;
- char *us, *e, codepoint[9], uc[UTF_SIZ];
- unsigned long utf32;
-
- if (!(p = popen(iso14755_cmd, "r")))
- return;
-
- us = fgets(codepoint, sizeof(codepoint), p);
- pclose(p);
-
- if (!us || *us == '\0' || *us == '-' || strlen(us) > 7)
- return;
- if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX ||
- (*e != '\n' && *e != '\0'))
- return;
-
- ttywrite(uc, utf8encode(utf32, uc), 1);
-}
-
-void
toggleprinter(const Arg *arg)
{
term.mode ^= MODE_PRINT;
@@ -2541,7 +2296,7 @@ eschandle(uchar ascii)
return 0;
case 'D': /* IND -- Linefeed */
if (term.c.y == term.bot) {
- tscrollup(term.top, 1, 1);
+ tscrollup(term.top, 1);
} else {
tmoveto(term.c.x, term.c.y+1);
}
@@ -2554,7 +2309,7 @@ eschandle(uchar ascii)
break;
case 'M': /* RI -- Reverse index */
if (term.c.y == term.top) {
- tscrolldown(term.top, 1, 1);
+ tscrolldown(term.top, 1);
} else {
tmoveto(term.c.x, term.c.y-1);
}
@@ -2564,7 +2319,6 @@ eschandle(uchar ascii)
break;
case 'c': /* RIS -- Reset to initial state */
treset();
- xfreetitlestack();
resettitle();
xloadcols();
break;
@@ -2769,7 +2523,7 @@ twrite(const char *buf, int buflen, int show_ctrl)
void
tresize(int col, int row)
{
- int i, j;
+ int i;
int minrow = MIN(row, term.row);
int mincol = MIN(col, term.col);
int *bp;
@@ -2806,14 +2560,6 @@ tresize(int col, int row)
term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
- for (i = 0; i < HISTSIZE; i++) {
- term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
- for (j = mincol; j < col; j++) {
- term.hist[i][j] = term.c.attr;
- term.hist[i][j].u = ' ';
- }
- }
-
/* resize each row to new width, zero-pad if needed */
for (i = 0; i < minrow; i++) {
term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
@@ -2859,7 +2605,7 @@ tresize(int col, int row)
void
resettitle(void)
{
- xsettitle(NULL, 0);
+ xsettitle(NULL);
}
void
@@ -2872,7 +2618,7 @@ drawregion(int x1, int y1, int x2, int y2)
continue;
term.dirty[y] = 0;
- xdrawline(TLINE(y), x1, y, x2);
+ xdrawline(term.line[y], x1, y, x2);
}
}
@@ -2893,10 +2639,8 @@ draw(void)
cx--;
drawregion(0, 0, term.col, term.row);
- if (term.scr == 0)
- xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
- term.ocx, term.ocy, term.line[term.ocy][term.ocx],
- term.line[term.ocy], term.col);
+ xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
+ term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
term.ocx = cx;
term.ocy = term.c.y;
xfinishdraw();