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 77ed4a86c9d6d83ba97efee0e3026ecd923666fb
Author: Boris Faure <[email protected]>
AuthorDate: Thu Nov 12 16:35:52 2026 +0000
termptyops: scroll a region by several lines in one pass
SU, SD, IL and DL scrolled a region one line at a time, each step
copying every row of the region, so a count of n cost n times the
region. A scroll region that is the whole screen is a rotation of the
circular buffer and pushes each line to the backlog, so it keeps
scrolling line by line; any other region now moves each row once and
clears the opened rows, with the count capped at the region height.
The reference counts of hyperlinks and blocks are only adjusted for
the rows leaving and the rows opened, in an order where a row gains
before it loses, for no one-cell block to be freed in between.
---
src/bin/termptyesc.c | 22 ++++-----------
src/bin/termptyops.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/termptyops.h | 2 ++
3 files changed, 87 insertions(+), 16 deletions(-)
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index e67f0a9e..f9893107 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -3016,7 +3016,7 @@ _handle_esc_csi_il(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
int arg = _csi_arg_get(ty, &b);
- int sy1, sy2, i;
+ int sy1, sy2;
if (arg == -ESC_ARG_ERROR)
return;
@@ -3040,10 +3040,7 @@ _handle_esc_csi_il(Termpty *ty, Eina_Unicode **ptr)
if (ty->termstate.bottom_margin <= ty->termstate.top_margin)
ty->termstate.bottom_margin = ty->termstate.top_margin + 1;
}
- for (i = 0; i < arg; i++)
- {
- termpty_text_scroll_rev(ty, EINA_TRUE);
- }
+ termpty_text_scroll_rev_lines(ty, arg);
ty->termstate.top_margin = sy1;
ty->termstate.bottom_margin = sy2;
ty->cursor_state.cx = ty->termstate.left_margin;
@@ -3054,7 +3051,7 @@ _handle_esc_csi_dl(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
int arg = _csi_arg_get(ty, &b);
- int sy1, sy2, i;
+ int sy1, sy2;
if (arg == -ESC_ARG_ERROR)
return;
@@ -3078,10 +3075,7 @@ _handle_esc_csi_dl(Termpty *ty, Eina_Unicode **ptr)
if (ty->termstate.bottom_margin <= ty->termstate.top_margin)
ty->termstate.bottom_margin = ty->termstate.top_margin + 1;
}
- for (i = 0; i < arg; i++)
- {
- termpty_text_scroll(ty, EINA_TRUE);
- }
+ termpty_text_scroll_lines(ty, arg);
ty->termstate.top_margin = sy1;
ty->termstate.bottom_margin = sy2;
ty->cursor_state.cx = ty->termstate.left_margin;
@@ -3092,15 +3086,13 @@ _handle_esc_csi_su(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
int arg = _csi_arg_get(ty, &b);
- int i;
if (arg == -ESC_ARG_ERROR)
return;
TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
DBG("SU - Scroll Up: %d", arg);
- for (i = 0; i < arg; i++)
- termpty_text_scroll(ty, EINA_TRUE);
+ termpty_text_scroll_lines(ty, arg);
}
static void
@@ -3108,7 +3100,6 @@ _handle_esc_csi_sd(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
int arg = _csi_arg_get(ty, &b);
- int i;
if (arg == -ESC_ARG_ERROR)
return;
@@ -3120,8 +3111,7 @@ _handle_esc_csi_sd(Termpty *ty, Eina_Unicode **ptr)
TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
DBG("SD - Scroll Down: %d", arg);
- for (i = 0; i < arg; i++)
- termpty_text_scroll_rev(ty, EINA_TRUE);
+ termpty_text_scroll_rev_lines(ty, arg);
}
static void
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index 8767ff08..a6a48348 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -162,6 +162,85 @@ termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
}
}
+/* The rows and columns of the scroll region. Returns EINA_FALSE when it is
+ * the whole screen, which scrolls by rotating the circular buffer. */
+static Eina_Bool
+_scroll_region_get(const Termpty *ty, int *start_y, int *end_y,
+ int *x, int *w)
+{
+ *start_y = ty->termstate.top_margin;
+ *end_y = ty->h - 1;
+ if (ty->termstate.bottom_margin != 0)
+ *end_y = ty->termstate.bottom_margin - 1;
+ *x = ty->termstate.left_margin;
+ *w = ty->w - *x;
+ if (ty->termstate.right_margin)
+ *w = ty->termstate.right_margin - *x;
+ return !((*start_y == 0) && (*end_y == ty->h - 1) &&
+ (ty->termstate.left_margin == 0) &&
+ (ty->termstate.right_margin == 0));
+}
+
+/* As n termpty_text_scroll(ty, EINA_TRUE), moving each row of a region
+ * once rather than n times. */
+void
+termpty_text_scroll_lines(Termpty *ty, int n)
+{
+ int start_y, end_y, x, w, y, i, kept;
+
+ if ((n <= 1) || !_scroll_region_get(ty, &start_y, &end_y, &x, &w))
+ {
+ for (i = 0; i < n; i++)
+ termpty_text_scroll(ty, EINA_TRUE);
+ return;
+ }
+ for (i = 0; i < n; i++)
+ termio_scroll(ty->obj, -1, start_y, end_y);
+
+ n = MIN(n, end_y - start_y + 1);
+ kept = end_y - start_y + 1 - n;
+ /* The n top rows lose their references and the n bottom ones gain a
+ * second, dropped when they are cleared. A row both lost and gained
+ * gains first, for no block to be freed in between. */
+ if ((kept > 0) && EINA_UNLIKELY((ty->hl.size != 0) || (ty->block.blocks)))
+ for (i = 0; i < n; i++)
+ termpty_cells_copy_refs(ty, &(TERMPTY_SCREEN(ty, x, start_y + kept + i)),
+ &(TERMPTY_SCREEN(ty, x, start_y + i)), w);
+ for (y = start_y; y < start_y + kept; y++)
+ memcpy(&(TERMPTY_SCREEN(ty, x, y)), &(TERMPTY_SCREEN(ty, x, y + n)),
+ w * sizeof(Termcell));
+ for (; y <= end_y; y++)
+ termpty_cells_clear(ty, &(TERMPTY_SCREEN(ty, x, y)), w);
+}
+
+/* As n termpty_text_scroll_rev(ty, EINA_TRUE). */
+void
+termpty_text_scroll_rev_lines(Termpty *ty, int n)
+{
+ int start_y, end_y, x, w, y, i, kept;
+
+ if ((n <= 1) || !_scroll_region_get(ty, &start_y, &end_y, &x, &w))
+ {
+ for (i = 0; i < n; i++)
+ termpty_text_scroll_rev(ty, EINA_TRUE);
+ return;
+ }
+ for (i = 0; i < n; i++)
+ termio_scroll(ty->obj, 1, start_y, end_y);
+
+ n = MIN(n, end_y - start_y + 1);
+ kept = end_y - start_y + 1 - n;
+ if ((kept > 0) && EINA_UNLIKELY((ty->hl.size != 0) || (ty->block.blocks)))
+ for (i = n - 1; i >= 0; i--)
+ termpty_cells_copy_refs(ty, &(TERMPTY_SCREEN(ty, x, start_y + i)),
+ &(TERMPTY_SCREEN(ty, x, start_y + kept + i)), w);
+ for (y = end_y; y >= start_y + n; y--)
+ memcpy(&(TERMPTY_SCREEN(ty, x, y)), &(TERMPTY_SCREEN(ty, x, y - n)),
+ w * sizeof(Termcell));
+ for (; y >= start_y; y--)
+ termpty_cells_clear(ty, &(TERMPTY_SCREEN(ty, x, y)), w);
+}
+
void
termpty_text_scroll_test(Termpty *ty, Eina_Bool clear)
{
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index b9a05af6..70555250 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -15,6 +15,8 @@ void termpty_cells_att_fill_preserve_colors(Termpty *ty, Termcell *cells,
Eina_Unicode codepoint, int count);
void termpty_text_scroll(Termpty *ty, Eina_Bool clear);
void termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear);
+void termpty_text_scroll_lines(Termpty *ty, int n);
+void termpty_text_scroll_rev_lines(Termpty *ty, int n);
void termpty_text_scroll_test(Termpty *ty, Eina_Bool clear);
void termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear);
void termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.