aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c392
1 files changed, 80 insertions, 312 deletions
diff --git a/st.c b/st.c
index 876e625..9c7ff35 100644
--- a/st.c
+++ b/st.c
@@ -14,7 +14,6 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <termios.h>
-#include <time.h>
#include <unistd.h>
#include <wchar.h>
@@ -31,31 +30,16 @@
/* Arbitrary sizes */
#define UTF_INVALID 0xFFFD
-#define UTF_SIZ 4
-#define ESC_BUF_SIZ (128 * UTF_SIZ)
#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)
-#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177')
#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 TLINE_HIST(y) \
- ((y) <= HISTSIZE - term.row + 2 ? term.hist[(y)] \
- : term.line[(y - HISTSIZE + term.row - 3)])
-
-/* constants */
-#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
enum term_mode {
MODE_WRAP = 1 << 0,
@@ -124,27 +108,22 @@ typedef struct {
/* Internal representation of the screen */
typedef struct {
- int row; /* nb row */
- int col; /* nb col */
- int maxcol;
- 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 */
- int ocy; /* old cursor row */
- int top; /* top scroll limit */
- int bot; /* bottom scroll limit */
- int mode; /* terminal mode flags */
- int esc; /* escape state flags */
- char trantbl[4]; /* charset table translation */
- int charset; /* current charset */
- int icharset; /* selected charset for sequence */
+ int row; /* nb row */
+ int col; /* nb col */
+ Line *line; /* screen */
+ Line *alt; /* alternate screen */
+ int *dirty; /* dirtyness of lines */
+ TCursor c; /* cursor */
+ int ocx; /* old cursor col */
+ int ocy; /* old cursor row */
+ int top; /* top scroll limit */
+ int bot; /* bottom scroll limit */
+ int mode; /* terminal mode flags */
+ int esc; /* escape state flags */
+ char trantbl[4]; /* charset table translation */
+ int charset; /* current charset */
+ int icharset; /* selected charset for sequence */
int *tabs;
- struct timespec last_ximspot_update;
} Term;
/* CSI Escape sequence structs */
@@ -169,7 +148,6 @@ typedef struct {
} STREscape;
static void execsh(char *, char **);
-static char *getcwd_by_pid(pid_t pid);
static void stty(char **);
static void sigchld(int);
static void ttywriteraw(const char *, size_t);
@@ -201,20 +179,20 @@ 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 tsetattr(const int *, int);
-static void tsetchar(Rune, const Glyph *, int, int);
+static void tscrollup(int, int);
+static void tscrolldown(int, int);
+static void tsetattr(int *, int);
+static void tsetchar(Rune, Glyph *, int, int);
static void tsetdirt(int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
-static void tsetmode(int, int, const int *, int);
+static void tsetmode(int, int, int *, int);
static int twrite(const char *, int, int);
static void tfulldirt(void);
static void tcontrolcode(uchar);
static void tdectest(char);
static void tdefutf8(char);
-static int32_t tdefcolor(const int *, int *, int);
+static int32_t tdefcolor(int *, int *, int);
static void tdeftran(char);
static void tstrsequence(uchar);
@@ -224,7 +202,6 @@ static void selnormalize(void);
static void selscroll(int, int);
static void selsnap(int *, int *, int);
-static size_t utf8decode(const char *, Rune *, size_t);
static Rune utf8decodebyte(char, size_t *);
static char utf8encodebyte(Rune, size_t);
static size_t utf8validate(Rune *, size_t);
@@ -243,11 +220,10 @@ static int iofd = 1;
static int cmdfd;
static pid_t pid;
-static const uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
-static const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
-static const Rune utfmin[UTF_SIZ + 1] = {0, 0, 0x80, 0x800, 0x10000};
-static const Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF,
- 0x10FFFF};
+static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
+static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
+static Rune utfmin[UTF_SIZ + 1] = {0, 0, 0x80, 0x800, 0x10000};
+static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
ssize_t xwrite(int fd, const char *s, size_t len) {
size_t aux = len;
@@ -280,13 +256,11 @@ void *xrealloc(void *p, size_t len) {
return p;
}
-char *xstrdup(const char *s) {
- char *p;
-
- if ((p = strdup(s)) == NULL)
+char *xstrdup(char *s) {
+ if ((s = strdup(s)) == NULL)
die("strdup: %s\n", strerror(errno));
- return p;
+ return s;
}
size_t utf8decode(const char *c, Rune *u, size_t clen) {
@@ -403,22 +377,10 @@ void selinit(void) {
int 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 == ' ')
- --i;
-
- return i;
-}
-
-int tlinehistlen(int y) {
- int i = term.col;
-
- if (TLINE_HIST(y)[i - 1].mode & ATTR_WRAP)
- return i;
-
- while (i > 0 && TLINE_HIST(y)[i - 1].u == ' ')
+ while (i > 0 && term.line[y][i - 1].u == ' ')
--i;
return i;
@@ -508,7 +470,7 @@ int selected(int x, int y) {
void selsnap(int *x, int *y, int direction) {
int newx, newy, xt, yt;
int delim, prevdelim;
- const Glyph *gp, *prevgp;
+ Glyph *gp, *prevgp;
switch (sel.snap) {
case SNAP_WORD:
@@ -516,7 +478,7 @@ void 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;
@@ -531,14 +493,14 @@ void 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)))
@@ -559,13 +521,13 @@ void 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 & ATTR_WRAP)) {
+ 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 & ATTR_WRAP)) {
+ if (!(term.line[*y][term.col - 1].mode & ATTR_WRAP)) {
break;
}
}
@@ -577,7 +539,7 @@ void selsnap(int *x, int *y, int direction) {
char *getsel(void) {
char *str, *ptr;
int y, bufsize, lastx, linelen;
- const Glyph *gp, *last;
+ Glyph *gp, *last;
if (sel.ob.x == -1)
return NULL;
@@ -593,13 +555,13 @@ char *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;
@@ -725,7 +687,7 @@ void stty(char **args) {
perror("Couldn't call stty");
}
-int ttynew(const char *line, char *cmd, const char *out, char **args) {
+int ttynew(char *line, char *cmd, char *out, char **args) {
int m, s;
if (out) {
@@ -754,15 +716,14 @@ int ttynew(const char *line, char *cmd, const char *out, char **args) {
break;
case 0:
close(iofd);
- close(m);
setsid(); /* create a new process group */
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
if (ioctl(s, TIOCSCTTY, NULL) < 0)
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
- if (s > 2)
- close(s);
+ close(s);
+ close(m);
#ifdef __OpenBSD__
if (pledge("stdio getpw proc exec", NULL) == -1)
die("pledge\n");
@@ -799,14 +760,12 @@ size_t ttyread(void) {
if (buflen > 0)
memmove(buf, buf + written, buflen);
+ wlneeddraw();
return ret;
}
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);
@@ -923,6 +882,8 @@ void tsetdirt(int top, int bot) {
for (i = top; i <= bot; i++)
term.dirty[i] = 1;
+
+ wlneeddraw();
}
void tsetdirtattr(int attr) {
@@ -979,13 +940,10 @@ void treset(void) {
void tnew(int col, int row) {
term = (Term){.c = {.attr = {.fg = defaultfg, .bg = defaultbg}}};
- clock_gettime(CLOCK_MONOTONIC, &term.last_ximspot_update);
tresize(col, row);
treset();
}
-int tisaltscr(void) { return IS_SET(MODE_ALTSCREEN); }
-
void tswapscreen(void) {
Line *tmp = term.line;
@@ -995,66 +953,12 @@ void tswapscreen(void) {
tfulldirt();
}
-void newterm(const Arg *a) {
- switch (fork()) {
- case -1:
- die("fork failed: %s\n", strerror(errno));
- break;
- case 0:
- chdir(getcwd_by_pid(pid));
- execlp("st", "./st", NULL);
- break;
- }
-}
-
-static char *getcwd_by_pid(pid_t pid) {
- char buf[32];
- snprintf(buf, sizeof buf, "/proc/%d/cwd", pid);
- return realpath(buf, NULL);
-}
-
-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) {
+void 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);
@@ -1067,22 +971,12 @@ void tscrolldown(int orig, int n, int copyhist) {
selscroll(orig, n);
}
-void tscrollup(int orig, int n, int copyhist) {
+void 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);
@@ -1127,7 +1021,7 @@ void tnewline(int first_col) {
int y = term.c.y;
if (y == term.bot) {
- tscrollup(term.top, 1, 1);
+ tscrollup(term.top, 1);
} else {
y++;
}
@@ -1182,8 +1076,8 @@ void tmoveto(int x, int y) {
term.c.y = LIMIT(y, miny, maxy);
}
-void tsetchar(Rune u, const Glyph *attr, int x, int y) {
- static const char *vt100_0[62] = {
+void tsetchar(Rune u, Glyph *attr, int x, int y) {
+ static char *vt100_0[62] = {
/* 0x41 - 0x7e */
"↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
@@ -1215,9 +1109,6 @@ void tsetchar(Rune u, const Glyph *attr, int x, int y) {
term.dirty[y] = 1;
term.line[y][x] = *attr;
term.line[y][x].u = u;
-
- if (isboxdraw(u))
- term.line[y][x].mode |= ATTR_BOXDRAW;
}
void tclearregion(int x1, int y1, int x2, int y2) {
@@ -1229,8 +1120,8 @@ void tclearregion(int x1, int y1, int x2, int y2) {
if (y1 > y2)
temp = y1, y1 = y2, y2 = temp;
- LIMIT(x1, 0, term.maxcol - 1);
- LIMIT(x2, 0, term.maxcol - 1);
+ LIMIT(x1, 0, term.col - 1);
+ LIMIT(x2, 0, term.col - 1);
LIMIT(y1, 0, term.row - 1);
LIMIT(y2, 0, term.row - 1);
@@ -1280,15 +1171,15 @@ void tinsertblank(int n) {
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 tdefcolor(const int *attr, int *npar, int l) {
+int32_t tdefcolor(int *attr, int *npar, int l) {
int32_t idx = -1;
uint r, g, b;
@@ -1332,7 +1223,7 @@ int32_t tdefcolor(const int *attr, int *npar, int l) {
return idx;
}
-void tsetattr(const int *attr, int l) {
+void tsetattr(int *attr, int l) {
int i;
int32_t idx;
@@ -1438,9 +1329,8 @@ void tsetscroll(int t, int b) {
term.bot = b;
}
-void tsetmode(int priv, int set, const int *args, int narg) {
- int alt;
- const int *lim;
+void tsetmode(int priv, int set, int *args, int narg) {
+ int alt, *lim;
for (lim = args + narg; args < lim; ++args) {
if (priv) {
@@ -1688,11 +1578,11 @@ void 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);
@@ -1799,15 +1689,7 @@ void strhandle(void) {
case ']': /* OSC -- Operating System Command */
switch (par) {
case 0:
- if (narg > 1) {
- xsettitle(strescseq.args[1]);
- xseticontitle(strescseq.args[1]);
- }
- return;
case 1:
- if (narg > 1)
- xseticontitle(strescseq.args[1]);
- return;
case 2:
if (narg > 1)
xsettitle(strescseq.args[1]);
@@ -1823,24 +1705,13 @@ void strhandle(void) {
}
}
return;
- case 4: /* color set */
- case 10: /* foreground set */
- case 11: /* background set */
- case 12: /* cursor color */
- if ((par == 4 && narg < 3) || narg < 2)
+ case 4: /* color set */
+ if (narg < 3)
break;
- p = strescseq.args[((par == 4) ? 2 : 1)];
+ p = strescseq.args[2];
/* FALLTHROUGH */
case 104: /* color reset, here p = NULL */
- if (par == 10)
- j = defaultfg;
- else if (par == 11)
- j = defaultbg;
- else if (par == 12)
- j = defaultcs;
- else
- j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
-
+ j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1)
return; /* color reset without parameter */
@@ -1851,8 +1722,6 @@ void strhandle(void) {
* TODO if defaultbg color is changed, borders
* are dirty
*/
- if (j == defaultbg)
- xclearwin();
redraw();
}
return;
@@ -1932,79 +1801,6 @@ void tprinter(char *s, size_t len) {
}
}
-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;
- /* modify externalpipe patch to pipe history too */
- for (n = 0; n <= HISTSIZE + 2; n++) {
- bp = TLINE_HIST(n);
- lastpos = MIN(tlinehistlen(n) + 1, term.col) - 1;
- if (lastpos < 0)
- break;
- if (lastpos == 0)
- continue;
- end = &bp[lastpos + 1];
- for (; bp < end; ++bp)
- if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
- break;
- if ((newline = TLINE_HIST(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 iso14755(const Arg *arg) {
- FILE *p;
- char *us, *e, codepoint[9], uc[UTF_SIZ];
- unsigned long utf32;
-
- if (!(p = popen(ISO14755CMD, "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; }
void printscreen(const Arg *arg) { tdump(); }
@@ -2022,7 +1818,7 @@ void tdumpsel(void) {
void tdumpline(int n) {
char buf[UTF_SIZ];
- const Glyph *bp, *end;
+ Glyph *bp, *end;
bp = &term.line[n][0];
end = &bp[MIN(tlinelen(n), term.col) - 1];
@@ -2236,7 +2032,7 @@ int 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);
}
@@ -2249,7 +2045,7 @@ int 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);
}
@@ -2417,10 +2213,6 @@ check_control_code:
if (width == 2) {
gp->mode |= ATTR_WIDE;
if (term.c.x + 1 < term.col) {
- if (gp[1].mode == ATTR_WIDE && term.c.x + 2 < term.col) {
- gp[2].u = ' ';
- gp[2].mode &= ~ATTR_WDUMMY;
- }
gp[1].u = '\0';
gp[1].mode = ATTR_WDUMMY;
}
@@ -2463,19 +2255,12 @@ int twrite(const char *buf, int buflen, int show_ctrl) {
}
void tresize(int col, int row) {
- int i, j;
- int tmp;
- int minrow, mincol;
+ int i;
+ int minrow = MIN(row, term.row);
+ int mincol = MIN(col, term.col);
int *bp;
TCursor c;
- tmp = col;
- if (!term.maxcol)
- term.maxcol = term.col;
- col = MAX(col, term.maxcol);
- minrow = MIN(row, term.row);
- mincol = MIN(col, term.maxcol);
-
if (col < 1 || row < 1) {
fprintf(stderr, "tresize: error resizing to %dx%d\n", col, row);
return;
@@ -2506,14 +2291,6 @@ void 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));
@@ -2525,18 +2302,17 @@ void tresize(int col, int row) {
term.line[i] = xmalloc(col * sizeof(Glyph));
term.alt[i] = xmalloc(col * sizeof(Glyph));
}
+ if (col > term.col) {
+ bp = term.tabs + term.col;
- if (col > term.maxcol) {
- bp = term.tabs + term.maxcol;
- memset(bp, 0, sizeof(*term.tabs) * (col - term.maxcol));
+ memset(bp, 0, sizeof(*term.tabs) * (col - term.col));
while (--bp > term.tabs && !*bp)
/* nothing */;
for (bp += tabspaces; bp < term.tabs + col; bp += tabspaces)
*bp = 1;
}
/* update terminal size */
- term.col = tmp;
- term.maxcol = col;
+ term.col = col;
term.row = row;
/* reset scrolling region */
tsetscroll(0, row - 1);
@@ -2566,7 +2342,7 @@ void 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);
}
}
@@ -2585,22 +2361,14 @@ void 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();
-
- struct timespec now;
- clock_gettime(CLOCK_MONOTONIC, &now);
- if (ximspot_update_interval &&
- TIMEDIFF(now, term.last_ximspot_update) > ximspot_update_interval) {
- xximspot(term.ocx, term.ocy);
- term.last_ximspot_update = now;
- }
+ /* xximspot(term.ocx, term.ocy); */ /* disabled in wayland brach */
}
void redraw(void) {
tfulldirt();
- draw();
+ /* draw();*/ /* Disabled in wayland */
}