This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-10-quiet-head
in repository terminology.
View the commit online.
commit 2db8e414feac3636024cf736ceb22885cf1abd0e
Author: Boris Faure <[email protected]>
AuthorDate: Sun Nov 8 13:02:06 2026 +0000
termptyesc: clamp REP counts by the lines between the margins
A REP count above the screen size was reduced modulo the screen size.
That keeps the cursor where the full count leaves it only when lines
are as wide as the screen: between left and right margins, or with
double width characters, the cursor ended up elsewhere.
Past the first line and one line per screen row, every row the text can
reach is full of the character, and each further line leaves the same
state, so only the count modulo the characters per line matters. Reduce
it so; this also bounds the work to about a screen instead of two.
rep.sh's checksum changes: its REP 11111 without margins scrolls fewer
lines into the scrollback, and the screen and cursor are unchanged.
rep-region.sh fails without this change.
---
src/bin/termptyesc.c | 8 ++------
src/bin/termptyops.c | 19 +++++++++++++++++++
src/bin/termptyops.h | 3 +++
tests/rep-region-literal.sh | 25 +++++++++++++++++++++++++
tests/rep-region.sh | 27 +++++++++++++++++++++++++++
tests/tests.results | 4 +++-
6 files changed, 79 insertions(+), 7 deletions(-)
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 015737cc..799671d2 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -3274,19 +3274,15 @@ _handle_esc_csi_rep(Termpty *ty, Eina_Unicode **ptr)
if (ty->last_char)
{
Eina_Unicode run[256];
- int screen_size = ty->w * ty->h;
int i, n;
if (arg <= 0)
{
arg = 1;
}
- else if (arg > screen_size)
+ else
{
- /* if value is too large, restrict it to something that makes
- * rendering correct (but not in the backlog, but who cares…)
- */
- arg = screen_size + (arg % screen_size);
+ arg = termpty_text_repeat_count(ty, ty->last_char, arg);
}
n = MIN(arg, (int)EINA_C_ARRAY_LENGTH(run));
for (i = 0; i < n; i++)
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index 9bf80f57..e6540468 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -311,6 +311,25 @@ _append_ascii_run(Termpty *ty, Termcell *cells, const Eina_Unicode *cp, int n,
}
}
+/* After a screen's worth of lines, each line leaves the same state. */
+int
+termpty_text_repeat_count(const Termpty *ty, Eina_Unicode codepoint,
+ int count)
+{
+ Eina_Unicode g = _termpty_charset_trans(ty, codepoint);
+ int cell_w = _termpty_is_dblwidth_get(ty, g, EINA_FALSE) ? 2 : 1;
+ int right = ty->termstate.right_margin ? ty->termstate.right_margin : ty->w;
+ int line_w = right - ty->termstate.left_margin;
+ int per_line, settled;
+
+ if (line_w < 1) line_w = 1;
+ per_line = (line_w + cell_w - 1) / cell_w;
+ settled = ty->w + (ty->h * per_line);
+ if (count <= settled + per_line)
+ return count;
+ return settled + ((count - settled) % per_line);
+}
+
void
termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
{
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index 5ba1eb24..b9a05af6 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -24,6 +24,9 @@ void termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len);
void termpty_text_append_known_ascii(Termpty *ty,
const Eina_Unicode *codepoints, int len,
size_t plain_ascii_len);
+/* A count no larger than 'count' leaving the same screen and cursor. */
+int termpty_text_repeat_count(const Termpty *ty, Eina_Unicode codepoint,
+ int count);
void termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit);
void termpty_clear_screen(Termpty *ty, Termpty_Clear mode);
void termpty_clear_all(Termpty *ty);
diff --git a/tests/rep-region-literal.sh b/tests/rep-region-literal.sh
new file mode 100644
index 00000000..f221b707
--- /dev/null
+++ b/tests/rep-region-literal.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# rep-region.sh with each REP written out as the characters it repeats:
+# both must end in the same state.
+
+# fill the screen with E, scroll region on rows 5 to 15
+printf '\033#8\033[5;15r\033[?69h'
+
+# inside the region
+printf '\033[2;8s\033[7;4H' ; printf 'a%.0s' $(seq 5000); printf '.'
+
+# above the region, from right of the right margin
+printf '\033[10;16s\033[2;70H' ; printf 'b%.0s' $(seq 3000); printf '.'
+
+# below the region: no scroll, the last row is rewritten
+printf '\033[18;24s\033[18;20H' ; printf 'c%.0s' $(seq 3000); printf '.'
+
+# double width
+printf '\033[26;32s\033[9;27H' ; printf '中%.0s' $(seq 3333); printf '.'
+
+# autowrap off
+printf '\033[34;40s\033[?7l\033[11;35H' ; printf 'd%.0s' $(seq 2000); printf '.\033[?7h'
+
+# insert mode
+printf '\033[42;48s\033[4h\033[13;45H' ; printf 'e%.0s' $(seq 2100); printf '.\033[4l'
diff --git a/tests/rep-region.sh b/tests/rep-region.sh
new file mode 100644
index 00000000..8a76db9f
--- /dev/null
+++ b/tests/rep-region.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# REP counts larger than the screen, within a scroll region and left and
+# right margins 7 columns apart, one band of columns per case. Each case
+# ends with a '.' at the cursor. The result must be that of the same
+# characters written one by one, in rep-region-literal.sh.
+
+# fill the screen with E, scroll region on rows 5 to 15
+printf '\033#8\033[5;15r\033[?69h'
+
+# inside the region
+printf '\033[2;8s\033[7;4Ha\033[4999b.'
+
+# above the region, from right of the right margin
+printf '\033[10;16s\033[2;70Hb\033[2999b.'
+
+# below the region: no scroll, the last row is rewritten
+printf '\033[18;24s\033[18;20Hc\033[2999b.'
+
+# double width
+printf '\033[26;32s\033[9;27H中\033[3332b.'
+
+# autowrap off
+printf '\033[34;40s\033[?7l\033[11;35Hd\033[1999b.\033[?7h'
+
+# insert mode
+printf '\033[42;48s\033[4h\033[13;45He\033[2099b.\033[4l'
diff --git a/tests/tests.results b/tests/tests.results
index beb78958..476d0901 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -89,7 +89,9 @@ ech.sh 9b9d50e716cbe871ab831c396d5fb943
text_append_after_right_margin.sh fc835db39be6a84e1ebd1ce1937cd364
cbt.sh b7f031f874c5cb537922d5a7019c6434
hpa.sh 6659226975d06786a9651da14299cb82
-rep.sh 7b533f940c995734489c284a7c7dac1b
+rep.sh 515acb406ff50287e1a1997bb1d337f4
+rep-region.sh 24d8394a3d1fcf24d1e996328fba3886
+rep-region-literal.sh 24d8394a3d1fcf24d1e996328fba3886
da.sh 0e2a05402d20ee081403a6c04c78344f
uts.sh c959c942c56b2f85424c2075f3cceddb
vpa.sh 28538edba8d3dbaf671597c7bc600e4f
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.