bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

misplaced cursor when a double-width character is near the lower-right c


From: Benno Schulenberg
Subject: misplaced cursor when a double-width character is near the lower-right corner
Date: Wed, 13 Jan 2021 12:28:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello Thomas,

When a double-width character is close to the right edge of the bottom row
of a subwindow, and a single-width character is added, then the cursor can
get misplaced, resulting in a misdrawing of the content when a further
character is added.

To reproduce, please download nano-5.4 [1].  (It has to be version 5.4
because earlier versions contain a workaround for VTE-based terminals that
avoids the problem, and later versions will have the workaround restored.)
Configure and compile, and then run:

    src/nano --ignorercfiles --nohelp

Then type ^W and paste "123ㄓ" (without the quotes) as the answer (or if
you prefer to type it: 123 M-V 003113), and type <Home>.  Now hold down
"x" until the cactus character is exactly three spaces before the right
edge.  See that the cursor is on the "1".  Now type "a".  The cursor is
still on the "1".  Now type "b".  Oh: the cursor has moved to the "2".
Now type "c".  Ouch: the screen has scrolled, the cactus character has
been pushed to the next row, the title bar has disappeared, the end of
the prompt bar has "ab1c123 ", and the cursor is below the c.

Now type ^L.  This effectively calls wrefresh(curscr) and makes nano
rewrite the contents of all subwindows.  Now the prompt bar is back
in its place and its end shows things as they should be: "abc123ㄓ".

What seems to happen is: when "b" is typed, ncurses sends commands to
the terminal to draw "b123ㄓ", which makes the cursor reach the last
column of the bottom row, and then somehow ncurses forgets that the
last character was double-width and moves the cursor back only four
positions instead of five.

(The problem does not occur when instead of "ㄓ" two single-width
characters are used, for example "45".)

I can reproduce this on an Xfce Terminal (0.8.7.4), on xterm (330),
on urxvt (9.22), and on a Linux console.  My machine has ncurses-6.1,
but it happens also when linking against recent ncurses-6.2-20210102.

Benno


[1] https://nano-editor.org/dist/v5/nano-5.4.tar.xz

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]