diff --git a/ANSI.c b/ANSI.c index c89a81c..f5c2172 100644 --- a/ANSI.c +++ b/ANSI.c @@ -187,6 +187,9 @@ fix CRM with all partial RM sequences; check for the empty buffer within the critical section; palette improvements. + + v1.82-wip, 12 February, 2018: + add ANSICON_WRAP environment variable for programs that expect the wrap. */ #include "ansicon.h" @@ -233,6 +236,7 @@ int es_argv[MAX_ARG]; // escape sequence args TCHAR Pt_arg[4096]; // text parameter for Operating System Command int Pt_len; BOOL shifted, G0_special, SaveG0; +BOOL wm = FALSE; // does program detect wrap itself? BOOL awm = TRUE; // autowrap mode BOOL im; // insert mode int screen_top = -1; // initial window top when cleared @@ -662,7 +666,7 @@ void FlushBuffer( void ) return; } - if (!awm && !im) + if ((wm || !awm) && !im && !pState->tb_margins) { if (pState->crm) { @@ -867,6 +871,11 @@ void PushBuffer( WCHAR c ) if (pState->crm) ChBuffer[nCharInBuffer++] = c; FlushBuffer(); + if (wm) + { + MoveDown( TRUE ); + return; + } // Avoid writing the newline if wrap has already occurred. GetConsoleScreenBufferInfo( hConOut, &Info ); if (pState->crm) @@ -3841,6 +3850,9 @@ BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved ) bResult = HookAPIAllMod( Hooks, FALSE, FALSE ); OriginalAttr( lpReserved ); + if (search_env( L"ANSICON_WRAP", prog )) + wm = TRUE; + NtQueryInformationThread = (PNTQIT)GetProcAddress( GetModuleHandle( L"ntdll.dll" ), "NtQueryInformationThread" ); if (NtQueryInformationThread == NULL) diff --git a/ansicon.c b/ansicon.c index e50ce03..ff36aff 100644 --- a/ansicon.c +++ b/ansicon.c @@ -91,7 +91,7 @@ use -pu to unload from the parent. */ -#define PDATE L"28 December, 2017" +#define PDATE L"12 February, 2018" #include "ansicon.h" #include "version.h" diff --git a/readme.txt b/readme.txt index 1569903..1df7aae 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Copyright 2005-2017 Jason Hood - Version 1.80. Freeware + Version 1.82-wip. Freeware Description @@ -135,6 +135,11 @@ Usage rent attributes. The shift state and insert mode are always reset for a new process. + ANSICON will detect when a line wraps at the right margin and suppress a + following newline. Some programs detect the wrap themselves and so the + following newline is actually for a blank line; use the ANSICON_WRAP + variable to indicate as such (see ANSICON_API below). + My version of WriteConsoleA will always set the number of characters writt- en, not the number of bytes. This means writing a double-byte character as two bytes will set 0 the first write (nothing was written) and 1 the second @@ -334,6 +339,9 @@ Version History Legend: + added, - bug-fixed, * changed. + 1.82-wip - 12 February, 2018: + - add ANSICON_WRAP for programs that expect the wrap at right margin. + 1.81 - 28 December, 2017: - fix multiple CRs before LF (including preventing an immediate flush); - fix CR, BS and partial RM during CRM; @@ -600,4 +608,4 @@ Distribution ============================== -Jason Hood, 28 December, 2017. +Jason Hood, 12 February, 2018. diff --git a/version.h b/version.h index 3d4c1b6..427d656 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ version.h - Version defines. */ -#define PVERS L"1.81" // wide string -#define PVERSA "1.81" // ANSI string (windres 2.16.91 didn't like L) -#define PVERE L"181" // wide environment string -#define PVEREA "181" // ANSI environment string -#define PVERB 1,8,1,0 // binary (resource) +#define PVERS L"1.82-wip" // wide string +#define PVERSA "1.82-wip" // ANSI string (windres 2.16.91 didn't like L) +#define PVERE L"182" // wide environment string +#define PVEREA "182" // ANSI environment string +#define PVERB 1,8,2,0 // binary (resource) #ifdef _WIN64 # define BITS L"64"