From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] [gdb/tui] Handle unicode chars in prompt
Date: Fri, 9 Jun 2023 11:48:57 +0200 [thread overview]
Message-ID: <24ce50cc-e2c9-c189-298d-6efbff5720a8@suse.de> (raw)
In-Reply-To: <875y89wy48.fsf@tromey.com>
On 5/30/23 19:03, Tom Tromey wrote:
>>> In TUI, the prompt is written out by tui_puts_internal, which outputs one byte
>>> at a time using waddch, which apparantly breaks multi-byte char support.
>>> Fix this by detecting multi-byte chars in tui_puts_internal, and
>>> printing them using
>>> waddnstr.
>
>> FWIW, I just came across this commit, which seems relevant:
>
> Tom> Note that tui_puts_internal remains. It is needed to handle computing
> Tom> the start line of the readline prompt, which is difficult to do
> Tom> properly in the case where redisplaying can also cause the command
> Tom> window to scroll. This might be possible to implement by reverting to
> Tom> single "character" output, by using mbsrtowcs for its side effects to
> Tom> find character boundaries in the input. I have not attempted this.
> Tom> ...
>
> I no longer remember what made this difficult. I wonder if it's
> possible to simply emit as many characters as possible in a single call,
> and then use getyx to figure out the length of the prompt after it has
> been fully displayed. If the prompt wraps or if it takes multiple
> lines, offhand it seems fine to just pick whatever the final column
> happens to be.
>
>
> Using wchar functions in gdb is a pain; at least in the past,
> gdb_wchar.h was written to support systems that don't support these at
> all (DJGPP - not sure if that host even builds any more).
>
> Some characters may take multiple columns (see 'wcwidth'). I'd hope
> that the display-and-getyx approach would avoid having to have gdb
> understand this; though I suppose gdb's pager probably already gets this
> wrong.
Thanks for the pointer.
In v2 I've used #ifdef HAVE_BTOWC to guard the use of mbrtowc, with a
reference to gdb_wchar.h.
[ Though I do wonder whether we could rely on the c++ stdlib instead and
just use std::mbrtowc. ]
I've also fixed a bug, the v1 version didn't take care of wrapping due
to printing a multi-byte character.
I've added a simplification patch to make the structure of the function
easier to understand, making that bug easier to spot.
Thanks,
- Tom
next prev parent reply other threads:[~2023-06-09 9:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 13:25 Tom de Vries
2023-05-26 13:56 ` Eli Zaretskii
2023-05-30 16:51 ` Tom Tromey
2023-06-09 9:34 ` Tom de Vries
2023-06-09 10:21 ` Eli Zaretskii
2023-05-26 15:44 ` Tom de Vries
2023-05-30 17:03 ` Tom Tromey
2023-05-30 18:07 ` DJ Delorie
2023-05-31 0:02 ` Tom Tromey
2023-05-31 11:29 ` Tom de Vries
2023-06-08 22:44 ` Tom de Vries
2023-06-09 15:13 ` Tom Tromey
2023-06-09 9:48 ` Tom de Vries [this message]
2023-06-09 15:15 ` Tom Tromey
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=24ce50cc-e2c9-c189-298d-6efbff5720a8@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).