diff options
author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-01-31 20:57:09 +0100 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-02-22 11:54:30 +0100 |
commit | 1f0d981bd7a1450ddfae3591c6e457253b3a6842 (patch) | |
tree | 439764c43f577fb59e7fa9b2dd4eb173436144cc | |
parent | cdb3b1892af40110660da8c3f6fc06b1b054fd12 (diff) | |
download | st-patched-1f0d981bd7a1450ddfae3591c6e457253b3a6842.tar.bz2 st-patched-1f0d981bd7a1450ddfae3591c6e457253b3a6842.tar.xz st-patched-1f0d981bd7a1450ddfae3591c6e457253b3a6842.zip |
Add MC sequence
This sequence control when the printer is enabled or disabled. This
sequence control the behaviour of the -o option.
-rw-r--r-- | st.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -134,6 +134,7 @@ enum term_mode { | |||
134 | MODE_MOUSEX10 = 131072, | 134 | MODE_MOUSEX10 = 131072, |
135 | MODE_MOUSEMANY = 262144, | 135 | MODE_MOUSEMANY = 262144, |
136 | MODE_BRCKTPASTE = 524288, | 136 | MODE_BRCKTPASTE = 524288, |
137 | MODE_PRINT = 1048576, | ||
137 | MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\ | 138 | MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\ |
138 | |MODE_MOUSEMANY, | 139 | |MODE_MOUSEMANY, |
139 | }; | 140 | }; |
@@ -469,7 +470,7 @@ static STREscape strescseq; | |||
469 | static int cmdfd; | 470 | static int cmdfd; |
470 | static pid_t pid; | 471 | static pid_t pid; |
471 | static Selection sel; | 472 | static Selection sel; |
472 | static int iofd = -1; | 473 | static int iofd; |
473 | static char **opt_cmd = NULL; | 474 | static char **opt_cmd = NULL; |
474 | static char *opt_io = NULL; | 475 | static char *opt_io = NULL; |
475 | static char *opt_title = NULL; | 476 | static char *opt_title = NULL; |
@@ -1256,6 +1257,7 @@ ttynew(void) { | |||
1256 | cmdfd = m; | 1257 | cmdfd = m; |
1257 | signal(SIGCHLD, sigchld); | 1258 | signal(SIGCHLD, sigchld); |
1258 | if(opt_io) { | 1259 | if(opt_io) { |
1260 | term.mode |= MODE_PRINT; | ||
1259 | iofd = (!strcmp(opt_io, "-")) ? | 1261 | iofd = (!strcmp(opt_io, "-")) ? |
1260 | STDOUT_FILENO : | 1262 | STDOUT_FILENO : |
1261 | open(opt_io, O_WRONLY | O_CREAT, 0666); | 1263 | open(opt_io, O_WRONLY | O_CREAT, 0666); |
@@ -1979,6 +1981,18 @@ csihandle(void) { | |||
1979 | DEFAULT(csiescseq.arg[0], 1); | 1981 | DEFAULT(csiescseq.arg[0], 1); |
1980 | tmoveto(term.c.x, term.c.y+csiescseq.arg[0]); | 1982 | tmoveto(term.c.x, term.c.y+csiescseq.arg[0]); |
1981 | break; | 1983 | break; |
1984 | case 'i': /* MC -- Media Copy */ | ||
1985 | switch(csiescseq.arg[0]) { | ||
1986 | case 0: | ||
1987 | case 1: | ||
1988 | case 4: | ||
1989 | term.mode &= ~MODE_PRINT; | ||
1990 | break; | ||
1991 | case 5: | ||
1992 | term.mode |= MODE_PRINT; | ||
1993 | break; | ||
1994 | } | ||
1995 | break; | ||
1982 | case 'c': /* DA -- Device Attributes */ | 1996 | case 'c': /* DA -- Device Attributes */ |
1983 | if(csiescseq.arg[0] == 0) | 1997 | if(csiescseq.arg[0] == 0) |
1984 | ttywrite(VT102ID, sizeof(VT102ID) - 1); | 1998 | ttywrite(VT102ID, sizeof(VT102ID) - 1); |
@@ -2332,7 +2346,7 @@ tputc(char *c, int len) { | |||
2332 | width = wcwidth(u8char); | 2346 | width = wcwidth(u8char); |
2333 | } | 2347 | } |
2334 | 2348 | ||
2335 | if(iofd != -1) { | 2349 | if(IS_SET(MODE_PRINT) && iofd != -1) { |
2336 | if(xwrite(iofd, c, len) < 0) { | 2350 | if(xwrite(iofd, c, len) < 0) { |
2337 | fprintf(stderr, "Error writing in %s:%s\n", | 2351 | fprintf(stderr, "Error writing in %s:%s\n", |
2338 | opt_io, strerror(errno)); | 2352 | opt_io, strerror(errno)); |