Running an ncurses program in urxvt squeezes repeating characters in strings. For example I expect "--------"
but I get "-"
.
I have written a short program that reproduces the problem. The code is below.
I have verified that the output is as correct when using xterm rather than urxvt.
This is the first time I am working with ncurses, however, the sample program is as simple as they come. Therefore, I don't think it is likely that the problem is with how I'm using ncurses. This is also supported by the fact that xterm gives the expected results.
I am using urxvt on Arch Linux. I am providing related configuration below too. I have vanilla xterm installed without any additional configuration. Both had zsh running.
Sample Program (C)
#include <curses.h>
int main(){
initscr();
printw("------\n"); // (1) 6 '-' chars urxvt: "------" xterm: "------"
printw("-------\n"); // (2) 7 '-' chars urxvt: "-" xterm: "-------"
printw("--------\n"); // (3) 8 '-' chars urxvt: "-" xterm: "--------"
printw("0--------0\n"); // (4) 8 '-' between '0' urxvt: "0-0" xterm: "0--------0"
printw("xxxxxxxx\n"); // (5) Replacing '-' with 'x' does not make a difference.
printw("---- ----\n"); // (6) Two '-' sequences separated by ' ' display correctly.
printw("12345678\n"); // (7) Strings with different characters display correctly.
for(int i=0; i<8; i++) addch('-'); // (8) 8 '-' chars urxvt: "-" xterm: "--------"
addch('\n');
for(char c='0'; c<'8'; c++) addch(c); // (9) Both display correctly
addch('\n');
refresh();
getch();
endwin();
return 0;
}
xterm Output (Correct)
------
-------
--------
0--------0
xxxxxxxx
---- ----
12345678
--------
01234567
urxvt Output (Incorrect)
------
-
-
0-0
x
---- ----
12345678
-
01234567
Observations
- Up to 6 repeating characters are displayed correctly.
- 7 and more repeating characters are displayed as a single character.
- This problem does not occur if the characters are non-repeating, so the length of the string itself is not the problem.
- The location of the repeating substring is not important. In (7), the substring that got squeezed was sandwiched by
'0'
characters on each end. - The problem is not due to a specific character. It happens with
'-'
as well as'x'
.
- The problem is not due to a specific character. It happens with
- The problem was observed using both the
printw
andaddch
functions. The associated manpages state that these functions move the cursor, so there should be no need to explicitly move the cursor. This is obviously the case, as otherwise the problem would not be limited to repeating characters, and would also happen with xterm.
urxvt Configuration
- rxvt-unicode v9.22
$TERM
isxterm-256color