diff options
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 41 |
1 files changed, 32 insertions, 9 deletions
| @@ -356,6 +356,8 @@ static void strparse(void); | |||
| 356 | static void strreset(void); | 356 | static void strreset(void); |
| 357 | 357 | ||
| 358 | static int tattrset(int); | 358 | static int tattrset(int); |
| 359 | static void tprinter(char *s, size_t len); | ||
| 360 | static void tdumpline(int); | ||
| 359 | static void tclearregion(int, int, int, int); | 361 | static void tclearregion(int, int, int, int); |
| 360 | static void tcursor(int); | 362 | static void tcursor(int); |
| 361 | static void tdeletechar(int); | 363 | static void tdeletechar(int); |
| @@ -470,7 +472,7 @@ static STREscape strescseq; | |||
| 470 | static int cmdfd; | 472 | static int cmdfd; |
| 471 | static pid_t pid; | 473 | static pid_t pid; |
| 472 | static Selection sel; | 474 | static Selection sel; |
| 473 | static int iofd; | 475 | static int iofd = STDOUT_FILENO; |
| 474 | static char **opt_cmd = NULL; | 476 | static char **opt_cmd = NULL; |
| 475 | static char *opt_io = NULL; | 477 | static char *opt_io = NULL; |
| 476 | static char *opt_title = NULL; | 478 | static char *opt_title = NULL; |
| @@ -1985,6 +1987,8 @@ csihandle(void) { | |||
| 1985 | switch(csiescseq.arg[0]) { | 1987 | switch(csiescseq.arg[0]) { |
| 1986 | case 0: | 1988 | case 0: |
| 1987 | case 1: | 1989 | case 1: |
| 1990 | tdumpline(term.c.y); | ||
| 1991 | break; | ||
| 1988 | case 4: | 1992 | case 4: |
| 1989 | term.mode &= ~MODE_PRINT; | 1993 | term.mode &= ~MODE_PRINT; |
| 1990 | break; | 1994 | break; |
| @@ -2266,6 +2270,31 @@ strreset(void) { | |||
| 2266 | } | 2270 | } |
| 2267 | 2271 | ||
| 2268 | void | 2272 | void |
| 2273 | tprinter(char *s, size_t len) { | ||
| 2274 | if(iofd != -1 && xwrite(iofd, s, len) < 0) { | ||
| 2275 | fprintf(stderr, "Error writing in %s:%s\n", | ||
| 2276 | opt_io, strerror(errno)); | ||
| 2277 | close(iofd); | ||
| 2278 | iofd = -1; | ||
| 2279 | } | ||
| 2280 | } | ||
| 2281 | |||
| 2282 | void | ||
| 2283 | tdumpline(int n) { | ||
| 2284 | Glyph *bp, *end; | ||
| 2285 | |||
| 2286 | bp = &term.line[n][0]; | ||
| 2287 | end = &bp[term.col-1]; | ||
| 2288 | while(end > bp && !strcmp(" ", end->c)) | ||
| 2289 | --end; | ||
| 2290 | if(bp != end || strcmp(bp->c, " ")) { | ||
| 2291 | for( ;bp <= end; ++bp) | ||
| 2292 | tprinter(bp->c, strlen(bp->c)); | ||
| 2293 | } | ||
| 2294 | tprinter("\n", 1); | ||
| 2295 | } | ||
| 2296 | |||
| 2297 | void | ||
| 2269 | tputtab(bool forward) { | 2298 | tputtab(bool forward) { |
| 2270 | uint x = term.c.x; | 2299 | uint x = term.c.x; |
| 2271 | 2300 | ||
| @@ -2346,14 +2375,8 @@ tputc(char *c, int len) { | |||
| 2346 | width = wcwidth(u8char); | 2375 | width = wcwidth(u8char); |
| 2347 | } | 2376 | } |
| 2348 | 2377 | ||
| 2349 | if(IS_SET(MODE_PRINT) && iofd != -1) { | 2378 | if(IS_SET(MODE_PRINT)) |
| 2350 | if(xwrite(iofd, c, len) < 0) { | 2379 | tprinter(c, len); |
| 2351 | fprintf(stderr, "Error writing in %s:%s\n", | ||
| 2352 | opt_io, strerror(errno)); | ||
| 2353 | close(iofd); | ||
| 2354 | iofd = -1; | ||
| 2355 | } | ||
| 2356 | } | ||
| 2357 | 2380 | ||
| 2358 | /* | 2381 | /* |
| 2359 | * STR sequences must be checked before anything else | 2382 | * STR sequences must be checked before anything else |
