[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wadd_wch() operates on wrong coords for non-spacing chars
From: |
Roman Zilka |
Subject: |
wadd_wch() operates on wrong coords for non-spacing chars |
Date: |
Wed, 5 Jul 2023 21:51:32 +0200 |
Hello,
according to curs_add_wch(3x) add_wch() adds non-spacing characters to
the base character on the current coordinates. Therefore, the
following program should print "aáa". It prints "áaa", however.
#include <locale.h>
#include <stddef.h>
#include <stdio.h>
#include <curses.h>
int main() {
setlocale(LC_ALL, "");
initscr();
wchar_t *c = L"a";
wchar_t *cmod = L"\u0301";
cchar_t cc;
cchar_t ccmod;
setcchar(&cc, c, 0, 0, NULL);
setcchar(&ccmod, cmod, 0, 0, NULL);
move(0, 0); add_wch(&cc);
move(0, 1); add_wch(&cc);
move(0, 1); add_wch(&ccmod);
move(0, 2); add_wch(&cc);
refresh();
getchar();
endwin();
}
x86_64-pc-linux-gnu, glibc 2.37, LANG="en_US.UTF-8",
TERM="xterm-256color", ncurses 6.4-20230401 (no relevant NEWS items in
any later version), linking against ncursesw.
No matter what the position is, the non-spacing char is printed one
column too early. It also affects addwstr() et al. If this is indeed
intended, please clarify. I'm not on the mailinglist, but I will watch
the archive.
Discovered while fixing a bug in procps-ng's watch(1) regarding
non-spacing chars:
https://gitlab.com/procps-ng/procps/-/merge_requests/186
commit: "watch: Fixed -d ignoring combining characters [BUG]"
Best regards,
-Roman Žilka
- wadd_wch() operates on wrong coords for non-spacing chars,
Roman Zilka <=