Revert back to saving buffer cursor position

In v1.70 I had saved the cursor position relative to the window, but
that means should the window scroll, the cursor would appear to be
restored to the wrong position.  It will still be wrong should the
*buffer* be scrolled, but that can't really be helped (well, possibly
it could, but it would be more effort than it's worth).
This commit is contained in:
Jason Hood 2017-10-28 11:19:06 +10:00
parent b5e7a01f7f
commit 67f1d48801
3 changed files with 10 additions and 12 deletions

13
ANSI.c
View File

@ -152,8 +152,9 @@
remove wcstok, avoiding potential interference with the host; remove wcstok, avoiding potential interference with the host;
similarly, use a private heap instead of malloc. similarly, use a private heap instead of malloc.
v1.80, 26 October, 2017: v1.80, 26 to 28 October, 2017:
fix unloading. fix unloading;
revert back to (re)storing buffer cursor position.
*/ */
#include "ansicon.h" #include "ansicon.h"
@ -1076,16 +1077,12 @@ void InterpretEscSeq( void )
case 's': // ESC[s Saves cursor position for recall later case 's': // ESC[s Saves cursor position for recall later
if (es_argc != 0) return; if (es_argc != 0) return;
pState->SavePos.X = CUR.X; pState->SavePos = CUR;
pState->SavePos.Y = CUR.Y - TOP;
DEBUGSTR( 1, "SavePos = %u,%u; CUR = %u,%u; TOP = %u, .Top = %u",
pState->SavePos.X, pState->SavePos.Y, CUR.X, CUR.Y, TOP, Info.srWindow.Top );
return; return;
case 'u': // ESC[u Return to saved cursor position case 'u': // ESC[u Return to saved cursor position
if (es_argc != 0) return; if (es_argc != 0) return;
Pos.X = pState->SavePos.X; Pos = pState->SavePos;
Pos.Y = pState->SavePos.Y + TOP;
if (Pos.X > RIGHT) Pos.X = RIGHT; if (Pos.X > RIGHT) Pos.X = RIGHT;
if (Pos.Y > BOTTOM) Pos.Y = BOTTOM; if (Pos.Y > BOTTOM) Pos.Y = BOTTOM;
SetConsoleCursorPosition( hConOut, Pos ); SetConsoleCursorPosition( hConOut, Pos );

View File

@ -87,7 +87,7 @@
add error codes to some message. add error codes to some message.
*/ */
#define PDATE L"26 October, 2017" #define PDATE L"28 October, 2017"
#include "ansicon.h" #include "ansicon.h"
#include "version.h" #include "version.h"

View File

@ -295,8 +295,9 @@ Version History
Legend: + added, - bug-fixed, * changed. Legend: + added, - bug-fixed, * changed.
1.80 - 27 October, 2017: 1.80 - 28 October, 2017:
- fix unloading. - fix unloading;
* go back to saving the buffer cursor position.
1.72 - 24 December, 2015: 1.72 - 24 December, 2015:
- handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile; - handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile;
@ -524,4 +525,4 @@ Distribution
============================= =============================
Jason Hood, 27 October, 2017. Jason Hood, 28 October, 2017.