All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: Alano Song <alanosong@163.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [PATCH] monitor: Add `clear` command
Date: Tue, 21 Apr 2026 17:52:54 +0000	[thread overview]
Message-ID: <aee5drWmWZ3Mnw3A@gallifrey> (raw)
In-Reply-To: <142c6c8b.11e3.19da4b172c4.Coremail.alanosong@163.com>

* Alano Song (alanosong@163.com) wrote:
> 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
> >

Hi Alano,

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

OK, mainly because of the difference with the scrollback buffer which I
see is different. (Ctrl-l is a great one to know, it works in almost
everything, not just qemu, it's a basic ASCII control code going
back about 60 years)

Now to get to the magic line:

> >> +void hmp_clear(Monitor *mon, const QDict *qdict)
> >> +{
> >> +    monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H");

Firstly it would be great to comment this; as I read it,
this is:
   clear scrollback
   clear screen
   cursor back to top-left

But, this has a problem - for me on both mate-terminal and
terminator (but not konsole), this doesn't completely clear
the scrollback; it clears most of the scrollback, but leaves
about one page; my guess is what happens here is you clear
the scrollback, but then the current screen goes into it
after/when you clear it.

Looking at the output of the ncurses 'clear' command:

dg@dalek:~$ clear|xxd -g 1
00000000: 1b 5b 48 1b 5b 32 4a 1b 5b 33 4a                 .[H.[2J.[3J

it's got them in the opposite order, cursor, clear screen, clear scrollback
and that's fine in both mate-terminal/terminator & konsole.
(This is Fedora 44 with vte291-0.84.0-1.fc44.x86_64 being used by mate-terminal).
[I can't tell you if that's a bug in one or both of the terminals]

So please, flip the output around, and add a comment.

Thanks,

Dave
> >> +}
> >> +
> >>  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   |_______/
-- 
 -----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-21 17:53 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
2026-04-19  7:43   ` Alano Song
2026-04-21 17:52     ` Dr. David Alan Gilbert [this message]
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=aee5drWmWZ3Mnw3A@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.