mbox series

[v2,0/5] ui/console-vc: various fixes and improvements

Message ID 20250226075913.353676-1-r.peniaev@gmail.com (mailing list archive)
Headers show
Series ui/console-vc: various fixes and improvements | expand

Message

Roman Penyaev Feb. 26, 2025, 7:59 a.m. UTC
This patch series brings several fixes and improvements to the QEMU
virtual console (VC), making it more usable and aligning it better
with VT100 spec. The updates include support for inserting and
deleting characters, better cursor handling and correct position
reporting. Without these changes, the console is hardly usable.

1. Support for DCH (delete) and ICH (insert) commands
  * Properly handles character deletion and insertion as per VT100
    specs.

2. Add support for cursor save/restore (ESC 7 and ESC 8)
  * Implements legacy DEC sequences for compatibility.
  * Ensures cursor attributes are also saved and restored.

3. Fix cursor position reporting
  * Reports cursor position relative to the screen instead of the
    scroll buffer.
  * Fixes issues with tools that rely on accurate cursor placement.

4. Ensure DSR (Device Status Report) responses go to applications
  * Stops terminal from rendering responses to the screen but instead
    send reports back to applications.

5. Handle `ESC ( <ch>` character set sequences
  * Makes `top` output look clean by handling the character set
    commands.

These changes improve the virtual console's compatibility with
terminal-based apps. Without them, the console is quite frustrating to
use.

v1 .. v2:

* The VT spec and ECMA-48 standard are somewhat vague about exactly
  what attributes should be set for the ICH (insert character),
  but various terminal implementations reset the character to the
  default state. Instead of inserting a "space" with the current
  attribute, call `vc_clear_xy()` for the inserted character.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Daniel P. Berrange <berrange@redhat.com>
Cc: qemu-devel@nongnu.org

Roman Penyaev (5):
  ui/console-vc: introduce parsing of the 'ESC ( <ch>' sequence
  ui/console-vc: report to the application instead of screen rendering
  ui/console-vc: report cursor position in the screen not in the scroll
    buffer
  ui/console-vc: add support for cursor DECSC and DECRC commands
  ui/console-vc: implement DCH (delete) and ICH (insert) commands

 ui/console-vc.c | 154 ++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 142 insertions(+), 12 deletions(-)

Comments

Marc-André Lureau Feb. 26, 2025, 10:06 a.m. UTC | #1
Hi,

On Wed, Feb 26, 2025 at 11:59 AM Roman Penyaev <r.peniaev@gmail.com> wrote:
>
> This patch series brings several fixes and improvements to the QEMU
> virtual console (VC), making it more usable and aligning it better
> with VT100 spec. The updates include support for inserting and
> deleting characters, better cursor handling and correct position
> reporting. Without these changes, the console is hardly usable.
>
> 1. Support for DCH (delete) and ICH (insert) commands
>   * Properly handles character deletion and insertion as per VT100
>     specs.
>
> 2. Add support for cursor save/restore (ESC 7 and ESC 8)
>   * Implements legacy DEC sequences for compatibility.
>   * Ensures cursor attributes are also saved and restored.
>
> 3. Fix cursor position reporting
>   * Reports cursor position relative to the screen instead of the
>     scroll buffer.
>   * Fixes issues with tools that rely on accurate cursor placement.
>
> 4. Ensure DSR (Device Status Report) responses go to applications
>   * Stops terminal from rendering responses to the screen but instead
>     send reports back to applications.
>
> 5. Handle `ESC ( <ch>` character set sequences
>   * Makes `top` output look clean by handling the character set
>     commands.
>
> These changes improve the virtual console's compatibility with
> terminal-based apps. Without them, the console is quite frustrating to
> use.
>
> v1 .. v2:
>
> * The VT spec and ECMA-48 standard are somewhat vague about exactly
>   what attributes should be set for the ICH (insert character),
>   but various terminal implementations reset the character to the
>   default state. Instead of inserting a "space" with the current
>   attribute, call `vc_clear_xy()` for the inserted character.
>
> Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Daniel P. Berrange <berrange@redhat.com>
> Cc: qemu-devel@nongnu.org

lgtm,

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

>
> Roman Penyaev (5):
>   ui/console-vc: introduce parsing of the 'ESC ( <ch>' sequence
>   ui/console-vc: report to the application instead of screen rendering
>   ui/console-vc: report cursor position in the screen not in the scroll
>     buffer
>   ui/console-vc: add support for cursor DECSC and DECRC commands
>   ui/console-vc: implement DCH (delete) and ICH (insert) commands
>
>  ui/console-vc.c | 154 ++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 142 insertions(+), 12 deletions(-)
>
> --
> 2.43.0
>