diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2020-05-14 18:18:07 +0300 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2020-05-16 14:08:10 +0200 |
commit | e8392b282c2eaa28725241a9612804fb55113da4 (patch) | |
tree | a19918f19c26bae56e589fa3adb3cd7a3e9955c5 | |
parent | f8afebdfa0cc9a57b22c39c47e9b585f69453eb7 (diff) | |
download | st-patched-e8392b282c2eaa28725241a9612804fb55113da4.tar.bz2 st-patched-e8392b282c2eaa28725241a9612804fb55113da4.tar.xz st-patched-e8392b282c2eaa28725241a9612804fb55113da4.zip |
support REP (repeat) escape sequence
The sequence \e[Nb prints the last printed char N (more) times if it's
printable, and it's ignored after newline or other control chars.
This is Ecma-048/ANSI-X3.6 sequence and not DEC VT. It's supported by
xterm, and ncurses uses it when possible, e.g. when TERM is xterm* (and
with this commit also st*).
xterm supports only codepoints<=255, possibly due to internal limits.
We support any value/codepoint which was placed in a cell.
To test:
- tput rep 65 4 -> prints 'AAAA'
- printf "\342\225\246\033[4b" -> prints U+2566 1+4 times.
-rw-r--r-- | st.c | 10 | ||||
-rw-r--r-- | st.info | 1 |
2 files changed, 11 insertions, 0 deletions
@@ -129,6 +129,7 @@ typedef struct { | |||
129 | int charset; /* current charset */ | 129 | int charset; /* current charset */ |
130 | int icharset; /* selected charset for sequence */ | 130 | int icharset; /* selected charset for sequence */ |
131 | int *tabs; | 131 | int *tabs; |
132 | Rune lastc; /* last printed char outside of sequence, 0 if control */ | ||
132 | } Term; | 133 | } Term; |
133 | 134 | ||
134 | /* CSI Escape sequence structs */ | 135 | /* CSI Escape sequence structs */ |
@@ -1648,6 +1649,12 @@ csihandle(void) | |||
1648 | if (csiescseq.arg[0] == 0) | 1649 | if (csiescseq.arg[0] == 0) |
1649 | ttywrite(vtiden, strlen(vtiden), 0); | 1650 | ttywrite(vtiden, strlen(vtiden), 0); |
1650 | break; | 1651 | break; |
1652 | case 'b': /* REP -- if last char is printable print it <n> more times */ | ||
1653 | DEFAULT(csiescseq.arg[0], 1); | ||
1654 | if (term.lastc) | ||
1655 | while (csiescseq.arg[0]-- > 0) | ||
1656 | tputc(term.lastc); | ||
1657 | break; | ||
1651 | case 'C': /* CUF -- Cursor <n> Forward */ | 1658 | case 'C': /* CUF -- Cursor <n> Forward */ |
1652 | case 'a': /* HPR -- Cursor <n> Forward */ | 1659 | case 'a': /* HPR -- Cursor <n> Forward */ |
1653 | DEFAULT(csiescseq.arg[0], 1); | 1660 | DEFAULT(csiescseq.arg[0], 1); |
@@ -2373,6 +2380,8 @@ check_control_code: | |||
2373 | /* | 2380 | /* |
2374 | * control codes are not shown ever | 2381 | * control codes are not shown ever |
2375 | */ | 2382 | */ |
2383 | if (!term.esc) | ||
2384 | term.lastc = 0; | ||
2376 | return; | 2385 | return; |
2377 | } else if (term.esc & ESC_START) { | 2386 | } else if (term.esc & ESC_START) { |
2378 | if (term.esc & ESC_CSI) { | 2387 | if (term.esc & ESC_CSI) { |
@@ -2422,6 +2431,7 @@ check_control_code: | |||
2422 | } | 2431 | } |
2423 | 2432 | ||
2424 | tsetchar(u, &term.c.attr, term.c.x, term.c.y); | 2433 | tsetchar(u, &term.c.attr, term.c.x, term.c.y); |
2434 | term.lastc = u; | ||
2425 | 2435 | ||
2426 | if (width == 2) { | 2436 | if (width == 2) { |
2427 | gp->mode |= ATTR_WIDE; | 2437 | gp->mode |= ATTR_WIDE; |
@@ -184,6 +184,7 @@ st-mono| simpleterm monocolor, | |||
184 | # XTerm extensions | 184 | # XTerm extensions |
185 | rmxx=\E[29m, | 185 | rmxx=\E[29m, |
186 | smxx=\E[9m, | 186 | smxx=\E[9m, |
187 | rep=%p1%c\E[%p2%{1}%-%db, | ||
187 | # tmux extensions, see TERMINFO EXTENSIONS in tmux(1) | 188 | # tmux extensions, see TERMINFO EXTENSIONS in tmux(1) |
188 | Tc, | 189 | Tc, |
189 | Ms=\E]52;%p1%s;%p2%s\007, | 190 | Ms=\E]52;%p1%s;%p2%s\007, |