diff --git a/contrib/win32/win32compat/ansiprsr.c b/contrib/win32/win32compat/ansiprsr.c index d28e9e8..a032df9 100644 --- a/contrib/win32/win32compat/ansiprsr.c +++ b/contrib/win32/win32compat/ansiprsr.c @@ -250,8 +250,8 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd case 10: pszBuffer++; AutoWrap = 1; - bAtEOLN = TRUE; - break; + GoToNextLine(); + break; case 12: pszBuffer++; @@ -510,6 +510,8 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn else if (bMode & MODE_BRK) { // Cursor UP + if (iParam[0] == 0) + iParam[0] = 1; ConMoveCursorPosition(0, -iParam[0]); } fcompletion = 1; @@ -523,6 +525,8 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn else if (bMode & MODE_BRK) { // Cursor DOWN + if (iParam[0] == 0) + iParam[0] = 1; ConMoveCursorPosition(0, iParam[0]); } fcompletion = 1; @@ -536,6 +540,8 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn else if (bMode & MODE_BRK) { // Cursor right + if (iParam[0] == 0) + iParam[0] = 1; ConMoveCursorPosition(iParam[0], 0); } @@ -863,7 +869,7 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn bCS1 = 0; bBkMode = 0; bCharMode = 0; - return pszCurrent; + return pszCurrent; } else return pszBuffer; @@ -906,9 +912,9 @@ unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEn break; case 'H': // Cursor Home - ConSetCursorPosition(1, 1); + ConSetCursorPosition(0, 0); pszCurrent++; - bAtEOLN = FALSE; + bAtEOLN = FALSE; break; case 'I': // Reverse Line Feed pszCurrent++; diff --git a/contrib/win32/win32compat/console.c b/contrib/win32/win32compat/console.c index bfe0f62..854bc10 100644 --- a/contrib/win32/win32compat/console.c +++ b/contrib/win32/win32compat/console.c @@ -104,7 +104,12 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit ) if ( os.dwPlatformId == VER_PLATFORM_WIN32_NT ) { - dwAttributes = (DWORD)ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; // PERFECT in NT + char *term = getenv("TERM"); + dwAttributes = (DWORD)ENABLE_PROCESSED_OUTPUT; // PERFECT in NT + + if (term != NULL && (_stricmp(term, "ansi") == 0 || _stricmp(term, "passthru"))) + dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode(hOutputConsole, dwAttributes); // Windows NT } else @@ -285,11 +290,21 @@ BOOL ConSetScreenSize( int xSize, int ySize ) /* ************************************************************ */ void ConSetAttribute(int *iParam, int iParamCount) { - int iAttr = 0; + static int iAttr = 0; int i = 0; + BOOL bRet = TRUE; if (iParamCount < 1) - SetConsoleTextAttribute(hOutputConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + { + iAttr |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + + iAttr = iAttr & ~BACKGROUND_INTENSITY; + iAttr = iAttr & ~FOREGROUND_INTENSITY; + iAttr = iAttr & ~COMMON_LVB_UNDERSCORE; + iAttr = iAttr & ~COMMON_LVB_REVERSE_VIDEO; + + SetConsoleTextAttribute(hOutputConsole, (WORD)iAttr); + } else { for (i=0;i