public inbox for dev@dpdk.org
 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
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ 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 related	[flat|nested] 9+ 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
  2026-01-14 18:00 ` Stephen Hemminger
  2026-01-16 15:42 ` [PATCH v3] " Kerem Aksu
  2 siblings, 1 reply; 9+ messages in thread
From: Marat Khalili @ 2026-01-05 15:07 UTC (permalink / raw)
  To: Kerem Aksu, dev@dpdk.org

> -----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] 9+ 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; 9+ messages in thread
From: Kerem Aksu @ 2026-01-05 20:27 UTC (permalink / raw)
  To: Marat Khalili; +Cc: dev@dpdk.org

[-- 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] 9+ 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-14 18:00 ` Stephen Hemminger
  2026-01-16 15:42 ` [PATCH v3] " Kerem Aksu
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2026-01-14 18:00 UTC (permalink / raw)
  To: Kerem Aksu; +Cc: dev

On Mon,  5 Jan 2026 14:35:29 +0300
Kerem Aksu <kerem.aksu@i2i-systems.com> wrote:

> 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>
> ---

Overall looks correct. AI review had some feedback.
I would add a release note just for clarity


### Summary
This patch modifies the Ctrl+L behavior in the cmdline library to clear the entire screen and redisplay the prompt at the top, matching standard bash/readline behavior. Currently, Ctrl+L only redisplays on the current line.

---

### Commit Message ✅

| Check | Status | Notes |
|-------|--------|-------|
| Subject ≤60 chars | ✅ | 40 characters |
| Correct prefix | ✅ | `cmdline:` is correct for lib/cmdline |
| Imperative mood | ✅ | "update" |
| No trailing period | ✅ | |
| Lowercase | ✅ | |
| Body wrapped ≤75 chars | ✅ | |
| Body doesn't start with "It" | ✅ | |
| Signed-off-by | ✅ | Present |
| Acked-by/Tested-by | ✅ | Both present |

---

### Code Review

**Overall Assessment**: The approach is sound. Refactoring `rdline_redisplay` into a parameterized `rdline_reprint` static function maintains API compatibility while adding the new clear-screen behavior.

#### Errors (must fix)

**1. Extra whitespace after comma** (style violation)

Lines 126-129 in the patch have double spaces:
```c
rdline_puts(rdl,  vt100_clear_screen);   /* two spaces after comma */
rdline_puts(rdl,  vt100_homecursor);     /* two spaces after comma */
rdline_puts(rdl,  vt100_home);           /* two spaces after comma */
```

Should be:
```c
rdline_puts(rdl, vt100_clear_screen);
rdline_puts(rdl, vt100_homecursor);
rdline_puts(rdl, vt100_home);
```

#### Warnings (should consider)

**2. Consider order of escape sequences**

The current implementation sends `vt100_clear_screen` then `vt100_homecursor`. Some terminals may already position cursor at home after clear screen (ESC [2J), but the explicit `ESC [H` is safer for portability. This is fine as-is.

**3. Potential documentation update**

Consider whether the programmer's guide (`doc/guides/prog_guide/cmdline.rst`) or API documentation needs updating to reflect the changed Ctrl+L behavior. Users familiar with the old behavior might notice the change.

#### Info (observations)

**4. Good API preservation**

The `RTE_EXPORT_SYMBOL(rdline_redisplay)` is correctly maintained, and the public function signature is unchanged. This preserves backward compatibility for any external callers.

**5. New VT100 constant placement**

The new `vt100_homecursor` is added in a reasonable location in `cmdline_vt100.h`, near related cursor movement sequences.

**6. Existing style quirks preserved**

The file already uses `for (i=0 ; i<...` style (spaces around semicolons but not around `=` and `<`). The patch follows this existing convention, which is correct.

---

### Verdict

**Needs revision** - Fix the double-space style issue, then this is ready.

The change itself is a sensible UX improvement that aligns DPDK's command line behavior with user expectations from bash and readline. The implementation is clean and maintains API compatibility.

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

* [PATCH v3] 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-14 18:00 ` Stephen Hemminger
@ 2026-01-16 15:42 ` Kerem Aksu
  2026-02-10  0:10   ` Stephen Hemminger
                     ` (2 more replies)
  2 siblings, 3 replies; 9+ messages in thread
From: Kerem Aksu @ 2026-01-16 15:42 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>
---
 doc/guides/rel_notes/release_26_03.rst |  1 +
 lib/cmdline/cmdline_rdline.c           | 29 ++++++++++++++++++++------
 lib/cmdline/cmdline_vt100.h            |  1 +
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_03.rst b/doc/guides/rel_notes/release_26_03.rst
index 15dabee7a1..7a3df7fc84 100644
--- a/doc/guides/rel_notes/release_26_03.rst
+++ b/doc/guides/rel_notes/release_26_03.rst
@@ -84,6 +84,7 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* cmdline: Updated ``rdline`` library to clear screen when fed with Control+L.
 
 ABI Changes
 -----------
diff --git a/lib/cmdline/cmdline_rdline.c b/lib/cmdline/cmdline_rdline.c
index 3b8d435e98..ddca4d0a73 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 related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] cmdline: update clear screen behavior
  2026-01-16 15:42 ` [PATCH v3] " Kerem Aksu
@ 2026-02-10  0:10   ` Stephen Hemminger
  2026-02-12  0:23   ` Stephen Hemminger
  2026-02-14 19:08   ` Stephen Hemminger
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2026-02-10  0:10 UTC (permalink / raw)
  To: Kerem Aksu; +Cc: dev

