From 4e44ad519dc48ed04cba98133d47e899f8340479 Mon Sep 17 00:00:00 2001 From: Jason Hood Date: Thu, 23 Aug 2018 16:54:42 +1000 Subject: [PATCH] Fix creating the wrap console buffer If the console buffer was wider than the window then the wrap buffer would not be created, resulting in erroneous movement. Preserve the height of the wrap buffer so the new width can be set. --- ANSI.c | 19 ++++++++++++------- ansicon.c | 2 +- readme.txt | 10 +++++++--- version.h | 10 +++++----- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ANSI.c b/ANSI.c index 9a2291d..0ef05ae 100644 --- a/ANSI.c +++ b/ANSI.c @@ -197,7 +197,7 @@ v1.83, 16 February, 2018: create the flush thread on first use. - v1.84-wip, 17 February, 26 April to 10 May, 2018: + v1.84, 17 February, 26 April to 10 May, 2018: close the flush handles on detach; dynamically load WINMM.DLL; remove dependency on the CRT and USER32.DLL; @@ -209,6 +209,9 @@ default to 7 or -7 if ANSICON_DEF could not be parsed; scrolling will use the default attribute for new lines; workaround Windows 10 1803 console bug. + + v1.85, 22 August, 2018: + fix creating the wrap buffer. */ #include "ansicon.h" @@ -757,12 +760,14 @@ void FlushBuffer( void ) // Ensure the buffer is the same width (it gets created using the window // width) and contains sufficient lines. GetConsoleScreenBufferInfo( hConOut, &Info ); - if (WIN.Right - WIN.Left + 1 != WIDTH || - BOTTOM - TOP < 2 * nCharInBuffer / WIDTH) - { - HEIGHT = 2 * nCharInBuffer / WIDTH + 1; - SetConsoleScreenBufferSize( hConWrap, Info.dwSize ); - } + wi.dwSize.X = WIDTH; + wi.dwSize.Y = 0; + if (WIN.Right - WIN.Left + 1 != WIDTH) + wi.dwSize.Y = BOTTOM - TOP + 1; + if (BOTTOM - TOP < 2 * nCharInBuffer / WIDTH) + wi.dwSize.Y = 2 * nCharInBuffer / WIDTH + 1; + if (wi.dwSize.Y) + SetConsoleScreenBufferSize( hConWrap, wi.dwSize ); // Put the cursor on the top line, in the same column. wi.CURPOS.X = CUR.X; wi.CURPOS.Y = 0; diff --git a/ansicon.c b/ansicon.c index b3ec044..5af6689 100644 --- a/ansicon.c +++ b/ansicon.c @@ -94,7 +94,7 @@ import the DLL. */ -#define PDATE L"11 May, 2018" +#define PDATE L"22 August, 2018" #include "ansicon.h" #include "version.h" diff --git a/readme.txt b/readme.txt index 5e49874..f25e88f 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Copyright 2005-2018 Jason Hood - Version 1.84. Freeware + Version 1.85. Freeware Description @@ -339,6 +339,9 @@ Version History Legend: + added, - bug-fixed, * changed. + 1.85 - 22 August, 2018: + - fix wrap issues with a buffer bigger than the window. + 1.84 - 11 May, 2018: - close the flush handles on detach; - WriteFile wasn't properly testing if its handle was for a console; @@ -601,6 +604,7 @@ Acknowledgments Vincent Fatica for pointing out \e[K was not right. Nat Kuhn for pointing out the problem with report cursor position. + Michel Kempeneers for discovering the buffer wrap issue. Thiadmer Riemersma for the nearest color algorithm. @@ -625,5 +629,5 @@ Distribution in LICENSE.txt. -========================= -Jason Hood, 11 May, 2018. +============================ +Jason Hood, 22 August, 2018. diff --git a/version.h b/version.h index 705ac7b..e16637a 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ version.h - Version defines. */ -#define PVERS L"1.84" // wide string -#define PVERSA "1.84" // ANSI string (windres 2.16.91 didn't like L) -#define PVERE L"184" // wide environment string -#define PVEREA "184" // ANSI environment string -#define PVERB 1,8,4,0 // binary (resource) +#define PVERS L"1.85" // wide string +#define PVERSA "1.85" // ANSI string (windres 2.16.91 didn't like L) +#define PVERE L"185" // wide environment string +#define PVEREA "185" // ANSI environment string +#define PVERB 1,8,5,0 // binary (resource) #ifdef _WIN64 # define BITS L"64"