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 v2 2/2] [gdb/tui] Handle unicode chars in prompt
Date: Mon, 12 Jun 2023 17:19:29 +0200 [thread overview]
Message-ID: <3fb08009-9266-8bc3-cf0e-1764f6d67e9e@suse.de> (raw)
In-Reply-To: <87h6rg7ih7.fsf@tromey.com>
On 6/9/23 17:39, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> +#ifdef HAVE_BTOWC
> Tom> + {
> Tom> + int mb_len;
> Tom> + if (is_mb_char (string, mb_len) && mb_len != 1)
> Tom> + {
> Tom> + if (mb_len == 0)
> Tom> + {
> Tom> + /* Multi-byte null char. */
> Tom> + break;
> Tom> + }
> Tom> +
> Tom> + waddnstr (w, string, mb_len);
> Tom> + string += mb_len;
> Tom> + handled = true;
> Tom> + }
> Tom> + }
> Tom> +#endif
>
> I wonder if this would be simplified by using wchar_iterator.
>
> This iterator tries to convert just a single character, and has out
> parameters that reflect which input bytes were converted.
>
> The main benefit would be less #ifdef and no need for is_mb_char in
> tui-io.c.
>
The iterator constructor also needs a specification of encoding and
width. I suppose for encoding we could use host_charset (), but I don't
know how to get the base width of that char set.
ISTM that's a problem that the multibyte functions take care of for us.
Thanks,
- Tom
> You may need to add a method to wchar_iterator to let the caller skip
> some bytes (you wouldn't want to create a new one on each iteration, as
> it calls iconv_open). That way the escape handling could stay pretty
> much the same.
>
> Tom
next prev parent reply other threads:[~2023-06-12 15:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 9:18 [PATCH v2 1/2] [gdb/tui] Simplify tui_puts_internal Tom de Vries
2023-06-09 9:18 ` [PATCH v2 2/2] [gdb/tui] Handle unicode chars in prompt Tom de Vries
2023-06-09 14:40 ` Tom Tromey
2023-06-09 15:39 ` Tom Tromey
2023-06-12 15:19 ` Tom de Vries [this message]
2023-06-12 18:44 ` Tom Tromey
2023-06-15 9:42 ` Tom de Vries
2023-06-09 14:35 ` [PATCH v2 1/2] [gdb/tui] Simplify tui_puts_internal 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=3fb08009-9266-8bc3-cf0e-1764f6d67e9e@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).