readline: Clear screen on form feed.
PATCH 1/1 readline: Clear screen on form feed.
--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)
util/readline.c +9 -0
@@ -345,6 +345,12 @@ static void readline_completion(ReadLineState *rs) } } +static void readline_clear_screen (ReadLineState *rs) +{ + rs->printf_func (rs->opaque,"\033[2J\033[1;1H" ); +readline_show_prompt (rs); +} +/* return true if command handled */ void readline_handle_byte (ReadLineState *rs,int ch) {
@@ -363,6 +369,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)case 9 :readline_completion (rs);break ; +case 12 : +readline_clear_screen (rs); +break ;case 10 :case 13 : rs->cmd_buf[rs->cmd_buf_size] ='\0' ;
Signature · 1 line
1.8.3.2
Quoted 4 lines · Hani Benhabiles
Signed-off-by Hani Benhabiles <[email protected]>--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Please only CC me on patches for areas of the code that I maintain or you feel I am an expert in. That includes block, net, and tracing. Monitor and terminal escape sequences isn't my forte :-).
Stefan
Quoted 9 lines · Stefan Hajnoczi
Quoted 4 lines · Hani Benhabiles
Signed-off-by Hani Benhabiles <[email protected]>--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)Please only CC me on patches for areas of the code that I maintain or you feel I am an expert in. That includes block, net, and tracing. Monitor and terminal escape sequences isn't my forte :-).
Sure, np. Just used get_maintainer.pl output.
Quoted 10 lines · Hani Benhabiles
Signed-off-by Hani Benhabiles <[email protected]>--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)util/readline.c +0
-0
util/readline.c static void readline_completion(ReadLineState *rs) · line 351
Quoted 7 lines
util/readline.c +4
-0@@ -345,6 +345,12 @@ static void readline_completion(ReadLineState *rs) } } +static void readline_clear_screen (ReadLineState *rs) +{ + rs->printf_func (rs->opaque,"\033[2J\033[1;1H" ); +readline_show_prompt (rs);
That's not entirely universal escape sequence, but readline code uses similar sequences in other places already.
Applying to -trivial, thank you!
/mjt
Quoted 10 lines · On Sun, 1 Jun 2014 12:53:35 +0100 Hani Benhabiles <[email protected]> wrote:
Signed-off-by Hani Benhabiles <[email protected]>--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)util/readline.c +0
-0
util/readline.c static void readline_completion(ReadLineState *rs) · line 350
Quoted 6 lines
util/readline.c +3
-0@@ -345,6 +345,12 @@ static void readline_completion(ReadLineState *rs) } } +static void readline_clear_screen (ReadLineState *rs) +{ + rs->printf_func (rs->opaque,"\033[2J\033[1;1H" );
That's a smart way of doing it and I can't suggest anything better. But what happens on Windows?
Quoted 16 lines
util/readline.c +6
-0+readline_show_prompt (rs); +} +/* return true if command handled */ void readline_handle_byte (ReadLineState *rs,int ch) {@@ -363,6 +369,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)case 9 :readline_completion (rs);break ; +case 12 : +readline_clear_screen (rs); +break ;case 10 :case 13 : rs->cmd_buf[rs->cmd_buf_size] ='\0' ;
Quoted 16 lines · Luiz Capitulino
Quoted 13 lines · On Sun, 1 Jun 2014 12:53:35 +0100 Hani Benhabiles <[email protected]> wrote:
Signed-off-by Hani Benhabiles <[email protected]>--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)util/readline.c +0
-0@@ -345,6 +345,12 @@ static void readline_completion(ReadLineState *rs) } }
Quoted 6 lines
util/readline.c static void readline_completion(ReadLineState *rs) · line 350
Quoted 3 lines
util/readline.c +3
-0+static void readline_clear_screen (ReadLineState *rs) +{ + rs->printf_func (rs->opaque,"\033[2J\033[1;1H" );That's a smart way of doing it and I can't suggest anything better. But what happens on Windows?
Sorry, I have no experience with Windows and I can't give a definite answer about it.
But as Michael pointed out, readline is already using similar escape sequences.
Quoted 18 lines
Quoted 17 lines
util/readline.c +6
-0+readline_show_prompt (rs); +} +/* return true if command handled */ void readline_handle_byte (ReadLineState *rs,int ch) {@@ -363,6 +369,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)case 9 :readline_completion (rs);break ; +case 12 : +readline_clear_screen (rs); +break ;case 10 :case 13 : rs->cmd_buf[rs->cmd_buf_size] ='\0' ;
Luiz Capitulino
AppliedQuoted 1 line · On Sun, 1 Jun 2014 12:53:35 +0100 Hani Benhabiles <[email protected]> wrote:
Signed-off-by Hani Benhabiles <[email protected]>
Applied to the qmp branch, thanks.
Btw, we don't add a period to the end of the first line in the changelog.
Quoted 31 lines
--- util/readline.c | 9 +++++++++ 1 file changed, 9 insertions(+)util/readline.c +9
-0@@ -345,6 +345,12 @@ static void readline_completion(ReadLineState *rs) } } +static void readline_clear_screen (ReadLineState *rs) +{ + rs->printf_func (rs->opaque,"\033[2J\033[1;1H" ); +readline_show_prompt (rs); +} +/* return true if command handled */ void readline_handle_byte (ReadLineState *rs,int ch) {@@ -363,6 +369,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)case 9 :readline_completion (rs);break ; +case 12 : +readline_clear_screen (rs); +break ;case 10 :case 13 : rs->cmd_buf[rs->cmd_buf_size] ='\0' ;