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.
This commit is contained in:
Jason Hood 2018-08-23 16:54:42 +10:00
parent 3ab935a1ad
commit 4e44ad519d
4 changed files with 25 additions and 16 deletions

19
ANSI.c
View File

@ -197,7 +197,7 @@
v1.83, 16 February, 2018: v1.83, 16 February, 2018:
create the flush thread on first use. 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; close the flush handles on detach;
dynamically load WINMM.DLL; dynamically load WINMM.DLL;
remove dependency on the CRT and USER32.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; default to 7 or -7 if ANSICON_DEF could not be parsed;
scrolling will use the default attribute for new lines; scrolling will use the default attribute for new lines;
workaround Windows 10 1803 console bug. workaround Windows 10 1803 console bug.
v1.85, 22 August, 2018:
fix creating the wrap buffer.
*/ */
#include "ansicon.h" #include "ansicon.h"
@ -757,12 +760,14 @@ void FlushBuffer( void )
// Ensure the buffer is the same width (it gets created using the window // Ensure the buffer is the same width (it gets created using the window
// width) and contains sufficient lines. // width) and contains sufficient lines.
GetConsoleScreenBufferInfo( hConOut, &Info ); GetConsoleScreenBufferInfo( hConOut, &Info );
if (WIN.Right - WIN.Left + 1 != WIDTH || wi.dwSize.X = WIDTH;
BOTTOM - TOP < 2 * nCharInBuffer / WIDTH) wi.dwSize.Y = 0;
{ if (WIN.Right - WIN.Left + 1 != WIDTH)
HEIGHT = 2 * nCharInBuffer / WIDTH + 1; wi.dwSize.Y = BOTTOM - TOP + 1;
SetConsoleScreenBufferSize( hConWrap, Info.dwSize ); 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. // Put the cursor on the top line, in the same column.
wi.CURPOS.X = CUR.X; wi.CURPOS.X = CUR.X;
wi.CURPOS.Y = 0; wi.CURPOS.Y = 0;

View File

@ -94,7 +94,7 @@
import the DLL. import the DLL.
*/ */
#define PDATE L"11 May, 2018" #define PDATE L"22 August, 2018"
#include "ansicon.h" #include "ansicon.h"
#include "version.h" #include "version.h"

View File

@ -3,7 +3,7 @@
Copyright 2005-2018 Jason Hood Copyright 2005-2018 Jason Hood
Version 1.84. Freeware Version 1.85. Freeware
Description Description
@ -339,6 +339,9 @@ Version History
Legend: + added, - bug-fixed, * changed. 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: 1.84 - 11 May, 2018:
- close the flush handles on detach; - close the flush handles on detach;
- WriteFile wasn't properly testing if its handle was for a console; - 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. Vincent Fatica for pointing out \e[K was not right.
Nat Kuhn for pointing out the problem with report cursor position. 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. Thiadmer Riemersma for the nearest color algorithm.
@ -625,5 +629,5 @@ Distribution
in LICENSE.txt. in LICENSE.txt.
========================= ============================
Jason Hood, 11 May, 2018. Jason Hood, 22 August, 2018.

View File

@ -2,11 +2,11 @@
version.h - Version defines. version.h - Version defines.
*/ */
#define PVERS L"1.84" // wide string #define PVERS L"1.85" // wide string
#define PVERSA "1.84" // ANSI string (windres 2.16.91 didn't like L) #define PVERSA "1.85" // ANSI string (windres 2.16.91 didn't like L)
#define PVERE L"184" // wide environment string #define PVERE L"185" // wide environment string
#define PVEREA "184" // ANSI environment string #define PVEREA "185" // ANSI environment string
#define PVERB 1,8,4,0 // binary (resource) #define PVERB 1,8,5,0 // binary (resource)
#ifdef _WIN64 #ifdef _WIN64
# define BITS L"64" # define BITS L"64"