[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scrolling doesn't work in one-line terminals
From: |
Sören Tempel |
Subject: |
Re: Scrolling doesn't work in one-line terminals |
Date: |
Sat, 23 Nov 2019 10:44:10 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
Chet Ramey <address@hidden> wrote:
> I'm generally wary of automatically changing the default value of user-
> settable options without any user intervention, but it's certainly worth
> considering for this case.
To ease considering my suggestion I came up with a clean patch
implementing it. The patch enables horizontal scrolling for terminals of
height 1 automatically and disables it again if the terminal is resized
to a larger height but only if it the horizontal scrolling wasn't
explicitly enabled before.
I also documented this in the man page. Let me know what you think. The
git-format-patch(1) against current devel git HEAD looks as follows:
From e00815f8b58c543cf83b40cf82af4e37138b4044 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <address@hidden>
Date: Sat, 23 Nov 2019 10:35:19 +0100
Subject: [PATCH] Enable horizontal scrolling for terminals of height 1
automatically
Wrapping lines doesn't work in these terminals and causes scrolling to
not work by default unless the user explicitly enables horizontal
scrolling in the configuration file.
---
display.c | 15 +++++++++++++++
doc/readline.3 | 1 +
2 files changed, 16 insertions(+)
diff --git a/display.c b/display.c
index 5129654..9ce5b32 100644
--- a/display.c
+++ b/display.c
@@ -270,6 +270,10 @@ static int modmark;
static int line_totbytes;
+/* Whether horizontal scrolling has been enabled automatically
+ because the terminal was resized to height 1. */
+static int horizontal_scrolling_autoset;
+
/* Variables to save and restore prompt and display information. */
/* These are getting numerous enough that it's time to create a struct. */
@@ -689,6 +693,17 @@ rl_redisplay (void)
else if (line_size <= _rl_screenwidth)
init_line_structures (_rl_screenwidth + 1);
+ /* Enable horizontal scrolling automatically for terminals of height 1
+ where wrapping lines doesn't work. Disable it as soon as the terminal
+ height is increased again if it was automatically enabled. */
+ if (_rl_screenheight <= 1)
+ {
+ if (!_rl_horizontal_scroll_mode)
+ horizontal_scrolling_autoset = 1;
+ _rl_horizontal_scroll_mode = 1;
+ }
+ else if (horizontal_scrolling_autoset)
+ _rl_horizontal_scroll_mode = 0;
/* Draw the line into the buffer. */
cpos_buffer_position = -1;
diff --git a/doc/readline.3 b/doc/readline.3
index 24fad7d..57b4491 100644
--- a/doc/readline.3
+++ b/doc/readline.3
@@ -488,6 +488,7 @@ the maximum number of history entries will be set to 500.
When set to \fBOn\fP, makes readline use a single line for display,
scrolling the input horizontally on a single screen line when it
becomes longer than the screen width rather than wrapping to a new line.
+This setting is automatically enabled for terminals of height 1.
.TP
.B input\-meta (Off)
If set to \fBOn\fP, readline will enable eight-bit input (that is,