[Konsole-devel] Bug#39640: cursor not in proper place after exiting ncurses applications

derekp1 at needcaffeine.net derekp1 at needcaffeine.net
Fri Mar 22 02:54:45 UTC 2002


Package: konsole
Version: 1.0.2 (using KDE 2.2.2 )
Severity: normal
Installed from:    compiled sources
Compiler:          gcc version 2.95.3 20010315 (release)
OS:                Linux (i686) release 2.4.16
OS/Compiler notes: 

Summary:
After exiting vim or less in a konsole session, the cursor goes to the upper-left corner of the screen, with the original screen contents visible.  The xterm included with xfree86 4.2 will always return the cursor to original posistion when exiting these programs instead of to position 1,1.  Both are linked against ncurses 5.2
Details:
The escape sequence that reproduces this behaviour on konqueror yet produces other behaviour on other xterms (varries, see below) is as follows:
[on program startup]
Esc[?1049h  (switch to alternet screen buffer)
Esc[1;24r  (set top and bottom margin)
[on program exit]
Esc[24;1H  (set cursor position (bottom left corner))
Esc[?1049l (return to default screen buffer)

Now, what happens is that Esc[?1049h folowed by any arbitrary text and cursor movement, then followed by Esc[?1049l will do the desired behaviour, that is return the cursor to the same position as before the Esc[?1049h was issued.  However, the Esc[1;24r (set top/bottom margin) ends up putting the cursor at position 1,1 in _both_ screen buffers in konsole, but not in xterm (Xfree86 4.2.0).  The margin set (a.k.a. window set) command does, however, affect both screen buffers in some other xterms I've worked with (specifically what is included with Solaris 2.6), but in those xterms, the Esc[24;1H _also_ affects both screen buffers, such that when vi exits, it will deposit the cursor at the lower-left part of the screen so that your not typing over other text on the screen (konsole has Esc[24;1H only affect the current screen).

This bug may be a bit difficult to reproduce since I noticed that some other curses packages don't issue the Esc[1;24r on initialization.  The best way to reproduce this is to get the konsole window full of text, then issue the four escape sequences at the top of this report. If the cursor returns to where you left off, the bug is gone, but if it goes to the top of the screen, the behaviour is still there.

There are two ways to fix this in konsole:
a) To get Xfree86 4.2.0's xterm behaviour, in the file TEmuVt102.C, function TEmuVt102::setMargins (line 875), change the lines:
    screen[0]->setMargins(t, b);
    screen[1]->setMargins(t, b);
to
    scr->setMargins(t, b);

Or, you can:
b) To get the other xterm's behaviour, change any line in TEmuVt102.C that calls
    scr->setCursorYX(p, q);
to
    screen[0]->setCursorYX(p, q); screen[1]->setCursorYX(p, q);

(specifically, the one at line 520, but the others may apply also).

(Submitted via bugs.kde.org)
(Called from KBugReport dialog)




More information about the konsole-devel mailing list