Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Allow simpler stdout -f handling.
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
655d5a3
..
7852de0
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-291,7
+291,7
@@
static void ttywrite(const char *, size_t);
static void xdraws(char *, Glyph, int, int, int, int);
static void xhints(void);
static void xclear(int, int, int, int);
static void xdraws(char *, Glyph, int, int, int, int);
static void xhints(void);
static void xclear(int, int, int, int);
-static void xcopy();
+static void xcopy(
void
);
static void xdrawcursor(void);
static void xinit(void);
static void xloadcols(void);
static void xdrawcursor(void);
static void xinit(void);
static void xloadcols(void);
@@
-311,12
+311,13
@@
static void brelease(XEvent *);
static void bpress(XEvent *);
static void bmotion(XEvent *);
static void selnotify(XEvent *);
static void bpress(XEvent *);
static void bmotion(XEvent *);
static void selnotify(XEvent *);
+static void selclear(XEvent *);
static void selrequest(XEvent *);
static void selinit(void);
static inline bool selected(int, int);
static void selcopy(void);
static void selrequest(XEvent *);
static void selinit(void);
static inline bool selected(int, int);
static void selcopy(void);
-static void selpaste();
+static void selpaste(
void
);
static void selscroll(int, int);
static int utf8decode(char *, long *);
static void selscroll(int, int);
static int utf8decode(char *, long *);
@@
-336,6
+337,7
@@
static void (*handler[LASTEvent])(XEvent *) = {
[MotionNotify] = bmotion,
[ButtonPress] = bpress,
[ButtonRelease] = brelease,
[MotionNotify] = bmotion,
[ButtonPress] = bpress,
[ButtonRelease] = brelease,
+ [SelectionClear] = selclear,
[SelectionNotify] = selnotify,
[SelectionRequest] = selrequest,
};
[SelectionNotify] = selnotify,
[SelectionRequest] = selrequest,
};
@@
-549,6
+551,7
@@
bpress(XEvent *e) {
sel.mode = 1;
sel.ex = sel.bx = X2COL(e->xbutton.x);
sel.ey = sel.by = Y2ROW(e->xbutton.y);
sel.mode = 1;
sel.ex = sel.bx = X2COL(e->xbutton.x);
sel.ey = sel.by = Y2ROW(e->xbutton.y);
+ draw();
}
}
}
}
@@
-612,6
+615,14
@@
selpaste() {
XConvertSelection(xw.dpy, XA_PRIMARY, sel.xtarget, XA_PRIMARY, xw.win, CurrentTime);
}
XConvertSelection(xw.dpy, XA_PRIMARY, sel.xtarget, XA_PRIMARY, xw.win, CurrentTime);
}
+void selclear(XEvent *e) {
+ if(sel.bx == -1)
+ return;
+ sel.bx = -1;
+ tsetdirt(sel.b.y, sel.e.y);
+ draw();
+}
+
void
selrequest(XEvent *e) {
XSelectionRequestEvent *xsre;
void
selrequest(XEvent *e) {
XSelectionRequestEvent *xsre;
@@
-790,9
+801,15
@@
ttynew(void) {
close(s);
cmdfd = m;
signal(SIGCHLD, sigchld);
close(s);
cmdfd = m;
signal(SIGCHLD, sigchld);
- if(opt_io && !(fileio = fopen(opt_io, "w"))) {
- fprintf(stderr, "Error opening %s:%s\n",
- opt_io, strerror(errno));
+ if(opt_io) {
+ if(!strcmp(opt_io, "-")) {
+ fileio = stdout;
+ } else {
+ if(!(fileio = fopen(opt_io, "w"))) {
+ fprintf(stderr, "Error opening %s:%s\n",
+ opt_io, strerror(errno));
+ }
+ }
}
}
}
}
}
}
@@
-1116,7
+1133,8
@@
tsetattr(int *attr, int l) {
for(i = 0; i < l; i++) {
switch(attr[i]) {
case 0:
for(i = 0; i < l; i++) {
switch(attr[i]) {
case 0:
- term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD);
+ term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD \
+ | ATTR_ITALIC);
term.c.attr.fg = DefaultFG;
term.c.attr.bg = DefaultBG;
break;
term.c.attr.fg = DefaultFG;
term.c.attr.bg = DefaultBG;
break;
@@
-1554,8
+1572,10
@@
void
tputc(char *c) {
char ascii = *c;
tputc(char *c) {
char ascii = *c;
- if(fileio)
+ if(fileio)
{
putc(ascii, fileio);
putc(ascii, fileio);
+ fflush(fileio);
+ }
if(term.esc & ESC_START) {
if(term.esc & ESC_CSI) {
if(term.esc & ESC_START) {
if(term.esc & ESC_CSI) {
@@
-1949,8
+1969,7
@@
xinit(void) {
attrs.bit_gravity = NorthWestGravity;
attrs.event_mask = FocusChangeMask | KeyPressMask
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
attrs.bit_gravity = NorthWestGravity;
attrs.event_mask = FocusChangeMask | KeyPressMask
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
- | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask
- | EnterWindowMask | LeaveWindowMask;
+ | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
attrs.colormap = xw.cmap;
parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr);
attrs.colormap = xw.cmap;
parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr);
@@
-2036,7
+2055,6
@@
void
xcopy() {
XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}};
XdbeSwapBuffers(xw.dpy, swpinfo, 1);
xcopy() {
XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}};
XdbeSwapBuffers(xw.dpy, swpinfo, 1);
-
}
void
}
void
@@
-2059,7
+2077,7
@@
xdrawcursor(void) {
} else
xclear(oldx, oldy, oldx, oldy);
} else
xclear(oldx, oldy, oldx, oldy);
- xcopy(
oldx, oldy, 1, 1
);
+ xcopy();
/* draw the new one */
if(!(term.c.state & CURSOR_HIDE)) {
/* draw the new one */
if(!(term.c.state & CURSOR_HIDE)) {
@@
-2074,7
+2092,7
@@
xdrawcursor(void) {
oldx = term.c.x, oldy = term.c.y;
}
oldx = term.c.x, oldy = term.c.y;
}
- xcopy(
term.c.x, term.c.y, 1, 1
);
+ xcopy();
}
void
}
void