public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug tui/28800] non-ascii character cannot display correctly in tui-mode's extended-prompt Date: Wed, 24 May 2023 15:40:43 +0000 [thread overview] Message-ID: <bug-28800-4717-GgFjemSYpC@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-28800-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=28800 Tom de Vries <vries at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vries at gcc dot gnu.org --- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> --- The prompt is printed by tui_puts_internal, which outputs every byte in the string individually. As demonstrator patch, by making tui_puts_internal behave more like tui_puts, that is, output entire strings: ... diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index a1eadcd937d..5cc26f02174 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -521,8 +521,23 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) int prev_col = 0; bool saw_nl = false; - while ((c = *string++) != 0) + while (true) { + const char *next = strpbrk (string, "\n\1\2\033\t"); + + /* Print the plain text prefix. */ + size_t n_chars = next == nullptr ? strlen (string) : next - string; + if (n_chars > 0) + waddnstr (w, string, n_chars); + + /* We finished. */ + if (next == nullptr) + break; + + c = *next; + if (c == 0) + break; + if (c == '\n') saw_nl = true; @@ -530,6 +545,7 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) { /* Ignore these, they are readline escape-marking sequences. */ + ++next; } else { @@ -538,10 +554,12 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) size_t bytes_read = apply_ansi_escape (w, string - 1); if (bytes_read > 0) { - string = string + bytes_read - 1; + next = next + bytes_read - 1; continue; } } + else + next++; do_tui_putc (w, c); if (height != nullptr) @@ -552,6 +570,8 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) prev_col = col; } } + + string = next; } if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) update_cmdwin_start_line (); ... I can see this that the behaviour is now correct: ... └────────────────────────────────────────────────────────────────┘ None No process In: ?? PC: ?? /data/vries/gdb <no frame>:<no attribute num on current thread> ❯ ... I'm not sure yet if this is a proper fix, I suspect that'll involve accumulating using mbrtowc or some such. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-05-24 15:40 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-20 16:03 [Bug tui/28800] New: " wuzy01 at qq dot com 2022-01-20 16:11 ` [Bug tui/28800] " schwab@linux-m68k.org 2022-01-27 12:26 ` aburgess at redhat dot com 2023-05-24 15:40 ` vries at gcc dot gnu.org [this message] 2023-05-24 17:56 ` vries at gcc dot gnu.org 2023-05-26 13:26 ` vries at gcc dot gnu.org
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=bug-28800-4717-GgFjemSYpC@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.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: linkBe 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).