|
|
@ -35,17 +35,13 @@ |
|
|
|
#define ESC_ARG_SIZ 16 |
|
|
|
#define ESC_ARG_SIZ 16 |
|
|
|
#define STR_BUF_SIZ ESC_BUF_SIZ |
|
|
|
#define STR_BUF_SIZ ESC_BUF_SIZ |
|
|
|
#define STR_ARG_SIZ ESC_ARG_SIZ |
|
|
|
#define STR_ARG_SIZ ESC_ARG_SIZ |
|
|
|
#define HISTSIZE 10000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* macros */ |
|
|
|
/* macros */ |
|
|
|
#define IS_SET(flag) ((term.mode & (flag)) != 0) |
|
|
|
#define IS_SET(flag) ((term.mode & (flag)) != 0) |
|
|
|
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177') |
|
|
|
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == 0x7f) |
|
|
|
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) |
|
|
|
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) |
|
|
|
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) |
|
|
|
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) |
|
|
|
#define ISDELIM(u) (u && wcschr(worddelimiters, u)) |
|
|
|
#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]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum term_mode { |
|
|
|
enum term_mode { |
|
|
|
MODE_WRAP = 1 << 0, |
|
|
|
MODE_WRAP = 1 << 0, |
|
|
@ -55,7 +51,6 @@ enum term_mode { |
|
|
|
MODE_ECHO = 1 << 4, |
|
|
|
MODE_ECHO = 1 << 4, |
|
|
|
MODE_PRINT = 1 << 5, |
|
|
|
MODE_PRINT = 1 << 5, |
|
|
|
MODE_UTF8 = 1 << 6, |
|
|
|
MODE_UTF8 = 1 << 6, |
|
|
|
MODE_SIXEL = 1 << 7, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
enum cursor_movement { |
|
|
|
enum cursor_movement { |
|
|
@ -82,12 +77,11 @@ enum charset { |
|
|
|
enum escape_state { |
|
|
|
enum escape_state { |
|
|
|
ESC_START = 1, |
|
|
|
ESC_START = 1, |
|
|
|
ESC_CSI = 2, |
|
|
|
ESC_CSI = 2, |
|
|
|
ESC_STR = 4, /* OSC, PM, APC */ |
|
|
|
ESC_STR = 4, /* DCS, OSC, PM, APC */ |
|
|
|
ESC_ALTCHARSET = 8, |
|
|
|
ESC_ALTCHARSET = 8, |
|
|
|
ESC_STR_END = 16, /* a final string was encountered */ |
|
|
|
ESC_STR_END = 16, /* a final string was encountered */ |
|
|
|
ESC_TEST = 32, /* Enter in test mode */ |
|
|
|
ESC_TEST = 32, /* Enter in test mode */ |
|
|
|
ESC_UTF8 = 64, |
|
|
|
ESC_UTF8 = 64, |
|
|
|
ESC_DCS =128, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
@ -121,9 +115,6 @@ typedef struct { |
|
|
|
int col; /* nb col */ |
|
|
|
int col; /* nb col */ |
|
|
|
Line *line; /* screen */ |
|
|
|
Line *line; /* screen */ |
|
|
|
Line *alt; /* alternate screen */ |
|
|
|
Line *alt; /* alternate screen */ |
|
|
|
Line hist[HISTSIZE]; /* history buffer */ |
|
|
|
|
|
|
|
int histi; /* history index */ |
|
|
|
|
|
|
|
int scr; /* scroll back */ |
|
|
|
|
|
|
|
int *dirty; /* dirtyness of lines */ |
|
|
|
int *dirty; /* dirtyness of lines */ |
|
|
|
TCursor c; /* cursor */ |
|
|
|
TCursor c; /* cursor */ |
|
|
|
int ocx; /* old cursor col */ |
|
|
|
int ocx; /* old cursor col */ |
|
|
@ -136,6 +127,7 @@ typedef struct { |
|
|
|
int charset; /* current charset */ |
|
|
|
int charset; /* current charset */ |
|
|
|
int icharset; /* selected charset for sequence */ |
|
|
|
int icharset; /* selected charset for sequence */ |
|
|
|
int *tabs; |
|
|
|
int *tabs; |
|
|
|
|
|
|
|
Rune lastc; /* last printed char outside of sequence, 0 if control */ |
|
|
|
} Term; |
|
|
|
} Term; |
|
|
|
|
|
|
|
|
|
|
|
/* CSI Escape sequence structs */ |
|
|
|
/* CSI Escape sequence structs */ |
|
|
@ -192,8 +184,8 @@ static void tnewline(int); |
|
|
|
static void tputtab(int); |
|
|
|
static void tputtab(int); |
|
|
|
static void tputc(Rune); |
|
|
|
static void tputc(Rune); |
|
|
|
static void treset(void); |
|
|
|
static void treset(void); |
|
|
|
static void tscrollup(int, int, int); |
|
|
|
static void tscrollup(int, int); |
|
|
|
static void tscrolldown(int, int, int); |
|
|
|
static void tscrolldown(int, int); |
|
|
|
static void tsetattr(int *, int); |
|
|
|
static void tsetattr(int *, int); |
|
|
|
static void tsetchar(Rune, Glyph *, int, int); |
|
|
|
static void tsetchar(Rune, Glyph *, int, int); |
|
|
|
static void tsetdirt(int, int); |
|
|
|
static void tsetdirt(int, int); |
|
|
@ -373,7 +365,8 @@ static const char base64_digits[] = { |
|
|
|
char |
|
|
|
char |
|
|
|
base64dec_getc(const char **src) |
|
|
|
base64dec_getc(const char **src) |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (**src && !isprint(**src)) (*src)++; |
|
|
|
while (**src && !isprint(**src)) |
|
|
|
|
|
|
|
(*src)++; |
|
|
|
return **src ? *((*src)++) : '='; /* emulate padding if string ends */ |
|
|
|
return **src ? *((*src)++) : '='; /* emulate padding if string ends */ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -421,10 +414,10 @@ tlinelen(int y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i = term.col; |
|
|
|
int i = term.col; |
|
|
|
|
|
|
|
|
|
|
|
if (TLINE(y)[i - 1].mode & ATTR_WRAP) |
|
|
|
if (term.line[y][i - 1].mode & ATTR_WRAP) |
|
|
|
return i; |
|
|
|
return i; |
|
|
|
|
|
|
|
|
|
|
|
while (i > 0 && TLINE(y)[i - 1].u == ' ') |
|
|
|
while (i > 0 && term.line[y][i - 1].u == ' ') |
|
|
|
--i; |
|
|
|
--i; |
|
|
|
|
|
|
|
|
|
|
|
return i; |
|
|
|
return i; |
|
|
@ -533,7 +526,7 @@ selsnap(int *x, int *y, int direction) |
|
|
|
* Snap around if the word wraps around at the end or |
|
|
|
* Snap around if the word wraps around at the end or |
|
|
|
* beginning of a line. |
|
|
|
* beginning of a line. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
prevgp = &TLINE(*y)[*x]; |
|
|
|
prevgp = &term.line[*y][*x]; |
|
|
|
prevdelim = ISDELIM(prevgp->u); |
|
|
|
prevdelim = ISDELIM(prevgp->u); |
|
|
|
for (;;) { |
|
|
|
for (;;) { |
|
|
|
newx = *x + direction; |
|
|
|
newx = *x + direction; |
|
|
@ -548,14 +541,14 @@ selsnap(int *x, int *y, int direction) |
|
|
|
yt = *y, xt = *x; |
|
|
|
yt = *y, xt = *x; |
|
|
|
else |
|
|
|
else |
|
|
|
yt = newy, xt = newx; |
|
|
|
yt = newy, xt = newx; |
|
|
|
if (!(TLINE(yt)[xt].mode & ATTR_WRAP)) |
|
|
|
if (!(term.line[yt][xt].mode & ATTR_WRAP)) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (newx >= tlinelen(newy)) |
|
|
|
if (newx >= tlinelen(newy)) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
gp = &TLINE(newy)[newx]; |
|
|
|
gp = &term.line[newy][newx]; |
|
|
|
delim = ISDELIM(gp->u); |
|
|
|
delim = ISDELIM(gp->u); |
|
|
|
if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim |
|
|
|
if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim |
|
|
|
|| (delim && gp->u != prevgp->u))) |
|
|
|
|| (delim && gp->u != prevgp->u))) |
|
|
@ -576,14 +569,14 @@ selsnap(int *x, int *y, int direction) |
|
|
|
*x = (direction < 0) ? 0 : term.col - 1; |
|
|
|
*x = (direction < 0) ? 0 : term.col - 1; |
|
|
|
if (direction < 0) { |
|
|
|
if (direction < 0) { |
|
|
|
for (; *y > 0; *y += direction) { |
|
|
|
for (; *y > 0; *y += direction) { |
|
|
|
if (!(TLINE(*y-1)[term.col-1].mode |
|
|
|
if (!(term.line[*y-1][term.col-1].mode |
|
|
|
& ATTR_WRAP)) { |
|
|
|
& ATTR_WRAP)) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (direction > 0) { |
|
|
|
} else if (direction > 0) { |
|
|
|
for (; *y < term.row-1; *y += direction) { |
|
|
|
for (; *y < term.row-1; *y += direction) { |
|
|
|
if (!(TLINE(*y)[term.col-1].mode |
|
|
|
if (!(term.line[*y][term.col-1].mode |
|
|
|
& ATTR_WRAP)) { |
|
|
|
& ATTR_WRAP)) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -614,13 +607,13 @@ getsel(void) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (sel.type == SEL_RECTANGULAR) { |
|
|
|
if (sel.type == SEL_RECTANGULAR) { |
|
|
|
gp = &TLINE(y)[sel.nb.x]; |
|
|
|
gp = &term.line[y][sel.nb.x]; |
|
|
|
lastx = sel.ne.x; |
|
|
|
lastx = sel.ne.x; |
|
|
|
} else { |
|
|
|
} 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; |
|
|
|
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 == ' ') |
|
|
|
while (last >= gp && last->u == ' ') |
|
|
|
--last; |
|
|
|
--last; |
|
|
|
|
|
|
|
|
|
|
@ -640,7 +633,8 @@ getsel(void) |
|
|
|
* st. |
|
|
|
* st. |
|
|
|
* FIXME: Fix the computer world. |
|
|
|
* FIXME: Fix the computer world. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if ((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP)) |
|
|
|
if ((y < sel.ne.y || lastx >= linelen) && |
|
|
|
|
|
|
|
(!(last->mode & ATTR_WRAP) || sel.type == SEL_RECTANGULAR)) |
|
|
|
*ptr++ = '\n'; |
|
|
|
*ptr++ = '\n'; |
|
|
|
} |
|
|
|
} |
|
|
|
*ptr = 0; |
|
|
|
*ptr = 0; |
|
|
@ -671,7 +665,7 @@ die(const char *errstr, ...) |
|
|
|
void |
|
|
|
void |
|
|
|
execsh(char *cmd, char **args) |
|
|
|
execsh(char *cmd, char **args) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *sh, *prog; |
|
|
|
char *sh, *prog, *arg; |
|
|
|
const struct passwd *pw; |
|
|
|
const struct passwd *pw; |
|
|
|
|
|
|
|
|
|
|
|
errno = 0; |
|
|
|
errno = 0; |
|
|
@ -685,13 +679,20 @@ execsh(char *cmd, char **args) |
|
|
|
if ((sh = getenv("SHELL")) == NULL) |
|
|
|
if ((sh = getenv("SHELL")) == NULL) |
|
|
|
sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd; |
|
|
|
sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd; |
|
|
|
|
|
|
|
|
|
|
|
if (args) |
|
|
|
if (args) { |
|
|
|
prog = args[0]; |
|
|
|
prog = args[0]; |
|
|
|
else if (utmp) |
|
|
|
arg = NULL; |
|
|
|
|
|
|
|
} else if (scroll) { |
|
|
|
|
|
|
|
prog = scroll; |
|
|
|
|
|
|
|
arg = utmp ? utmp : sh; |
|
|
|
|
|
|
|
} else if (utmp) { |
|
|
|
prog = utmp; |
|
|
|
prog = utmp; |
|
|
|
else |
|
|
|
arg = NULL; |
|
|
|
|
|
|
|
} else { |
|
|
|
prog = sh; |
|
|
|
prog = sh; |
|
|
|
DEFAULT(args, ((char *[]) {prog, NULL})); |
|
|
|
arg = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DEFAULT(args, ((char *[]) {prog, arg, NULL})); |
|
|
|
|
|
|
|
|
|
|
|
unsetenv("COLUMNS"); |
|
|
|
unsetenv("COLUMNS"); |
|
|
|
unsetenv("LINES"); |
|
|
|
unsetenv("LINES"); |
|
|
@ -729,7 +730,7 @@ sigchld(int a) |
|
|
|
die("child exited with status %d\n", WEXITSTATUS(stat)); |
|
|
|
die("child exited with status %d\n", WEXITSTATUS(stat)); |
|
|
|
else if (WIFSIGNALED(stat)) |
|
|
|
else if (WIFSIGNALED(stat)) |
|
|
|
die("child terminated due to signal %d\n", WTERMSIG(stat)); |
|
|
|
die("child terminated due to signal %d\n", WTERMSIG(stat)); |
|
|
|
exit(0); |
|
|
|
_exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
@ -822,30 +823,31 @@ ttyread(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static char buf[BUFSIZ]; |
|
|
|
static char buf[BUFSIZ]; |
|
|
|
static int buflen = 0; |
|
|
|
static int buflen = 0; |
|
|
|
int written; |
|
|
|
int ret, written; |
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* append read bytes to unprocessed bytes */ |
|
|
|
/* append read bytes to unprocessed bytes */ |
|
|
|
if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) |
|
|
|
ret = read(cmdfd, buf+buflen, LEN(buf)-buflen); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (ret) { |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
exit(0); |
|
|
|
|
|
|
|
case -1: |
|
|
|
die("couldn't read from shell: %s\n", strerror(errno)); |
|
|
|
die("couldn't read from shell: %s\n", strerror(errno)); |
|
|
|
|
|
|
|
default: |
|
|
|
buflen += ret; |
|
|
|
buflen += ret; |
|
|
|
|
|
|
|
|
|
|
|
written = twrite(buf, buflen, 0); |
|
|
|
written = twrite(buf, buflen, 0); |
|
|
|
buflen -= written; |
|
|
|
buflen -= written; |
|
|
|
/* keep any uncomplete utf8 char for the next call */ |
|
|
|
/* keep any incomplete UTF-8 byte sequence for the next call */ |
|
|
|
if (buflen > 0) |
|
|
|
if (buflen > 0) |
|
|
|
memmove(buf, buf + written, buflen); |
|
|
|
memmove(buf, buf + written, buflen); |
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
ttywrite(const char *s, size_t n, int may_echo) |
|
|
|
ttywrite(const char *s, size_t n, int may_echo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const char *next; |
|
|
|
const char *next; |
|
|
|
Arg arg = (Arg) { .i = term.scr }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kscrolldown(&arg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (may_echo && IS_SET(MODE_ECHO)) |
|
|
|
if (may_echo && IS_SET(MODE_ECHO)) |
|
|
|
twrite(s, n, 1); |
|
|
|
twrite(s, n, 1); |
|
|
@ -1057,53 +1059,13 @@ tswapscreen(void) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
kscrolldown(const Arg* a) |
|
|
|
tscrolldown(int orig, int n) |
|
|
|
{ |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
Line temp; |
|
|
|
Line temp; |
|
|
|
|
|
|
|
|
|
|
|
LIMIT(n, 0, term.bot-orig+1); |
|
|
|
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); |
|
|
|
tsetdirt(orig, term.bot-n); |
|
|
|
tclearregion(0, term.bot-n+1, term.col-1, term.bot); |
|
|
|
tclearregion(0, term.bot-n+1, term.col-1, term.bot); |
|
|
|
|
|
|
|
|
|
|
@ -1117,23 +1079,13 @@ tscrolldown(int orig, int n, int copyhist) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
tscrollup(int orig, int n, int copyhist) |
|
|
|
tscrollup(int orig, int n) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
Line temp; |
|
|
|
Line temp; |
|
|
|
|
|
|
|
|
|
|
|
LIMIT(n, 0, term.bot-orig+1); |
|
|
|
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); |
|
|
|
tclearregion(0, orig, term.col-1, orig+n-1); |
|
|
|
tsetdirt(orig+n, term.bot); |
|
|
|
tsetdirt(orig+n, term.bot); |
|
|
|
|
|
|
|
|
|
|
@ -1152,28 +1104,18 @@ selscroll(int orig, int n) |
|
|
|
if (sel.ob.x == -1) |
|
|
|
if (sel.ob.x == -1) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { |
|
|
|
if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) { |
|
|
|
if ((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { |
|
|
|
selclear(); |
|
|
|
|
|
|
|
} else if (BETWEEN(sel.nb.y, orig, term.bot)) { |
|
|
|
|
|
|
|
sel.ob.y += n; |
|
|
|
|
|
|
|
sel.oe.y += n; |
|
|
|
|
|
|
|
if (sel.ob.y < term.top || sel.ob.y > term.bot || |
|
|
|
|
|
|
|
sel.oe.y < term.top || sel.oe.y > term.bot) { |
|
|
|
selclear(); |
|
|
|
selclear(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sel.type == SEL_RECTANGULAR) { |
|
|
|
|
|
|
|
if (sel.ob.y < term.top) |
|
|
|
|
|
|
|
sel.ob.y = term.top; |
|
|
|
|
|
|
|
if (sel.oe.y > term.bot) |
|
|
|
|
|
|
|
sel.oe.y = term.bot; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (sel.ob.y < term.top) { |
|
|
|
|
|
|
|
sel.ob.y = term.top; |
|
|
|
|
|
|
|
sel.ob.x = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sel.oe.y > term.bot) { |
|
|
|
|
|
|
|
sel.oe.y = term.bot; |
|
|
|
|
|
|
|
sel.oe.x = term.col; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
selnormalize(); |
|
|
|
selnormalize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
@ -1182,7 +1124,7 @@ tnewline(int first_col) |
|
|
|
int y = term.c.y; |
|
|
|
int y = term.c.y; |
|
|
|
|
|
|
|
|
|
|
|
if (y == term.bot) { |
|
|
|
if (y == term.bot) { |
|
|
|
tscrollup(term.top, 1, 1); |
|
|
|
tscrollup(term.top, 1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
y++; |
|
|
|
y++; |
|
|
|
} |
|
|
|
} |
|
|
@ -1347,14 +1289,14 @@ void |
|
|
|
tinsertblankline(int n) |
|
|
|
tinsertblankline(int n) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (BETWEEN(term.c.y, term.top, term.bot)) |
|
|
|
if (BETWEEN(term.c.y, term.top, term.bot)) |
|
|
|
tscrolldown(term.c.y, n, 0); |
|
|
|
tscrolldown(term.c.y, n); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
tdeleteline(int n) |
|
|
|
tdeleteline(int n) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (BETWEEN(term.c.y, term.top, term.bot)) |
|
|
|
if (BETWEEN(term.c.y, term.top, term.bot)) |
|
|
|
tscrollup(term.c.y, n, 0); |
|
|
|
tscrollup(term.c.y, n); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int32_t |
|
|
|
int32_t |
|
|
@ -1704,6 +1646,12 @@ csihandle(void) |
|
|
|
if (csiescseq.arg[0] == 0) |
|
|
|
if (csiescseq.arg[0] == 0) |
|
|
|
ttywrite(vtiden, strlen(vtiden), 0); |
|
|
|
ttywrite(vtiden, strlen(vtiden), 0); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'b': /* REP -- if last char is printable print it <n> more times */ |
|
|
|
|
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
|
|
|
|
if (term.lastc) |
|
|
|
|
|
|
|
while (csiescseq.arg[0]-- > 0) |
|
|
|
|
|
|
|
tputc(term.lastc); |
|
|
|
|
|
|
|
break; |
|
|
|
case 'C': /* CUF -- Cursor <n> Forward */ |
|
|
|
case 'C': /* CUF -- Cursor <n> Forward */ |
|
|
|
case 'a': /* HPR -- Cursor <n> Forward */ |
|
|
|
case 'a': /* HPR -- Cursor <n> Forward */ |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
@ -1785,11 +1733,11 @@ csihandle(void) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'S': /* SU -- Scroll <n> line up */ |
|
|
|
case 'S': /* SU -- Scroll <n> line up */ |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
tscrollup(term.top, csiescseq.arg[0], 0); |
|
|
|
tscrollup(term.top, csiescseq.arg[0]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'T': /* SD -- Scroll <n> line down */ |
|
|
|
case 'T': /* SD -- Scroll <n> line down */ |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
tscrolldown(term.top, csiescseq.arg[0], 0); |
|
|
|
tscrolldown(term.top, csiescseq.arg[0]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'L': /* IL -- Insert <n> blank lines */ |
|
|
|
case 'L': /* IL -- Insert <n> blank lines */ |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
|
DEFAULT(csiescseq.arg[0], 1); |
|
|
@ -1827,7 +1775,7 @@ csihandle(void) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'n': /* DSR – Device Status Report (cursor position) */ |
|
|
|
case 'n': /* DSR – Device Status Report (cursor position) */ |
|
|
|
if (csiescseq.arg[0] == 6) { |
|
|
|
if (csiescseq.arg[0] == 6) { |
|
|
|
len = snprintf(buf, sizeof(buf),"\033[%i;%iR", |
|
|
|
len = snprintf(buf, sizeof(buf), "\033[%i;%iR", |
|
|
|
term.c.y+1, term.c.x+1); |
|
|
|
term.c.y+1, term.c.x+1); |
|
|
|
ttywrite(buf, len, 0); |
|
|
|
ttywrite(buf, len, 0); |
|
|
|
} |
|
|
|
} |
|
|
@ -1911,7 +1859,7 @@ strhandle(void) |
|
|
|
xsettitle(strescseq.args[1]); |
|
|
|
xsettitle(strescseq.args[1]); |
|
|
|
return; |
|
|
|
return; |
|
|
|
case 52: |
|
|
|
case 52: |
|
|
|
if (narg > 2) { |
|
|
|
if (narg > 2 && allowwindowops) { |
|
|
|
dec = base64dec(strescseq.args[2]); |
|
|
|
dec = base64dec(strescseq.args[2]); |
|
|
|
if (dec) { |
|
|
|
if (dec) { |
|
|
|
xsetsel(dec); |
|
|
|
xsetsel(dec); |
|
|
@ -1947,7 +1895,6 @@ strhandle(void) |
|
|
|
xsettitle(strescseq.args[0]); |
|
|
|
xsettitle(strescseq.args[0]); |
|
|
|
return; |
|
|
|
return; |
|
|
|
case 'P': /* DCS -- Device Control String */ |
|
|
|
case 'P': /* DCS -- Device Control String */ |
|
|
|
term.mode |= ESC_DCS; |
|
|
|
|
|
|
|
case '_': /* APC -- Application Program Command */ |
|
|
|
case '_': /* APC -- Application Program Command */ |
|
|
|
case '^': /* PM -- Privacy Message */ |
|
|
|
case '^': /* PM -- Privacy Message */ |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1979,59 +1926,6 @@ strparse(void) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
void |
|
|
|
strdump(void) |
|
|
|
strdump(void) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2123,7 +2017,7 @@ tdumpline(int n) |
|
|
|
bp = &term.line[n][0]; |
|
|
|
bp = &term.line[n][0]; |
|
|
|
end = &bp[MIN(tlinelen(n), term.col) - 1]; |
|
|
|
end = &bp[MIN(tlinelen(n), term.col) - 1]; |
|
|
|
if (bp != end || bp->u != ' ') { |
|
|
|
if (bp != end || bp->u != ' ') { |
|
|
|
for ( ;bp <= end; ++bp) |
|
|
|
for ( ; bp <= end; ++bp) |
|
|
|
tprinter(buf, utf8encode(bp->u, buf)); |
|
|
|
tprinter(buf, utf8encode(bp->u, buf)); |
|
|
|
} |
|
|
|
} |
|
|
|
tprinter("\n", 1); |
|
|
|
tprinter("\n", 1); |
|
|
@ -2194,12 +2088,9 @@ tdectest(char c) |
|
|
|
void |
|
|
|
void |
|
|
|
tstrsequence(uchar c) |
|
|
|
tstrsequence(uchar c) |
|
|
|
{ |
|
|
|
{ |
|
|
|
strreset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (c) { |
|
|
|
switch (c) { |
|
|
|
case 0x90: /* DCS -- Device Control String */ |
|
|
|
case 0x90: /* DCS -- Device Control String */ |
|
|
|
c = 'P'; |
|
|
|
c = 'P'; |
|
|
|
term.esc |= ESC_DCS; |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case 0x9f: /* APC -- Application Program Command */ |
|
|
|
case 0x9f: /* APC -- Application Program Command */ |
|
|
|
c = '_'; |
|
|
|
c = '_'; |
|
|
@ -2211,6 +2102,7 @@ tstrsequence(uchar c) |
|
|
|
c = ']'; |
|
|
|
c = ']'; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
strreset(); |
|
|
|
strescseq.type = c; |
|
|
|
strescseq.type = c; |
|
|
|
term.esc |= ESC_STR; |
|
|
|
term.esc |= ESC_STR; |
|
|
|
} |
|
|
|
} |
|
|
@ -2253,6 +2145,7 @@ tcontrolcode(uchar ascii) |
|
|
|
return; |
|
|
|
return; |
|
|
|
case '\032': /* SUB */ |
|
|
|
case '\032': /* SUB */ |
|
|
|
tsetchar('?', &term.c.attr, term.c.x, term.c.y); |
|
|
|
tsetchar('?', &term.c.attr, term.c.x, term.c.y); |
|
|
|
|
|
|
|
/* FALLTHROUGH */ |
|
|
|
case '\030': /* CAN */ |
|
|
|
case '\030': /* CAN */ |
|
|
|
csireset(); |
|
|
|
csireset(); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -2348,7 +2241,7 @@ eschandle(uchar ascii) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
case 'D': /* IND -- Linefeed */ |
|
|
|
case 'D': /* IND -- Linefeed */ |
|
|
|
if (term.c.y == term.bot) { |
|
|
|
if (term.c.y == term.bot) { |
|
|
|
tscrollup(term.top, 1, 1); |
|
|
|
tscrollup(term.top, 1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tmoveto(term.c.x, term.c.y+1); |
|
|
|
tmoveto(term.c.x, term.c.y+1); |
|
|
|
} |
|
|
|
} |
|
|
@ -2361,7 +2254,7 @@ eschandle(uchar ascii) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'M': /* RI -- Reverse index */ |
|
|
|
case 'M': /* RI -- Reverse index */ |
|
|
|
if (term.c.y == term.top) { |
|
|
|
if (term.c.y == term.top) { |
|
|
|
tscrolldown(term.top, 1, 1); |
|
|
|
tscrolldown(term.top, 1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tmoveto(term.c.x, term.c.y-1); |
|
|
|
tmoveto(term.c.x, term.c.y-1); |
|
|
|
} |
|
|
|
} |
|
|
@ -2407,16 +2300,14 @@ tputc(Rune u) |
|
|
|
Glyph *gp; |
|
|
|
Glyph *gp; |
|
|
|
|
|
|
|
|
|
|
|
control = ISCONTROL(u); |
|
|
|
control = ISCONTROL(u); |
|
|
|
if (!IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) { |
|
|
|
if (u < 127 || !IS_SET(MODE_UTF8)) { |
|
|
|
c[0] = u; |
|
|
|
c[0] = u; |
|
|
|
width = len = 1; |
|
|
|
width = len = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
len = utf8encode(u, c); |
|
|
|
len = utf8encode(u, c); |
|
|
|
if (!control && (width = wcwidth(u)) == -1) { |
|
|
|
if (!control && (width = wcwidth(u)) == -1) |
|
|
|
memcpy(c, "\357\277\275", 4); /* UTF_INVALID */ |
|
|
|
|
|
|
|
width = 1; |
|
|
|
width = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IS_SET(MODE_PRINT)) |
|
|
|
if (IS_SET(MODE_PRINT)) |
|
|
|
tprinter(c, len); |
|
|
|
tprinter(c, len); |
|
|
@ -2430,23 +2321,11 @@ tputc(Rune u) |
|
|
|
if (term.esc & ESC_STR) { |
|
|
|
if (term.esc & ESC_STR) { |
|
|
|
if (u == '\a' || u == 030 || u == 032 || u == 033 || |
|
|
|
if (u == '\a' || u == 030 || u == 032 || u == 033 || |
|
|
|
ISCONTROLC1(u)) { |
|
|
|
ISCONTROLC1(u)) { |
|
|
|
term.esc &= ~(ESC_START|ESC_STR|ESC_DCS); |
|
|
|
term.esc &= ~(ESC_START|ESC_STR); |
|
|
|
if (IS_SET(MODE_SIXEL)) { |
|
|
|
|
|
|
|
/* TODO: render sixel */; |
|
|
|
|
|
|
|
term.mode &= ~MODE_SIXEL; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
term.esc |= ESC_STR_END; |
|
|
|
term.esc |= ESC_STR_END; |
|
|
|
goto check_control_code; |
|
|
|
goto check_control_code; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (IS_SET(MODE_SIXEL)) { |
|
|
|
|
|
|
|
/* TODO: implement sixel mode */ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q') |
|
|
|
|
|
|
|
term.mode |= MODE_SIXEL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strescseq.len+len >= strescseq.siz) { |
|
|
|
if (strescseq.len+len >= strescseq.siz) { |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Here is a bug in terminals. If the user never sends |
|
|
|
* Here is a bug in terminals. If the user never sends |
|
|
@ -2483,6 +2362,8 @@ check_control_code: |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* control codes are not shown ever |
|
|
|
* control codes are not shown ever |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
if (!term.esc) |
|
|
|
|
|
|
|
term.lastc = 0; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} else if (term.esc & ESC_START) { |
|
|
|
} else if (term.esc & ESC_START) { |
|
|
|
if (term.esc & ESC_CSI) { |
|
|
|
if (term.esc & ESC_CSI) { |
|
|
@ -2513,7 +2394,7 @@ check_control_code: |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) |
|
|
|
if (selected(term.c.x, term.c.y)) |
|
|
|
selclear(); |
|
|
|
selclear(); |
|
|
|
|
|
|
|
|
|
|
|
gp = &term.line[term.c.y][term.c.x]; |
|
|
|
gp = &term.line[term.c.y][term.c.x]; |
|
|
@ -2532,6 +2413,7 @@ check_control_code: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tsetchar(u, &term.c.attr, term.c.x, term.c.y); |
|
|
|
tsetchar(u, &term.c.attr, term.c.x, term.c.y); |
|
|
|
|
|
|
|
term.lastc = u; |
|
|
|
|
|
|
|
|
|
|
|
if (width == 2) { |
|
|
|
if (width == 2) { |
|
|
|
gp->mode |= ATTR_WIDE; |
|
|
|
gp->mode |= ATTR_WIDE; |
|
|
@ -2555,7 +2437,7 @@ twrite(const char *buf, int buflen, int show_ctrl) |
|
|
|
int n; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < buflen; n += charsize) { |
|
|
|
for (n = 0; n < buflen; n += charsize) { |
|
|
|
if (IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) { |
|
|
|
if (IS_SET(MODE_UTF8)) { |
|
|
|
/* process a complete utf8 char */ |
|
|
|
/* process a complete utf8 char */ |
|
|
|
charsize = utf8decode(buf + n, &u, buflen - n); |
|
|
|
charsize = utf8decode(buf + n, &u, buflen - n); |
|
|
|
if (charsize == 0) |
|
|
|
if (charsize == 0) |
|
|
@ -2582,7 +2464,7 @@ twrite(const char *buf, int buflen, int show_ctrl) |
|
|
|
void |
|
|
|
void |
|
|
|
tresize(int col, int row) |
|
|
|
tresize(int col, int row) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i, j; |
|
|
|
int i; |
|
|
|
int minrow = MIN(row, term.row); |
|
|
|
int minrow = MIN(row, term.row); |
|
|
|
int mincol = MIN(col, term.col); |
|
|
|
int mincol = MIN(col, term.col); |
|
|
|
int *bp; |
|
|
|
int *bp; |
|
|
@ -2619,14 +2501,6 @@ tresize(int col, int row) |
|
|
|
term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty)); |
|
|
|
term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty)); |
|
|
|
term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs)); |
|
|
|
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 */ |
|
|
|
/* resize each row to new width, zero-pad if needed */ |
|
|
|
for (i = 0; i < minrow; i++) { |
|
|
|
for (i = 0; i < minrow; i++) { |
|
|
|
term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); |
|
|
|
term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); |
|
|
@ -2679,19 +2553,20 @@ void |
|
|
|
drawregion(int x1, int y1, int x2, int y2) |
|
|
|
drawregion(int x1, int y1, int x2, int y2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int y; |
|
|
|
int y; |
|
|
|
|
|
|
|
|
|
|
|
for (y = y1; y < y2; y++) { |
|
|
|
for (y = y1; y < y2; y++) { |
|
|
|
if (!term.dirty[y]) |
|
|
|
if (!term.dirty[y]) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
term.dirty[y] = 0; |
|
|
|
term.dirty[y] = 0; |
|
|
|
xdrawline(TLINE(y), x1, y, x2); |
|
|
|
xdrawline(term.line[y], x1, y, x2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
draw(void) |
|
|
|
draw(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int cx = term.c.x; |
|
|
|
int cx = term.c.x, ocx = term.ocx, ocy = term.ocy; |
|
|
|
|
|
|
|
|
|
|
|
if (!xstartdraw()) |
|
|
|
if (!xstartdraw()) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -2705,19 +2580,12 @@ draw(void) |
|
|
|
cx--; |
|
|
|
cx--; |
|
|
|
|
|
|
|
|
|
|
|
drawregion(0, 0, term.col, term.row); |
|
|
|
drawregion(0, 0, term.col, term.row); |
|
|
|
if (term.scr == 0) { |
|
|
|
|
|
|
|
// Draw current line to format ligatures properly.
|
|
|
|
|
|
|
|
xdrawline(term.line[term.c.y], 0, term.c.y, term.col); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], |
|
|
|
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], |
|
|
|
term.ocx, term.ocy, term.line[term.ocy][term.ocx]); |
|
|
|
term.ocx, term.ocy, term.line[term.ocy][term.ocx]); |
|
|
|
|
|
|
|
term.ocx = cx; |
|
|
|
// If cursor was on a transformed glyph, we need to redraw the previous line
|
|
|
|
term.ocy = term.c.y; |
|
|
|
if (term.ocy != term.c.y && (term.line[term.ocy][term.ocx].mode & ATTR_LIGA)) |
|
|
|
|
|
|
|
xdrawline(term.line[term.ocy], 0, term.ocy, term.col); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
term.ocx = cx, term.ocy = term.c.y; |
|
|
|
|
|
|
|
xfinishdraw(); |
|
|
|
xfinishdraw(); |
|
|
|
|
|
|
|
if (ocx != term.ocx || ocy != term.ocy) |
|
|
|
xximspot(term.ocx, term.ocy); |
|
|
|
xximspot(term.ocx, term.ocy); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|