Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
st.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add MC sequence
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
c59bf1d
..
314bf3f
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-134,6
+134,7
@@
enum term_mode {
MODE_MOUSEX10 = 131072,
MODE_MOUSEMANY = 262144,
MODE_BRCKTPASTE = 524288,
MODE_MOUSEX10 = 131072,
MODE_MOUSEMANY = 262144,
MODE_BRCKTPASTE = 524288,
+ MODE_PRINT = 1048576,
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
@@
-441,6
+442,7
@@
static int isfullutf8(char *, int);
static ssize_t xwrite(int, char *, size_t);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
static ssize_t xwrite(int, char *, size_t);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
+static char *xstrdup(char *s);
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
@@
-468,7
+470,7
@@
static STREscape strescseq;
static int cmdfd;
static pid_t pid;
static Selection sel;
static int cmdfd;
static pid_t pid;
static Selection sel;
-static int iofd = -1;
+static int iofd;
static char **opt_cmd = NULL;
static char *opt_io = NULL;
static char *opt_title = NULL;
static char **opt_cmd = NULL;
static char *opt_io = NULL;
static char *opt_title = NULL;
@@
-529,6
+531,16
@@
xrealloc(void *p, size_t len) {
return p;
}
return p;
}
+char *
+xstrdup(char *s) {
+ char *p = strdup(s);
+
+ if (!p)
+ die("Out of memory\n");
+
+ return p;
+}
+
int
utf8decode(char *s, long *u) {
uchar c;
int
utf8decode(char *s, long *u) {
uchar c;
@@
-953,11
+965,12
@@
selcopy(void) {
/* append every set & selected glyph to the selection */
for(y = sel.nb.y; y < sel.ne.y + 1; y++) {
gp = &term.line[y][0];
/* append every set & selected glyph to the selection */
for(y = sel.nb.y; y < sel.ne.y + 1; y++) {
gp = &term.line[y][0];
- last = gp + term.col;
+ last = &gp[term.col-1];
- while(--last >= gp && !(selected(last - gp, y) && \
- strcmp(last->c, " ") != 0))
- /* nothing */;
+ while(last >= gp && !(selected(last - gp, y) &&
+ strcmp(last->c, " ") != 0)) {
+ --last;
+ }
for(x = 0; gp <= last; x++, ++gp) {
if(!selected(x, y) || (gp->mode & ATTR_WDUMMY))
for(x = 0; gp <= last; x++, ++gp) {
if(!selected(x, y) || (gp->mode & ATTR_WDUMMY))
@@
-1244,6
+1257,7
@@
ttynew(void) {
cmdfd = m;
signal(SIGCHLD, sigchld);
if(opt_io) {
cmdfd = m;
signal(SIGCHLD, sigchld);
if(opt_io) {
+ term.mode |= MODE_PRINT;
iofd = (!strcmp(opt_io, "-")) ?
STDOUT_FILENO :
open(opt_io, O_WRONLY | O_CREAT, 0666);
iofd = (!strcmp(opt_io, "-")) ?
STDOUT_FILENO :
open(opt_io, O_WRONLY | O_CREAT, 0666);
@@
-1967,6
+1981,18
@@
csihandle(void) {
DEFAULT(csiescseq.arg[0], 1);
tmoveto(term.c.x, term.c.y+csiescseq.arg[0]);
break;
DEFAULT(csiescseq.arg[0], 1);
tmoveto(term.c.x, term.c.y+csiescseq.arg[0]);
break;
+ case 'i': /* MC -- Media Copy */
+ switch(csiescseq.arg[0]) {
+ case 0:
+ case 1:
+ case 4:
+ term.mode &= ~MODE_PRINT;
+ break;
+ case 5:
+ term.mode |= MODE_PRINT;
+ break;
+ }
+ break;
case 'c': /* DA -- Device Attributes */
if(csiescseq.arg[0] == 0)
ttywrite(VT102ID, sizeof(VT102ID) - 1);
case 'c': /* DA -- Device Attributes */
if(csiescseq.arg[0] == 0)
ttywrite(VT102ID, sizeof(VT102ID) - 1);
@@
-2320,7
+2346,7
@@
tputc(char *c, int len) {
width = wcwidth(u8char);
}
width = wcwidth(u8char);
}
- if(iofd != -1) {
+ if(IS_SET(MODE_PRINT) && iofd != -1) {
if(xwrite(iofd, c, len) < 0) {
fprintf(stderr, "Error writing in %s:%s\n",
opt_io, strerror(errno));
if(xwrite(iofd, c, len) < 0) {
fprintf(stderr, "Error writing in %s:%s\n",
opt_io, strerror(errno));
@@
-3297,8
+3323,6
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
XftDrawRect(xw.draw, fg, winx, winy + font->ascent + 1,
width, 1);
}
XftDrawRect(xw.draw, fg, winx, winy + font->ascent + 1,
width, 1);
}
- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, winx, winy, width,
- CEIL((font->ascent + font->descent) * chscale), winx, winy);
/* Reset clip to none. */
XftDrawSetClip(xw.draw, 0);
/* Reset clip to none. */
XftDrawSetClip(xw.draw, 0);
@@
-3397,6
+3421,8
@@
redraw(int timeout) {
void
draw(void) {
drawregion(0, 0, term.col, term.row);
void
draw(void) {
drawregion(0, 0, term.col, term.row);
+ XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w,
+ xw.h, 0, 0);
XSetForeground(xw.dpy, dc.gc,
dc.col[IS_SET(MODE_REVERSE)?
defaultfg : defaultbg].pixel);
XSetForeground(xw.dpy, dc.gc,
dc.col[IS_SET(MODE_REVERSE)?
defaultfg : defaultbg].pixel);
@@
-3788,7
+3814,7
@@
main(int argc, char *argv[]) {
if(argc > 1) {
opt_cmd = &argv[1];
if(argv[1] != NULL && opt_title == NULL) {
if(argc > 1) {
opt_cmd = &argv[1];
if(argv[1] != NULL && opt_title == NULL) {
- titles = strdup(argv[1]);
+ titles = xstrdup(argv[1]);
opt_title = basename(titles);
}
}
opt_title = basename(titles);
}
}