summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2010-04-03 00:52:53 -0400
committerSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2010-04-03 00:52:53 -0400
commitf95352946080be803b794c9f2733d8c809c1a39a (patch)
tree8b458cd585c4b54295fdff356ff844ada1315afa
parentd6e9eb25e92e548f86ffd78a604022c47303aacc (diff)
downloadscreen-f95352946080be803b794c9f2733d8c809c1a39a.tar.gz
Improve cursor store/restore on smcup/rmcup.
When going to alternate screen buffer on smcup, the terminal is supposed to store the cursor position, rendition etc. Screen used to store only the position (and that was just a little buggy anyway). So change this behaviour to store all information about the cursor, and restore everything on rmcup. Apparently, the terminal is supposed to store the cursor for smcup (CSI ? 1049 h) and DECSC (ESC 7, CSI s, CSI ? 1048 h) separately. So be it.
-rw-r--r--src/ansi.c65
-rw-r--r--src/resize.c11
-rw-r--r--src/window.h4
3 files changed, 46 insertions, 34 deletions
diff --git a/src/ansi.c b/src/ansi.c
index 685907a..46e3e01 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -122,8 +122,8 @@ static void DesignateCharset __P((int, int));
static void MapCharset __P((int));
static void MapCharsetR __P((int));
#endif
-static void SaveCursor __P((void));
-static void RestoreCursor __P((void));
+static void SaveCursor __P((struct cursor *));
+static void RestoreCursor __P((struct cursor *));
static void BackSpace __P((void));
static void Return __P((void));
static void LineFeed __P((int));
@@ -987,10 +987,10 @@ int c, intermediate;
Report("\033[?%d;%dc", 1, 2);
break;
case '7':
- SaveCursor();
+ SaveCursor(&curr->w_saved);
break;
case '8':
- RestoreCursor();
+ RestoreCursor(&curr->w_saved);
break;
case 'c':
ClearScreen();
@@ -1233,7 +1233,7 @@ int c, intermediate;
LGotoPos(&curr->w_layer, curr->w_x, curr->w_y);
break;
case 's':
- SaveCursor();
+ SaveCursor(&curr->w_saved);
break;
case 't':
switch(a1)
@@ -1274,7 +1274,7 @@ int c, intermediate;
}
break;
case 'u':
- RestoreCursor();
+ RestoreCursor(&curr->w_saved);
break;
case 'I':
if (!a1)
@@ -1431,15 +1431,28 @@ int c, intermediate;
if (use_altscreen)
{
if (i)
- EnterAltScreen(curr);
+ {
+ if (!curr->w_alt.on)
+ SaveCursor(&curr->w_alt.cursor);
+ EnterAltScreen(curr);
+ }
else
- LeaveAltScreen(curr);
+ {
+ LeaveAltScreen(curr);
+ RestoreCursor(&curr->w_alt.cursor);
+ }
if (a1 == 47 && !i)
curr->w_saved.on = 0;
LRefreshAll(&curr->w_layer, 0);
LGotoPos(&curr->w_layer, curr->w_x, curr->w_y);
}
break;
+ case 1048:
+ if (i)
+ SaveCursor(&curr->w_saved);
+ else
+ RestoreCursor(&curr->w_saved);
+ break;
/* case 66: NKM: Numeric keypad appl mode */
/* case 68: KBUM: Keyboard usage mode (data process) */
case 1000: /* VT200 mouse tracking */
@@ -1755,34 +1768,36 @@ int n;
#endif /* FONT */
static void
-SaveCursor()
+SaveCursor(cursor)
+struct cursor *cursor;
{
- curr->w_saved.on = 1;
- curr->w_saved.x = curr->w_x;
- curr->w_saved.y = curr->w_y;
- curr->w_saved.Rend = curr->w_rend;
+ cursor->on = 1;
+ cursor->x = curr->w_x;
+ cursor->y = curr->w_y;
+ cursor->Rend = curr->w_rend;
#ifdef FONT
- curr->w_saved.Charset = curr->w_Charset;
- curr->w_saved.CharsetR = curr->w_CharsetR;
- bcopy((char *) curr->w_charsets, (char *) curr->w_saved.Charsets,
+ cursor->Charset = curr->w_Charset;
+ cursor->CharsetR = curr->w_CharsetR;
+ bcopy((char *) curr->w_charsets, (char *) cursor->Charsets,
4 * sizeof(int));
#endif
}
static void
-RestoreCursor()
+RestoreCursor(cursor)
+struct cursor *cursor;
{
- if (!curr->w_saved.on)
+ if (!cursor->on)
return;
- LGotoPos(&curr->w_layer, curr->w_saved.x, curr->w_saved.y);
- curr->w_x = curr->w_saved.x;
- curr->w_y = curr->w_saved.y;
- curr->w_rend = curr->w_saved.Rend;
+ LGotoPos(&curr->w_layer, cursor->x, cursor->y);
+ curr->w_x = cursor->x;
+ curr->w_y = cursor->y;
+ curr->w_rend = cursor->Rend;
#ifdef FONT
- bcopy((char *) curr->w_saved.Charsets, (char *) curr->w_charsets,
+ bcopy((char *) cursor->Charsets, (char *) curr->w_charsets,
4 * sizeof(int));
- curr->w_Charset = curr->w_saved.Charset;
- curr->w_CharsetR = curr->w_saved.CharsetR;
+ curr->w_Charset = cursor->Charset;
+ curr->w_CharsetR = cursor->CharsetR;
curr->w_ss = 0;
curr->w_FontL = curr->w_charsets[curr->w_Charset];
curr->w_FontR = curr->w_charsets[curr->w_CharsetR];
diff --git a/src/resize.c b/src/resize.c
index 0f24ca5..ec67a7a 100644
--- a/src/resize.c
+++ b/src/resize.c
@@ -976,6 +976,10 @@ int wi, he, hi;
p->w_saved.y = 0;
if (p->w_saved.y >= he)
p->w_saved.y = he - 1;
+ if (p->w_alt.cursor.x > wi)
+ p->w_alt.cursor.x = wi;
+ if (p->w_alt.cursor.y >= he)
+ p->w_alt.cursor.y = he - 1;
/* reset scrolling region */
p->w_top = 0;
@@ -1043,8 +1047,6 @@ struct win *p;
p->w_alt.mlines = 0;
p->w_alt.width = 0;
p->w_alt.height = 0;
- p->w_alt.x = 0;
- p->w_alt.y = 0;
#ifdef COPY_PASTE
if (p->w_alt.hlines)
{
@@ -1071,8 +1073,6 @@ struct win *p;
SWAP(width, t);
SWAP(height, t);
SWAP(histheight, t);
- SWAP(x, t);
- SWAP(y, t);
#ifdef COPY_PASTE
SWAP(hlines, ml);
@@ -1085,7 +1085,6 @@ void
EnterAltScreen(p)
struct win *p;
{
- int ox = p->w_x, oy = p->w_y;
if (!p->w_alt.on)
{
/* If not already using the alternate screen buffer, then create
@@ -1101,8 +1100,6 @@ struct win *p;
p->w_histheight = 0;
}
ChangeWindowSize(p, p->w_alt.width, p->w_alt.height, p->w_alt.histheight);
- p->w_x = ox;
- p->w_y = oy;
p->w_alt.on = 1;
}
diff --git a/src/window.h b/src/window.h
index 07a8fa5..1f70f39 100644
--- a/src/window.h
+++ b/src/window.h
@@ -188,7 +188,7 @@ struct win
int w_charsets[4]; /* Font = charsets[Charset] */
#endif
int w_ss;
- struct {
+ struct cursor {
int on;
int x, y;
struct mchar Rend;
@@ -284,10 +284,10 @@ struct win
int width;
int height;
int histheight;
- int x, y;
#ifdef COPY_PASTE
struct mline *hlines;
int histidx;
+ struct cursor cursor;
#endif
} w_alt;