Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Simplify techo
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
d58af7d
..
e510565
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>
@@
-180,6
+176,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 */
@@
-1257,7
+1257,7
@@
ttyread(void) {
/* process every complete utf8 char */
buflen += ret;
ptr = buf;
/* process every complete utf8 char */
buflen += ret;
ptr = buf;
- while(
charsize = utf8decode(ptr, &unicodep, buflen
)) {
+ while(
(charsize = utf8decode(ptr, &unicodep, buflen)
)) {
utf8encode(unicodep, s, UTF_SIZ);
tputc(s, charsize);
ptr += charsize;
utf8encode(unicodep, s, UTF_SIZ);
tputc(s, charsize);
ptr += charsize;
@@
-1855,7
+1855,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
+2318,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);
@@
-3089,7
+3089,7
@@
xinit(void) {
xresettitle();
XMapWindow(xw.dpy, xw.win);
xhints();
xresettitle();
XMapWindow(xw.dpy, xw.win);
xhints();
- XSync(xw.dpy,
0
);
+ XSync(xw.dpy,
False
);
}
void
}
void
@@
-3107,7
+3107,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;
@@
-3440,7
+3440,6
@@
void
redraw(int timeout) {
struct timespec tv = {0, timeout * 1000};
redraw(int timeout) {
struct timespec tv = {0, timeout * 1000};
- tfulldirt();
draw();
if(timeout > 0) {
draw();
if(timeout > 0) {
@@
-3738,8
+3737,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;
@@
-3774,7
+3773,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);