All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: AlanoSong@163.com
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [PATCH] monitor: Add `clear` command
Date: Sat, 18 Apr 2026 17:23:46 +0000	[thread overview]
Message-ID: <aeO-IqKqBwtKfW8P@gallifrey> (raw)
In-Reply-To: <20260418133927.43012-1-AlanoSong@163.com>

* 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   |_______/


  reply	other threads:[~2026-04-18 17:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-18 13:39 [PATCH] monitor: Add `clear` command AlanoSong
2026-04-18 17:23 ` Dr. David Alan Gilbert [this message]
2026-04-19  7:43   ` Alano Song
2026-04-21 17:52     ` Dr. David Alan Gilbert
2026-04-22 13:44       ` Alano Song
2026-04-19  8:43   ` Paolo Bonzini
2026-04-20 13:35   ` Alano Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aeO-IqKqBwtKfW8P@gallifrey \
    --to=dave@treblig.org \
    --cc=AlanoSong@163.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.