DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] cmdline: update clear screen behavior
@ 2026-01-05 11:35 Kerem Aksu
  2026-01-05 15:07 ` Marat Khalili
  0 siblings, 1 reply; 3+ messages in thread
From: Kerem Aksu @ 2026-01-05 11:35 UTC (permalink / raw)
  To: dev; +Cc: Kerem Aksu

Control+L should clear screen and redisplay prompt at the top
line. DPDK rdline library will not change anything on the screen when
fed with Control+L.  When prompt is lost after too many text written
to the terminal, users will press Control+L to clear screen and put
the prompt to the top line. This is expected behavior in bash(1) or
applications that are using readline(3). Updated to behave as users
expected.

Signed-off-by: Kerem Aksu <kerem.aksu@i2i-systems.com>
---
 lib/cmdline/cmdline_rdline.c | 29 +++++++++++++++++++++++------
 lib/cmdline/cmdline_vt100.h  |  1 +
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/cmdline/cmdline_rdline.c b/lib/cmdline/cmdline_rdline.c
index 3b8d435e98..95f519f123 100644
--- a/lib/cmdline/cmdline_rdline.c
+++ b/lib/cmdline/cmdline_rdline.c
@@ -182,9 +182,8 @@ display_right_buffer(struct rdline *rdl, int force)
 				  CIRBUF_GET_LEN(&rdl->right));
 }
 
-RTE_EXPORT_SYMBOL(rdline_redisplay)
-void
-rdline_redisplay(struct rdline *rdl)
+static void
+rdline_reprint(struct rdline *rdl, int clear_screen)
 {
 	unsigned int i;
 	char tmp;
@@ -192,7 +191,12 @@ rdline_redisplay(struct rdline *rdl)
 	if (!rdl)
 		return;
 
-	rdline_puts(rdl, vt100_home);
+	if (clear_screen) {
+		rdline_puts(rdl,  vt100_clear_screen);
+		rdline_puts(rdl,  vt100_homecursor);
+	} else {
+		rdline_puts(rdl,  vt100_home);
+	}
 	for (i=0 ; i<rdl->prompt_size ; i++)
 		rdl->write_char(rdl, rdl->prompt[i]);
 	CIRBUF_FOREACH(&rdl->left, i, tmp) {
@@ -201,6 +205,19 @@ rdline_redisplay(struct rdline *rdl)
 	display_right_buffer(rdl, 1);
 }
 
+RTE_EXPORT_SYMBOL(rdline_redisplay)
+void
+rdline_redisplay(struct rdline *rdl)
+{
+	rdline_reprint(rdl, 0);
+}
+
+static void
+rdline_clear_screen(struct rdline *rdl)
+{
+	rdline_reprint(rdl, 1);
+}
+
 RTE_EXPORT_SYMBOL(rdline_char_in)
 int
 rdline_char_in(struct rdline *rdl, char c)
@@ -382,9 +399,9 @@ rdline_char_in(struct rdline *rdl, char c)
 			rdline_newline(rdl, rdl->prompt);
 			break;
 
-		/* redisplay (helps when prompt is lost in other output) */
+		/* clear screen (helps when prompt is lost in other output) */
 		case CMDLINE_KEY_CTRL_L:
-			rdline_redisplay(rdl);
+			rdline_clear_screen(rdl);
 			break;
 
 		/* autocomplete */
diff --git a/lib/cmdline/cmdline_vt100.h b/lib/cmdline/cmdline_vt100.h
index be9ae8e1c9..5f11ebdb74 100644
--- a/lib/cmdline/cmdline_vt100.h
+++ b/lib/cmdline/cmdline_vt100.h
@@ -38,6 +38,7 @@ extern "C" {
 #endif
 #define vt100_word_left    "\033\142"
 #define vt100_word_right   "\033\146"
+#define vt100_homecursor   "\033[H"
 
 /* Result of parsing : it must be synchronized with
  * cmdline_vt100_commands[] in vt100.c */
-- 
2.34.1


-- 
Yasal Uyarı: *Bu elektronik posta bu linki kullanarak ulaşabileceğiniz 
koşullara tabidir:** **https://i2i-systems.com/email-disclaimer/ 
<http://i2i-systems.com/about-us/email-disclaimer/>*

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] cmdline: update clear screen behavior
  2026-01-05 11:35 [PATCH] cmdline: update clear screen behavior Kerem Aksu
@ 2026-01-05 15:07 ` Marat Khalili
  2026-01-05 20:27   ` Kerem Aksu
  0 siblings, 1 reply; 3+ messages in thread
From: Marat Khalili @ 2026-01-05 15:07 UTC (permalink / raw)
  To: Kerem Aksu, dev

> -----Original Message-----
> From: Kerem Aksu <kerem.aksu@i2i-systems.com>
> Sent: Monday 5 January 2026 11:35
> To: dev@dpdk.org
> Cc: Kerem Aksu <kerem.aksu@i2i-systems.com>
> Subject: [PATCH] cmdline: update clear screen behavior
> 
> Control+L should clear screen and redisplay prompt at the top
> line. DPDK rdline library will not change anything on the screen when
> fed with Control+L.  When prompt is lost after too many text written
> to the terminal, users will press Control+L to clear screen and put
> the prompt to the top line. This is expected behavior in bash(1) or
> applications that are using readline(3). Updated to behave as users
> expected.
> 
> Signed-off-by: Kerem Aksu <kerem.aksu@i2i-systems.com>
> ---

Acked-by: Marat Khalili <marat.khalili@huawei.com>
Tested-by: Marat Khalili <marat.khalili@huawei.com>

Interestingly, currently supported combinations also miss Ctrl+U.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cmdline: update clear screen behavior
  2026-01-05 15:07 ` Marat Khalili
@ 2026-01-05 20:27   ` Kerem Aksu
  0 siblings, 0 replies; 3+ messages in thread
From: Kerem Aksu @ 2026-01-05 20:27 UTC (permalink / raw)
  To: Marat Khalili; +Cc: dev

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

On Mon, Jan 5, 2026 at 6:07 PM Marat Khalili <marat.khalili@huawei.com>
wrote:
> Acked-by: Marat Khalili <marat.khalili@huawei.com>
> Tested-by: Marat Khalili <marat.khalili@huawei.com>
>
> Interestingly, currently supported combinations also miss Ctrl+U.

That can be implemented as another patch if requested.

Also existing combinations does not behave like their readline(3)
counterparts.
For example, Alt+D should kill next word but also should put it into kill
buffer to be used by Ctrl+Y.

-- 
Yasal Uyarı: *Bu elektronik posta bu linki kullanarak ulaşabileceğiniz 
koşullara tabidir:** **https://i2i-systems.com/email-disclaimer/ 
<http://i2i-systems.com/about-us/email-disclaimer/>*

[-- Attachment #2: Type: text/html, Size: 1829 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-05 20:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-05 11:35 [PATCH] cmdline: update clear screen behavior Kerem Aksu
2026-01-05 15:07 ` Marat Khalili
2026-01-05 20:27   ` Kerem Aksu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).