0

I've recently by writing some programs in C using the ncurses library on an Arch Linux machine. I've of course been using printw to print text out to the screen (specifically stdscr). However, I've been having a weird issue when using printw. If I try to print out multiple of the same character one after the other, printw will only print one of those characters.

Example:

printw("- - - - - - - - -"); // prints all the characters without any issues

printw("-----------------"); // only prints a single dash ('-')

Now, the only odd part, is that I've found this glitch to be true on every Arch Linux terminal I've used, except for the default XFCE terminal. This glitch happened in iTerm, putty, and termius (I was ssh'd into the Arch Linux machine when using each of the terminals).

So, does anyone know why this would happen? Is it a feature? Something for optimization? And if so, is there anyway to turn it off? Or does it possibly have something to do with the terminals or ssh?

Any help is much appreciated! Also, if you would like to take a look at the program in question, just let me know, and I can link the github for it.

Thanks!

Mathieu
  • 8,840
  • 7
  • 32
  • 45
jsmith
  • 151
  • 1
  • 8
  • 1
    Yes, link please. Small example however would be better. – purec May 31 '18 at 14:43
  • Have you run the code on any other machines that Arch Linux? Does the problem only appear on Arch Linux, or elsewhere? It isn't obvious that `ssh` should be a factor. – Jonathan Leffler May 31 '18 at 15:27
  • I've reproduced it on Debian "testing" Buster, but only with PuTTY so far. Ncurses 6 seems to use the CSI _p_ b escape sequence to repeat the last graphic character _p_ times if it thinks the terminal supports it. I suspect the xterm emulation of PuTTY doesn't support it. Changing the `TERM` environment should help. E.g. set `TERM=putty` for PuTTY. – Ian Abbott May 31 '18 at 15:42
  • 1
    Continuing my last comment, there is a relevant entry in the [Ncurses changelog for 20170729](https://invisible-island.net/ncurses/NEWS.html#t20170729): **+ add "rep" to xterm-new, available since 1997/01/26 -TD**. "rep" is the repeat character sequence. – Ian Abbott May 31 '18 at 16:07
  • It seems PuTTY's author is aware of the problem and has [fixed it](https://git.tartarus.org/?p=simon/putty.git;a=commit;h=2b5b843849b2d491cac563f81fbb41d2fa17dde3) in the latest development snapshot. – Ian Abbott May 31 '18 at 16:36
  • Ian Abbott, thank you very much! Exporting TERM as putty in bashrc fixed the problem. I haven't checked out the other solutions for the other terminals, but putty is mostly what I use. – jsmith Jun 01 '18 at 04:50
  • Possible duplicate of [ncurses in urxvt does not print repeating characters](https://stackoverflow.com/questions/46507473/ncurses-in-urxvt-does-not-print-repeating-characters) – Thomas Dickey Jun 02 '18 at 11:03

0 Answers0