[PULL,16/17] readline: Clear screen on form feed.
diff mbox

Message ID 1402498262-20521-17-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino June 11, 2014, 2:51 p.m. UTC
From: Hani Benhabiles <kroosec@gmail.com>

Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 util/readline.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch
diff mbox

diff --git a/util/readline.c b/util/readline.c
index 7214e84..cc1302a 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -351,6 +351,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)
 {
@@ -369,6 +375,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';