diff options
| author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2012-09-03 21:52:21 +0200 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2012-09-03 21:52:21 +0200 |
| commit | a984ffc4cb755c6dcdbc153b2591dca0ae6a8ead (patch) | |
| tree | 393e05c204a8a5c9153f358eecc40b0f79b6c827 /st.c | |
| parent | Patch from Roberto Vargas. »Add initialization strings in terminfo« (diff) | |
| download | st-a984ffc4cb755c6dcdbc153b2591dca0ae6a8ead.tar.gz st-a984ffc4cb755c6dcdbc153b2591dca0ae6a8ead.zip | |
Add write I/O to file
This is a theorical feature listed in http://st.suckless.org/goals. All the
input/output of the terminal will be written to a file, which can be very
useful for debugging, and also allow interconnect st to other process
through named pipes.
---
st.1 | 6 ++++++
st.c | 14 +++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
Diffstat (limited to '')
| -rw-r--r-- | st.c | 14 |
1 files changed, 13 insertions, 1 deletions
| @@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | #define USAGE \ | 37 | #define USAGE \ |
| 38 | "st " VERSION " (c) 2010-2012 st engineers\n" \ | 38 | "st " VERSION " (c) 2010-2012 st engineers\n" \ |
| 39 | "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n" | 39 | "usage: st [-t title] [-c class] [-w windowid] [-v] [-f file] [-e command...]\n" |
| 40 | 40 | ||
| 41 | /* XEMBED messages */ | 41 | /* XEMBED messages */ |
| 42 | #define XEMBED_FOCUS_IN 4 | 42 | #define XEMBED_FOCUS_IN 4 |
| @@ -342,7 +342,9 @@ static STREscape strescseq; | |||
| 342 | static int cmdfd; | 342 | static int cmdfd; |
| 343 | static pid_t pid; | 343 | static pid_t pid; |
| 344 | static Selection sel; | 344 | static Selection sel; |
| 345 | static FILE *fileio; | ||
| 345 | static char **opt_cmd = NULL; | 346 | static char **opt_cmd = NULL; |
| 347 | static char *opt_io = NULL; | ||
| 346 | static char *opt_title = NULL; | 348 | static char *opt_title = NULL; |
| 347 | static char *opt_embed = NULL; | 349 | static char *opt_embed = NULL; |
| 348 | static char *opt_class = NULL; | 350 | static char *opt_class = NULL; |
| @@ -776,6 +778,10 @@ ttynew(void) { | |||
| 776 | close(s); | 778 | close(s); |
| 777 | cmdfd = m; | 779 | cmdfd = m; |
| 778 | signal(SIGCHLD, sigchld); | 780 | signal(SIGCHLD, sigchld); |
| 781 | if (opt_io && !(fileio = fopen(opt_io, "w"))) { | ||
| 782 | fprintf(stderr, "Error opening %s:%s", | ||
| 783 | opt_io, strerror(errno)); | ||
| 784 | } | ||
| 779 | } | 785 | } |
| 780 | } | 786 | } |
| 781 | 787 | ||
| @@ -1534,6 +1540,9 @@ tputtab(bool forward) { | |||
| 1534 | void | 1540 | void |
| 1535 | tputc(char *c) { | 1541 | tputc(char *c) { |
| 1536 | char ascii = *c; | 1542 | char ascii = *c; |
| 1543 | |||
| 1544 | if (fileio) | ||
| 1545 | putc(ascii, fileio); | ||
| 1537 | if(term.esc & ESC_START) { | 1546 | if(term.esc & ESC_START) { |
| 1538 | if(term.esc & ESC_CSI) { | 1547 | if(term.esc & ESC_CSI) { |
| 1539 | csiescseq.buf[csiescseq.len++] = ascii; | 1548 | csiescseq.buf[csiescseq.len++] = ascii; |
| @@ -2269,6 +2278,9 @@ main(int argc, char *argv[]) { | |||
| 2269 | case 'w': | 2278 | case 'w': |
| 2270 | if(++i < argc) opt_embed = argv[i]; | 2279 | if(++i < argc) opt_embed = argv[i]; |
| 2271 | break; | 2280 | break; |
| 2281 | case 'f': | ||
| 2282 | if (++i < argc) opt_io = argv[i]; | ||
| 2283 | break; | ||
| 2272 | case 'e': | 2284 | case 'e': |
| 2273 | /* eat every remaining arguments */ | 2285 | /* eat every remaining arguments */ |
| 2274 | if(++i < argc) opt_cmd = &argv[i]; | 2286 | if(++i < argc) opt_cmd = &argv[i]; |
