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 00:44:39 +0200 [thread overview]
Message-ID: <26eace21-84bf-7d9d-051b-93f2bc38edd7@suse.de> (raw)
In-Reply-To: <678ad6f8-b39e-0f0d-5933-62f81c44d27c@suse.de>
On 5/31/23 13:29, Tom de Vries wrote:
> 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.
>
> I've given that a try, and that seems to work.
>
> I also realized that we don't cover wrapping prompts in the testsuite,
> so I wrote a test-case (
> https://sourceware.org/pipermail/gdb-patches/2023-May/199950.html ).
I've committed the test-case (excluding the proposed fix for now), with
an extra check that FAILs in combination with this patch:
...
FAIL: gdb.tui/long-prompt.exp: prompt size == width + 1: end of screen:
scrolling
...
because we have:
...
17 (gdb) set prompt 123456789A123456789B123
18 456789C123456789D>
19 123456789A123456789B123456789C123456789D
20 123456789A123456789B123456789C123456789D
21 123456789A123456789B123456789C123456789D
22 >set prompt (gdb)
23 (gdb)
...
instead of the expected:
...
19 (gdb) set prompt 123456789A123456789B123
20 456789C123456789D>
21 123456789A123456789B123456789C123456789D
22 >set prompt (gdb)
23 (gdb)
...
The logic I used in this patch:
...
+ if (height != nullptr)
+ {
+ int line = getcury (w);
+ *height += line - prev_line;
}
...
was to use the current line to detect a wrap but that doesn't work if
writing the prompt wraps at the last line which then generates a scroll.
This is the reason that a wrap is detected in the original code using a
reduction in wrap position.
But AFAIU that doesn't work either for this "maximum-string" approach.
If the string is long enough, it's possible to wrap and increase column
position.
In conclusion, AFAIU this approach doesn't work.
Thanks,
- Tom
next prev parent reply other threads:[~2023-06-08 22:44 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 [this message]
2023-06-09 15:13 ` Tom Tromey
2023-06-09 9:48 ` Tom de Vries
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=26eace21-84bf-7d9d-051b-93f2bc38edd7@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).