On Fri, 16 Jan 2026 18:42:56 +0300
Kerem Aksu <kerem.aksu@i2i-systems.com> wrote:

> 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>
> ---
>  doc/guides/rel_notes/release_26_03.rst |  1 +
>  lib/cmdline/cmdline_rdline.c           | 29 ++++++++++++++++++++------
>  lib/cmdline/cmdline_vt100.h            |  1 +
>  3 files changed, 25 insertions(+), 6 deletions(-)

I was going to queue this to next-net.
But AI review sees some things that need to be addressed.
Do you want to resubmit with fixed release note, or I can fix that.


Errors: None.

Warnings:

    Release note entry is placed under "API Changes" but the public API signature is unchanged — this is a behavior change and may belong under a different section.
    Commit body could open with what the patch does rather than jumping into background.
    Pre-existing missing spaces around operators (i=0 ; i<rdl->prompt_size) in touched function — good opportunity to clean up.

Info:

    rdline_clear_screen() wrapper is only called once; could be inlined, but the named function improves readability at the call site. Fine either way.

Overall: Clean patch, good refactoring approach preserving the public API. No correctness issues.

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

* Re: [PATCH v3] cmdline: update clear screen behavior
  2026-01-16 15:42 ` [PATCH v3] " Kerem Aksu
  2026-02-10  0:10   ` Stephen Hemminger
@ 2026-02-12  0:23   ` Stephen Hemminger
  2026-02-12  7:56     ` Kerem Aksu
  2026-02-14 19:08   ` Stephen Hemminger
  2 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2026-02-12  0:23 UTC (permalink / raw)
  To: Kerem Aksu; +Cc: dev

On Fri, 16 Jan 2026 18:42:56 +0300
Kerem Aksu <kerem.aksu@i2i-systems.com> wrote:

> 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>
> ---

Applied to next-net after fixing the release note and rewording the
commit message.

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

* Re: [PATCH v3] cmdline: update clear screen behavior
  2026-02-12  0:23   ` Stephen Hemminger
@ 2026-02-12  7:56     ` Kerem Aksu
  0 siblings, 0 replies; 9+ messages in thread
From: Kerem Aksu @ 2026-02-12  7:56 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

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

On Tue, 10 Feb 2026 at 03:10, Stephen Hemminger <stephen@networkplumber.org>
wrote:

>     Release note entry is placed under "API Changes" but the public API
signature is unchanged — this is a behavior change and may belong under a
different section.

I couldn't figure out where to put the release note and looked for similar
changes in previous releases.

>     Pre-existing missing spaces around operators (i=0 ;
i<rdl->prompt_size) in touched function — good opportunity to clean up.

I avoided changing style of a decade old code since I don't know how DPDK
wants to handle these situations.

> Applied to next-net after fixing the release note and rewording the
> commit message.

Your email got lost so I can only get back to you now. Thanks for the good
work.

-- 
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: 2249 bytes --]

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

* Re: [PATCH v3] cmdline: update clear screen behavior
  2026-01-16 15:42 ` [PATCH v3] " Kerem Aksu
  2026-02-10  0:10   ` Stephen Hemminger
  2026-02-12  0:23   ` Stephen Hemminger
@ 2026-02-14 19:08   ` Stephen Hemminger
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2026-02-14 19:08 UTC (permalink / raw)
  To: Kerem Aksu; +Cc: dev

On Fri, 16 Jan 2026 18:42:56 +0300
Kerem Aksu <kerem.aksu@i2i-systems.com> wrote:

> 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>
> ---

Ended getting rid of the clear_screen flag.
If there are only to callers, it is better to have each caller
do the steps they want, then call reprint

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

end of thread, other threads:[~2026-02-14 19:09 UTC | newest]

Thread overview: 9+ 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
2026-01-14 18:00 ` Stephen Hemminger
2026-01-16 15:42 ` [PATCH v3] " Kerem Aksu
2026-02-10  0:10   ` Stephen Hemminger
2026-02-12  0:23   ` Stephen Hemminger
2026-02-12  7:56     ` Kerem Aksu
2026-02-14 19:08   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox