#include <stdio.h> #include <stdlib.h> #include <curses.h> // This program shows bug of rendering in Konsole Version 2.11.2( Using KDE Development Platform 4.11.2) - on OpenSuse 13.1 // // Screenshots of problem: // http://gyazo.com/71e754c61f6aafcd501894d806e1a7f1 (from real wild) // http://gyazo.com/775c9ec8cc81861ff40e62d7350be512 (this test program) // Screenshot of good rendering: // http://gyazo.com/c8ff96af7aa0006d5fb4343a73722ae1 // // To reproduce, build it using // g++ -Wall -fexceptions -g -I/usr/include/ncurses -c ./main.cpp -o ./main.o // g++ -o ./ ./main.o -lncurses // // And then run program in konsole terminal with width <= 80 (width in main func) // Press any key and you will see artifacts at the end of line // If terminal's width > 80 or character is not a whitespace, all renders OK. int main() { int x = 10; int width = 80; WINDOW* stdscr = initscr (); cbreak (); noecho (); nonl (); intrflush (stdscr, false); keypad (stdscr, true); start_color (); init_pair(1, 4, 4); init_pair(2, 7, 7); while (x > 5) { attrset(COLOR_PAIR(2) | A_BOLD); mvaddstr(3, x, "SomeText"); for (int xx = x + 8; xx < width; xx++) { attrset(COLOR_PAIR(1)); // If change next character to any (not space - for example, "_" or "X") all will work ok mvaddstr(3, xx, " "); } refresh(); getch(); x--; } endwin(); return 0; } Reproducible: Always Actual Results: Blue background line is rendered to X=80 coordinate, but at the end of line there are some incorrect symbols (white blocks). Expected Results: Blue background line is rendered to X=80 coordinate. This bug is reproduced in Konsole and Konsole-based (Yakuake) terminal emulators only. In xterm, gnome-terminal and putty this works without troubles.
Also reproduced on Debian 7 (Konsole 2.8.4) http://gyazo.com/e7ad5b49a52803d4276f8fd0887feff5 - but black characters at the end of line instead of white. Color of parasite blocks depends on color scheme selected in Konsole's profile.
After several days of investigation, I have found the source of a problem. If width > 80, ncurses for this line generates sequence of control codes with text, this sequence rerenders it 100%. But when width < 80, ncurses (optimized?) generates sequence of control codes without any text, but with "DEL" control code. Konsole deletes one character, and at end of line it filled with empty flags. XTerm and another terms handle it otherwise: they fill end of line using space with attributes which are set now (see ClearCells func at screen.c file in xterm sources - view https://gist.github.com/elw00d/8890166). If comment ClearCells call in ScrnDeleteChar func implementation, bug will be "reproduced" in xterm too. Proposed patch: https://gist.github.com/anonymous/8890021 I didn't code on C/C++ for several years, and I don't sure that creating anonymous Character object is good in this place, so fix my code, please, if it is buggy from memory consistency point of view.
Thanks for the work and patch - it does appear to fix you test - let me look at it further.
I think this will work + // Append space(s) with current attributes + Character spaceWithCurrentAttrs(' ', _effectiveForeground, _effectiveBackground, + _effectiveRendition, false); + + for (int i = 0; i < n; i++) + _screenLines[_cuY].append(spaceWithCurrentAttrs);
Yes, it works for me - for test program and for original mono application.
Git commit 427de88cc1020c7fb9fb2b8752fddfd4cc0be736 by Kurt Hindenburg. Committed on 09/02/2014 at 16:02. Pushed by hindenburg into branch 'master'. Fix wrong rendering at the end of line when drawing colored whitespaces Previous code just deleted the end characters; new code puts in spaces with current attributes at the end of the line. Thanks to Igor Kostromin elwood.su@gmail.com for bug, research + patch See bko for test code + more info FIXED-IN: 2.13 M +8 -0 src/Screen.cpp http://commits.kde.org/konsole/427de88cc1020c7fb9fb2b8752fddfd4cc0be736
Thanks !
Git commit 3d9c101877290f8d4fffc83b364d7bad6e4c9653 by Kurt Hindenburg. Committed on 09/02/2014 at 16:02. Pushed by hindenburg into branch 'frameworks'. Fix wrong rendering at the end of line when drawing colored whitespaces Previous code just deleted the end characters; new code puts in spaces with current attributes at the end of the line. Thanks to Igor Kostromin elwood.su@gmail.com for bug, research + patch See bko for test code + more info FIXED-IN: 2.13 (cherry picked from commit 427de88cc1020c7fb9fb2b8752fddfd4cc0be736) M +8 -0 src/Screen.cpp http://commits.kde.org/konsole/3d9c101877290f8d4fffc83b364d7bad6e4c9653
Git commit c7b9435d65c4c1324eadc71e66bae2ca78e6dd7a by Kurt Hindenburg. Committed on 09/02/2014 at 16:02. Pushed by hindenburg into branch 'KDE/4.12'. Fix wrong rendering at the end of line when drawing colored whitespaces Previous code just deleted the end characters; new code puts in spaces with current attributes at the end of the line. Thanks to Igor Kostromin elwood.su@gmail.com for bug, research + patch See bko for test code + more info FIXED-IN: 2.13 (cherry picked from commit 427de88cc1020c7fb9fb2b8752fddfd4cc0be736) M +8 -0 src/Screen.cpp http://commits.kde.org/konsole/c7b9435d65c4c1324eadc71e66bae2ca78e6dd7a