Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
remove confusing SERRNO macro
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
6fef7f3
..
e017940
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-36,10
+36,6
@@
char *argv0;
#define Glyph Glyph_
#define Font Font_
#define Glyph Glyph_
#define Font Font_
-#define Draw XftDraw *
-#define Colour XftColor
-#define Colourmap Colormap
-#define Rectangle XRectangle
#if defined(__linux)
#include <pty.h>
#if defined(__linux)
#include <pty.h>
@@
-69,7
+65,6
@@
char *argv0;
#define REDRAW_TIMEOUT (80*1000) /* 80 ms */
/* macros */
#define REDRAW_TIMEOUT (80*1000) /* 80 ms */
/* macros */
-#define SERRNO strerror(errno)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a[0]))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a[0]))
@@
-180,6
+175,10
@@
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned short ushort;
+typedef XftDraw *Draw;
+typedef XftColor Colour;
+typedef Colormap Colourmap;
+
typedef struct {
char c[UTF_SIZ]; /* character code */
ushort mode; /* attribute flags */
typedef struct {
char c[UTF_SIZ]; /* character code */
ushort mode; /* attribute flags */
@@
-1181,7
+1180,7
@@
sigchld(int a) {
int stat = 0;
if(waitpid(pid, &stat, 0) < 0)
int stat = 0;
if(waitpid(pid, &stat, 0) < 0)
- die("Waiting for pid %hd failed: %s\n", pid,
SERRNO
);
+ die("Waiting for pid %hd failed: %s\n", pid,
strerror(errno)
);
if(WIFEXITED(stat)) {
exit(WEXITSTATUS(stat));
if(WIFEXITED(stat)) {
exit(WEXITSTATUS(stat));
@@
-1197,7
+1196,7
@@
ttynew(void) {
/* seems to work fine on linux, openbsd and freebsd */
if(openpty(&m, &s, NULL, NULL, &w) < 0)
/* seems to work fine on linux, openbsd and freebsd */
if(openpty(&m, &s, NULL, NULL, &w) < 0)
- die("openpty failed: %s\n",
SERRNO
);
+ die("openpty failed: %s\n",
strerror(errno)
);
switch(pid = fork()) {
case -1:
switch(pid = fork()) {
case -1:
@@
-1209,7
+1208,7
@@
ttynew(void) {
dup2(s, STDOUT_FILENO);
dup2(s, STDERR_FILENO);
if(ioctl(s, TIOCSCTTY, NULL) < 0)
dup2(s, STDOUT_FILENO);
dup2(s, STDERR_FILENO);
if(ioctl(s, TIOCSCTTY, NULL) < 0)
- die("ioctl TIOCSCTTY failed: %s\n",
SERRNO
);
+ die("ioctl TIOCSCTTY failed: %s\n",
strerror(errno)
);
close(s);
close(m);
execsh();
close(s);
close(m);
execsh();
@@
-1252,7
+1251,7
@@
ttyread(void) {
/* append read bytes to unprocessed bytes */
if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
/* append read bytes to unprocessed bytes */
if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
- die("Couldn't read from shell: %s\n",
SERRNO
);
+ die("Couldn't read from shell: %s\n",
strerror(errno)
);
/* process every complete utf8 char */
buflen += ret;
/* process every complete utf8 char */
buflen += ret;
@@
-1271,7
+1270,7
@@
ttyread(void) {
void
ttywrite(const char *s, size_t n) {
if(write(cmdfd, s, n) == -1)
void
ttywrite(const char *s, size_t n) {
if(write(cmdfd, s, n) == -1)
- die("write error on tty: %s\n",
SERRNO
);
+ die("write error on tty: %s\n",
strerror(errno)
);
}
void
}
void
@@
-1290,7
+1289,7
@@
ttyresize(void) {
w.ws_xpixel = xw.tw;
w.ws_ypixel = xw.th;
if(ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
w.ws_xpixel = xw.tw;
w.ws_ypixel = xw.th;
if(ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
- fprintf(stderr, "Couldn't set window size: %s\n",
SERRNO
);
+ fprintf(stderr, "Couldn't set window size: %s\n",
strerror(errno)
);
}
int
}
int
@@
-1855,7
+1854,10
@@
tsetmode(bool priv, bool set, int *args, int narg) {
MODBIT(term.mode, set, MODE_8BIT);
break;
case 1049: /* swap screen & set/restore cursor as xterm */
MODBIT(term.mode, set, MODE_8BIT);
break;
case 1049: /* swap screen & set/restore cursor as xterm */
+ if (!allowaltscreen)
+ break;
tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
+ /* FALLTHRU */
case 47: /* swap screen */
case 1047:
if (!allowaltscreen)
case 47: /* swap screen */
case 1047:
if (!allowaltscreen)
@@
-2315,10
+2317,7
@@
techo(char *buf, int len) {
for(; len > 0; buf++, len--) {
char c = *buf;
for(; len > 0; buf++, len--) {
char c = *buf;
- if(c == '\033') { /* escape */
- tputc("^", 1);
- tputc("[", 1);
- } else if(c < '\x20') { /* control code */
+ if(c < '\x20') { /* control code */
if(c != '\n' && c != '\r' && c != '\t') {
c |= '\x40';
tputc("^", 1);
if(c != '\n' && c != '\r' && c != '\t') {
c |= '\x40';
tputc("^", 1);
@@
-3107,7
+3106,7
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
FcCharSet *fccharset;
Colour *fg, *bg, *temp, revfg, revbg, truefg, truebg;
XRenderColor colfg, colbg;
FcCharSet *fccharset;
Colour *fg, *bg, *temp, revfg, revbg, truefg, truebg;
XRenderColor colfg, colbg;
- Rectangle r;
+
X
Rectangle r;
int oneatatime;
frcflags = FRC_NORMAL;
int oneatatime;
frcflags = FRC_NORMAL;
@@
-3737,8
+3736,8
@@
run(void) {
else
cresize(xw.fw, xw.fh);
else
cresize(xw.fw, xw.fh);
- gettimeofday(&lastblink, NULL);
gettimeofday(&last, NULL);
gettimeofday(&last, NULL);
+ lastblink = last;
for(xev = actionfps;;) {
long deltatime;
for(xev = actionfps;;) {
long deltatime;
@@
-3750,7
+3749,7
@@
run(void) {
if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv) < 0) {
if(errno == EINTR)
continue;
if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv) < 0) {
if(errno == EINTR)
continue;
- die("select failed: %s\n",
SERRNO
);
+ die("select failed: %s\n",
strerror(errno)
);
}
if(FD_ISSET(cmdfd, &rfd)) {
ttyread();
}
if(FD_ISSET(cmdfd, &rfd)) {
ttyread();
@@
-3773,7
+3772,7
@@
run(void) {
if(blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
tsetdirtattr(ATTR_BLINK);
term.mode ^= MODE_BLINK;
if(blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
tsetdirtattr(ATTR_BLINK);
term.mode ^= MODE_BLINK;
-
gettimeofday(&lastblink, NULL)
;
+
lastblink = now
;
dodraw = 1;
}
deltatime = TIMEDIFF(now, last);
dodraw = 1;
}
deltatime = TIMEDIFF(now, last);