[hackers] [st] Fix save/restore cursor || Mihail Zenkov

From: <git_AT_suckless.org>
Date: Wed, 02 Oct 2013 20:48:58 +0200

commit 62ab938965f2673e029ae2e2a4244788e673bd70
Author: Mihail Zenkov <mihail.zenkov_AT_gmail.com>
Date: Tue Oct 1 20:02:24 2013 +0200

    Fix save/restore cursor
    
    st was assuming that save/restore cursor position was independent
    of the screen that was shown in each moment, but it is not true,
    because each screen has a different save/restore buffer. This
    patch fixes it.

diff --git a/st.c b/st.c
index 05e285c..12fcc90 100644
--- a/st.c
+++ b/st.c
_AT_@ -1342,13 +1342,14 @@ tfulldirt(void) {
 
 void
 tcursor(int mode) {
- static TCursor c;
+ static TCursor c[2];
+ bool alt = IS_SET(MODE_ALTSCREEN);
 
         if(mode == CURSOR_SAVE) {
- c = term.c;
+ c[alt] = term.c;
         } else if(mode == CURSOR_LOAD) {
- term.c = c;
- tmoveto(c.x, c.y);
+ term.c = c[alt];
+ tmoveto(c[alt].x, c[alt].y);
         }
 }
 
_AT_@ -1854,12 +1855,12 @@ tsetmode(bool priv, bool set, int *args, int narg) {
                         case 1034:
                                 MODBIT(term.mode, set, MODE_8BIT);
                                 break;
- case 1049: /* = 1047 and 1048 */
- case 47:
+ case 1049: /* swap screen & set/restore cursor as xterm */
+ tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
+ case 47: /* swap screen */
                         case 1047:
                                 if (!allowaltscreen)
                                         break;
-
                                 alt = IS_SET(MODE_ALTSCREEN);
                                 if(alt) {
                                         tclearregion(0, 0, term.col-1,
Received on Wed Oct 02 2013 - 20:48:58 CEST

This archive was generated by hypermail 2.3.0 : Wed Oct 02 2013 - 21:00:23 CEST