From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Allow check-mark to be changed for CLI
Date: Wed, 25 Jun 2025 18:21:10 +0100 [thread overview]
Message-ID: <5511fb41-26e1-491c-be82-9b6ad20a2d55@palves.net> (raw)
In-Reply-To: <87ldpfygha.fsf@tromey.com>
On 2025-06-25 16:43, Tom Tromey wrote:
> Pedro> So maybe all we need is to base the "current" column's width
> Pedro> depend on the wcwidth of the character used.
>
> I think to do this we'd need something better than wcwidth. See
> appended. Also as Eli points out, the terminal itself can do something
> other than whatever wcwidth reports.
>
> Tom
>
> #define _XOPEN_SOURCE
> #include <wchar.h>
> #include <stdio.h>
>
> #define C L"👉"
>
> int main() {
> printf ("width = %d\n", wcswidth (C, wcslen (C)));
> printf ("of char = %d\n", wcwidth (C[0]));
> return 0;
> }
>
> bapiya. gcc -o q q.c
> bapiya. ./q
> width = -1
> of char = -1
>
That seems to be something with the locale. Yours returns -1 for me too, but the below returns 2:
#define _XOPEN_SOURCE
#include <wchar.h>
#include <stdio.h>
#include <locale.h>
#define C L"👉"
int main()
{
setlocale (LC_CTYPE, "");
printf ("width = %d\n", wcswidth (C, wcslen (C)));
printf ("of char = %d\n", wcwidth (C[0]));
return 0;
}
$ gcc wcwidth.c -o wcwidth
$ ./wcwidth
width = 2
of char = 2
next prev parent reply other threads:[~2025-06-25 17:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 20:18 [PATCH 0/2] Use check-mark for current row of CLI table Tom Tromey
2025-05-09 20:18 ` [PATCH 1/2] Introduce ui_out::field_check_mark Tom Tromey
2025-05-14 2:10 ` Kevin Buettner
2025-05-09 20:18 ` [PATCH 2/2] Allow check-mark to be changed for CLI Tom Tromey
2025-05-10 6:23 ` Eli Zaretskii
2025-05-10 6:32 ` Eli Zaretskii
2025-05-16 14:18 ` Tom Tromey
2025-05-16 16:09 ` Eli Zaretskii
2025-05-23 15:00 ` Kévin Le Gouguec
2025-05-23 15:42 ` Eli Zaretskii
2025-06-11 13:53 ` Tom Tromey
2025-05-14 15:41 ` Andrew Burgess
2025-05-16 14:20 ` Tom Tromey
2025-05-16 16:16 ` Eli Zaretskii
2025-06-25 19:11 ` Pedro Alves
2025-06-26 5:51 ` Eli Zaretskii
2025-06-26 10:35 ` Pedro Alves
2025-06-26 12:32 ` Eli Zaretskii
2025-06-30 23:51 ` Pedro Alves
2025-06-30 23:58 ` Pedro Alves
2025-05-19 12:54 ` Andrew Burgess
2025-06-20 16:22 ` Pedro Alves
2025-06-24 16:58 ` Tom Tromey
2025-06-25 10:05 ` Pedro Alves
2025-06-25 15:43 ` Tom Tromey
2025-06-25 17:21 ` Pedro Alves [this message]
2025-06-27 16:17 ` 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=5511fb41-26e1-491c-be82-9b6ad20a2d55@palves.net \
--to=pedro@palves.net \
--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