hmp-commands.hx | 14 ++++++++++++++ include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 5 +++++ 3 files changed, 20 insertions(+)
The monitor screen can be cluttered after executing commands
like `info qtree`. It is useful to have a command to clear
current screen, just like linux `clear` command do.
This patch has been tested under monitors using stdio, vc,
tcp socket, unix socket and serial interfaces.
Signed-off-by: Alano Song <AlanoSong@163.com>
---
hmp-commands.hx | 14 ++++++++++++++
include/monitor/hmp.h | 1 +
monitor/hmp-cmds.c | 5 +++++
3 files changed, 20 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 5cc4788f12..95f9166732 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -20,6 +20,20 @@ SRST
Show the help for all commands or just for command *cmd*.
ERST
+ {
+ .name = "clear",
+ .args_type = "",
+ .params = "",
+ .help = "clear the monitor screen",
+ .cmd = hmp_clear,
+ .flags = "p",
+ },
+
+SRST
+``clear``
+ Clear the monitor screen.
+ERST
+
{
.name = "commit",
.args_type = "device:B",
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index e222bea60c..9b66458d21 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);
void hmp_trace_file(Monitor *mon, const QDict *qdict);
void hmp_info_trace_events(Monitor *mon, const QDict *qdict);
void hmp_help(Monitor *mon, const QDict *qdict);
+void hmp_clear(Monitor *mon, const QDict *qdict);
void hmp_info_help(Monitor *mon, const QDict *qdict);
void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);
void hmp_info_history(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index bc26b39d70..3e9485478e 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -218,6 +218,11 @@ void hmp_help(Monitor *mon, const QDict *qdict)
hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
}
+void hmp_clear(Monitor *mon, const QDict *qdict)
+{
+ monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H");
+}
+
void hmp_info_help(Monitor *mon, const QDict *qdict)
{
hmp_help_cmd(mon, "info");
--
2.43.0
* AlanoSong@163.com (AlanoSong@163.com) wrote:
> The monitor screen can be cluttered after executing commands
> like `info qtree`. It is useful to have a command to clear
> current screen, just like linux `clear` command do.
>
> This patch has been tested under monitors using stdio, vc,
> tcp socket, unix socket and serial interfaces.
>
> Signed-off-by: Alano Song <AlanoSong@163.com>
Does typing ctrl-l not do it for you in your terminal?
Dave
> ---
> hmp-commands.hx | 14 ++++++++++++++
> include/monitor/hmp.h | 1 +
> monitor/hmp-cmds.c | 5 +++++
> 3 files changed, 20 insertions(+)
>
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 5cc4788f12..95f9166732 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -20,6 +20,20 @@ SRST
> Show the help for all commands or just for command *cmd*.
> ERST
>
> + {
> + .name = "clear",
> + .args_type = "",
> + .params = "",
> + .help = "clear the monitor screen",
> + .cmd = hmp_clear,
> + .flags = "p",
> + },
> +
> +SRST
> +``clear``
> + Clear the monitor screen.
> +ERST
> +
> {
> .name = "commit",
> .args_type = "device:B",
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index e222bea60c..9b66458d21 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);
> void hmp_trace_file(Monitor *mon, const QDict *qdict);
> void hmp_info_trace_events(Monitor *mon, const QDict *qdict);
> void hmp_help(Monitor *mon, const QDict *qdict);
> +void hmp_clear(Monitor *mon, const QDict *qdict);
> void hmp_info_help(Monitor *mon, const QDict *qdict);
> void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);
> void hmp_info_history(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index bc26b39d70..3e9485478e 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -218,6 +218,11 @@ void hmp_help(Monitor *mon, const QDict *qdict)
> hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
> }
>
> +void hmp_clear(Monitor *mon, const QDict *qdict)
> +{
> + monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H");
> +}
> +
> void hmp_info_help(Monitor *mon, const QDict *qdict)
> {
> hmp_help_cmd(mon, "info");
> --
> 2.43.0
>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
At 2026-04-19 01:23:46, "Dr. David Alan Gilbert" <dave@treblig.org> wrote:
>* AlanoSong@163.com (AlanoSong@163.com) wrote:
>> The monitor screen can be cluttered after executing commands
>> like `info qtree`. It is useful to have a command to clear
>> current screen, just like linux `clear` command do.
>>
>> This patch has been tested under monitors using stdio, vc,
>> tcp socket, unix socket and serial interfaces.
>>
>> Signed-off-by: Alano Song <AlanoSong@163.com>
>
>Does typing ctrl-l not do it for you in your terminal?
>
>Dave
>
Yes, you are correct that ctrl-l provides basic screen clear,
but the new `clear` command clears both visible screen and
scrollback buffer, just like `clear` command does on my Ubuntu terminal.
I still believe that this patch is useful:
1) Many linux users like me instinctively type `clear`,
when we want to tidy up the terminal.
2) Not everyone is aware of or remembers the ctrl-l shortcut.
A typed command is more discoverable, especially for new users
or those who don't use terminal shortcuts regularly.
Best Regards,
Alano.
// Re-send, it seems that the previous reply email is not visible in the mail list.
>> ---
>> hmp-commands.hx | 14 ++++++++++++++
>> include/monitor/hmp.h | 1 +
>> monitor/hmp-cmds.c | 5 +++++
>> 3 files changed, 20 insertions(+)
>>
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index 5cc4788f12..95f9166732 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -20,6 +20,20 @@ SRST
>> Show the help for all commands or just for command *cmd*.
>> ERST
>>
>> + {
>> + .name = "clear",
>> + .args_type = "",
>> + .params = "",
>> + .help = "clear the monitor screen",
>> + .cmd = hmp_clear,
>> + .flags = "p",
>> + },
>> +
>> +SRST
>> +``clear``
>> + Clear the monitor screen.
>> +ERST
>> +
>> {
>> .name = "commit",
>> .args_type = "device:B",
>> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
>> index e222bea60c..9b66458d21 100644
>> --- a/include/monitor/hmp.h
>> +++ b/include/monitor/hmp.h
>> @@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);
>> void hmp_trace_file(Monitor *mon, const QDict *qdict);
>> void hmp_info_trace_events(Monitor *mon, const QDict *qdict);
>> void hmp_help(Monitor *mon, const QDict *qdict);
>> +void hmp_clear(Monitor *mon, const QDict *qdict);
>> void hmp_info_help(Monitor *mon, const QDict *qdict);
>> void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);
>> void hmp_info_history(Monitor *mon, const QDict *qdict);
>> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
>> index bc26b39d70..3e9485478e 100644
>> --- a/monitor/hmp-cmds.c
>> +++ b/monitor/hmp-cmds.c
>> @@ -218,6 +218,11 @@ void hmp_help(Monitor *mon, const QDict *qdict)
>> hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
>> }
>>
>> +void hmp_clear(Monitor *mon, const QDict *qdict)
>> +{
>> + monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H");
>> +}
>> +
>> void hmp_info_help(Monitor *mon, const QDict *qdict)
>> {
>> hmp_help_cmd(mon, "info");
>> --
>> 2.43.0
>>
>--
> -----Open up your eyes, open up your mind, open up your code -------
>/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
>\ dave @ treblig.org | | In Hex /
> \ _________________________|_____ http://www.treblig.org |_______/
At 2026-04-19 01:23:46, "Dr. David Alan Gilbert" <dave@treblig.org> wrote:
>* AlanoSong@163.com (AlanoSong@163.com) wrote:
>> The monitor screen can be cluttered after executing commands
>> like `info qtree`. It is useful to have a command to clear
>> current screen, just like linux `clear` command do.
>>
>> This patch has been tested under monitors using stdio, vc,
>> tcp socket, unix socket and serial interfaces.
>>
>> Signed-off-by: Alano Song <AlanoSong@163.com>
>
>Does typing ctrl-l not do it for you in your terminal?
>
>Dave
>
Yes, you are correct that ctrl-l provides basic screen clear,
but the new `clear` command clears both visible screen and
scrollback buffer, just like `clear` command does on my Ubuntu terminal.
I still believe that this patch is useful:
1) Many linux users like me instinctively type `clear`
when we want to tidy up the terminal.
2) Not everyone is aware of or remembers the ctrl-l shortcut.
A typed command is more discoverable, especially for new users
or those who don't use terminal shortcuts regularly.
>> ---
>> hmp-commands.hx | 14 ++++++++++++++
>> include/monitor/hmp.h | 1 +
>> monitor/hmp-cmds.c | 5 +++++
>> 3 files changed, 20 insertions(+)
>>
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index 5cc4788f12..95f9166732 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -20,6 +20,20 @@ SRST
>> Show the help for all commands or just for command *cmd*.
>> ERST
>>
>> + {
>> + .name = "clear",
>> + .args_type = "",
>> + .params = "",
>> + .help = "clear the monitor screen",
>> + .cmd = hmp_clear,
>> + .flags = "p",
>> + },
>> +
>> +SRST
>> +``clear``
>> + Clear the monitor screen.
>> +ERST
>> +
>> {
>> .name = "commit",
>> .args_type = "device:B",
>> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
>> index e222bea60c..9b66458d21 100644
>> --- a/include/monitor/hmp.h
>> +++ b/include/monitor/hmp.h
>> @@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);
>> void hmp_trace_file(Monitor *mon, const QDict *qdict);
>> void hmp_info_trace_events(Monitor *mon, const QDict *qdict);
>> void hmp_help(Monitor *mon, const QDict *qdict);
>> +void hmp_clear(Monitor *mon, const QDict *qdict);
>> void hmp_info_help(Monitor *mon, const QDict *qdict);
>> void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);
>> void hmp_info_history(Monitor *mon, const QDict *qdict);
>> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
>> index bc26b39d70..3e9485478e 100644
>> --- a/monitor/hmp-cmds.c
>> +++ b/monitor/hmp-cmds.c
>> @@ -218,6 +218,11 @@ void hmp_help(Monitor *mon, const QDict *qdict)
>> hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
>> }
>>
>> +void hmp_clear(Monitor *mon, const QDict *qdict)
>> +{
>> + monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H");
>> +}
>> +
>> void hmp_info_help(Monitor *mon, const QDict *qdict)
>> {
>> hmp_help_cmd(mon, "info");
>> --
>> 2.43.0
>>
>--
> -----Open up your eyes, open up your mind, open up your code -------
>/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
>\ dave @ treblig.org | | In Hex /
> \ _________________________|_____ http://www.treblig.org |_______/
On 4/18/26 19:23, Dr. David Alan Gilbert wrote:
> * AlanoSong@163.com (AlanoSong@163.com) wrote:
>> The monitor screen can be cluttered after executing commands
>> like `info qtree`. It is useful to have a command to clear
>> current screen, just like linux `clear` command do.
>>
>> This patch has been tested under monitors using stdio, vc,
>> tcp socket, unix socket and serial interfaces.
>>
>> Signed-off-by: Alano Song <AlanoSong@163.com>
>
> Does typing ctrl-l not do it for you in your terminal?
Yeah, we should add support for Ctrl-L to the non-terminal backends
independent of this. However, backends such as socket do not use
readline so they also don't support it right now.
Paolo
> Dave
>
>> ---
>> hmp-commands.hx | 14 ++++++++++++++
>> include/monitor/hmp.h | 1 +
>> monitor/hmp-cmds.c | 5 +++++
>> 3 files changed, 20 insertions(+)
>>
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index 5cc4788f12..95f9166732 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -20,6 +20,20 @@ SRST
>> Show the help for all commands or just for command *cmd*.
>> ERST
>>
>> + {
>> + .name = "clear",
>> + .args_type = "",
>> + .params = "",
>> + .help = "clear the monitor screen",
>> + .cmd = hmp_clear,
>> + .flags = "p",
>> + },
>> +
>> +SRST
>> +``clear``
>> + Clear the monitor screen.
>> +ERST
>> +
>> {
>> .name = "commit",
>> .args_type = "device:B",
>> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
>> index e222bea60c..9b66458d21 100644
>> --- a/include/monitor/hmp.h
>> +++ b/include/monitor/hmp.h
>> @@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);
>> void hmp_trace_file(Monitor *mon, const QDict *qdict);
>> void hmp_info_trace_events(Monitor *mon, const QDict *qdict);
>> void hmp_help(Monitor *mon, const QDict *qdict);
>> +void hmp_clear(Monitor *mon, const QDict *qdict);
>> void hmp_info_help(Monitor *mon, const QDict *qdict);
>> void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);
>> void hmp_info_history(Monitor *mon, const QDict *qdict);
>> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
>> index bc26b39d70..3e9485478e 100644
>> --- a/monitor/hmp-cmds.c
>> +++ b/monitor/hmp-cmds.c
>> @@ -218,6 +218,11 @@ void hmp_help(Monitor *mon, const QDict *qdict)
>> hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
>> }
>>
>> +void hmp_clear(Monitor *mon, const QDict *qdict)
>> +{
>> + monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H");
>> +}
>> +
>> void hmp_info_help(Monitor *mon, const QDict *qdict)
>> {
>> hmp_help_cmd(mon, "info");
>> --
>> 2.43.0
>>
© 2016 - 2026 Red Hat, Inc.