aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2014-01-31 21:53:53 +0100
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-03-06 07:50:34 +0100
commitcf332a325dafe7e9ed6d87df9dcec29149c5042c (patch)
treea3e6464f840694fed6ad4df019421b8f6d4b6d76
parent1f0d981bd7a1450ddfae3591c6e457253b3a6842 (diff)
downloadst-patched-cf332a325dafe7e9ed6d87df9dcec29149c5042c.tar.bz2
st-patched-cf332a325dafe7e9ed6d87df9dcec29149c5042c.tar.xz
st-patched-cf332a325dafe7e9ed6d87df9dcec29149c5042c.zip
Add MC for a single line
This sequence print the current line. It is different to the 'printer on' sequence, where all the characters that arrive to the terminal are printer. Here only the ascii characters are printed.
-rw-r--r--st.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/st.c b/st.c
index 314bf3f..e60643c 100644
--- a/st.c
+++ b/st.c
@@ -356,6 +356,8 @@ static void strparse(void);
356static void strreset(void); 356static void strreset(void);
357 357
358static int tattrset(int); 358static int tattrset(int);
359static void tprinter(char *s, size_t len);
360static void tdumpline(int);
359static void tclearregion(int, int, int, int); 361static void tclearregion(int, int, int, int);
360static void tcursor(int); 362static void tcursor(int);
361static void tdeletechar(int); 363static void tdeletechar(int);
@@ -470,7 +472,7 @@ static STREscape strescseq;
470static int cmdfd; 472static int cmdfd;
471static pid_t pid; 473static pid_t pid;
472static Selection sel; 474static Selection sel;
473static int iofd; 475static int iofd = STDOUT_FILENO;
474static char **opt_cmd = NULL; 476static char **opt_cmd = NULL;
475static char *opt_io = NULL; 477static char *opt_io = NULL;
476static char *opt_title = NULL; 478static 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
2268void 2272void
2273tprinter(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
2282void
2283tdumpline(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
2297void
2269tputtab(bool forward) { 2298tputtab(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