[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-readline] Command "clear-screen" should clear scrollback buffer (if
From: |
burning2007 |
Subject: |
[Bug-readline] Command "clear-screen" should clear scrollback buffer (if supported) as well |
Date: |
Fri, 15 Dec 2017 00:56:53 +0300 |
Version: 6.3-release
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-solus-linux-gcc
Machine Type: x86_64-solus-linux-gnu
Description:
The command "clear-screen" should clear terminal's scrollback buffer as well.
`clear` from ncurses does so. Seems like clearing scrollback along with screen
is desired behavior in almost all cases. Another option is to provide
"clear-screen-and-scrollback" command and let the user to pick what he like.
How to repeat:
Ensure that your terminal support `CSI ED 2` sequence (linux console, xterm,
most of libvte-based terminals, including gnome-terminal, xfce-terminal):
`infocmp -x |grep E3`. `cat` something that takes more than one screen, then
(assuming that "clear-screen" bound as by default) press "C-l". Screen will be
cleared, but you still have to be able to scroll back.
Fix:
Here is possible patch:
diff --git a/display.c b/display.c
index 41fb053..dc7a578 100644
--- a/display.c
+++ b/display.c
@@ -2668,8 +2668,13 @@ void
_rl_clear_screen ()
{
#ifndef __DJGPP__
- if (_rl_term_clrpag)
+ if (_rl_term_clrpag) {
tputs (_rl_term_clrpag, 1, _rl_output_character_function);
+
+ if (_rl_term_clrscrollback) {
+ tputs (_rl_term_clrscrollback, 1, _rl_output_character_function);
+ }
+ }
else
rl_crlf ();
#else
diff --git a/rlprivate.h b/rlprivate.h
index fc3856a..9dfd8b7 100644
--- a/rlprivate.h
+++ b/rlprivate.h
@@ -534,6 +534,7 @@ extern int _rl_enable_keypad;
extern int _rl_enable_meta;
extern char *_rl_term_clreol;
extern char *_rl_term_clrpag;
+extern char *_rl_term_clrscrollback;
extern char *_rl_term_im;
extern char *_rl_term_ic;
extern char *_rl_term_ei;
diff --git a/terminal.c b/terminal.c
index ef2884e..7bcde2c 100644
--- a/terminal.c
+++ b/terminal.c
@@ -112,6 +112,7 @@ char PC, *BC, *UP;
/* Some strings to control terminal actions. These are output by tputs (). */
char *_rl_term_clreol;
char *_rl_term_clrpag;
+char *_rl_term_clrscrollback;
char *_rl_term_cr;
char *_rl_term_backspace;
char *_rl_term_goto;
@@ -393,6 +394,7 @@ static const struct _tc_string tc_strings[] =
{ "IC", &_rl_term_IC },
{ "ce", &_rl_term_clreol },
{ "cl", &_rl_term_clrpag },
+ { "E3", &_rl_term_clrscrollback },
{ "cr", &_rl_term_cr },
{ "dc", &_rl_term_dc },
{ "ei", &_rl_term_ei },
@@ -445,7 +447,7 @@ _rl_init_terminal_io (terminal_name)
int tty, tgetent_ret;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
- _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
+ _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = _rl_term_clrscrollback =
(char *)NULL;
tty = rl_instream ? fileno (rl_instream) : 0;
if (term == 0)
@@ -458,7 +460,7 @@ _rl_init_terminal_io (terminal_name)
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_terminal_can_insert = term_has_meta = _rl_term_autowrap = 0;
_rl_term_cr = "\r";
- _rl_term_clreol = _rl_term_clrpag = _rl_term_backspace = (char *)NULL;
+ _rl_term_clreol = _rl_term_clrpag = _rl_term_backspace =
_rl_term_clrscrollback = (char *)NULL;
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
- [Bug-readline] Command "clear-screen" should clear scrollback buffer (if supported) as well,
burning2007 <=