Manual Merge change 3d38805276ffbf60b2f51e18c8278065f934ee76

ID Author Date Message
3d38805276ffbf60b2f51e18c8278065f934ee76 Ray Hayes <rayhayes@rhbe.net>
9/20/2016 11:11:06 AM -07:00 Minor fixes for color handling and newline
handling.
This commit is contained in:
Manoj Ampalam 2016-09-22 19:37:52 -07:00
parent 3e23785c66
commit 57c6793fc0
2 changed files with 42 additions and 11 deletions

View File

@ -250,7 +250,7 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
case 10: case 10:
pszBuffer++; pszBuffer++;
AutoWrap = 1; AutoWrap = 1;
bAtEOLN = TRUE; GoToNextLine();
break; break;
case 12: case 12:
@ -510,6 +510,8 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
else if (bMode & MODE_BRK) else if (bMode & MODE_BRK)
{ {
// Cursor UP // Cursor UP
if (iParam[0] == 0)
iParam[0] = 1;
ConMoveCursorPosition(0, -iParam[0]); ConMoveCursorPosition(0, -iParam[0]);
} }
fcompletion = 1; fcompletion = 1;
@ -523,6 +525,8 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
else if (bMode & MODE_BRK) else if (bMode & MODE_BRK)
{ {
// Cursor DOWN // Cursor DOWN
if (iParam[0] == 0)
iParam[0] = 1;
ConMoveCursorPosition(0, iParam[0]); ConMoveCursorPosition(0, iParam[0]);
} }
fcompletion = 1; fcompletion = 1;
@ -536,6 +540,8 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
else if (bMode & MODE_BRK) else if (bMode & MODE_BRK)
{ {
// Cursor right // Cursor right
if (iParam[0] == 0)
iParam[0] = 1;
ConMoveCursorPosition(iParam[0], 0); ConMoveCursorPosition(iParam[0], 0);
} }
@ -906,7 +912,7 @@ unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEn
break; break;
case 'H': // Cursor Home case 'H': // Cursor Home
ConSetCursorPosition(1, 1); ConSetCursorPosition(0, 0);
pszCurrent++; pszCurrent++;
bAtEOLN = FALSE; bAtEOLN = FALSE;
break; break;

View File

@ -104,7 +104,12 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
if ( os.dwPlatformId == VER_PLATFORM_WIN32_NT ) 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 SetConsoleMode(hOutputConsole, dwAttributes); // Windows NT
} }
else else
@ -285,11 +290,21 @@ BOOL ConSetScreenSize( int xSize, int ySize )
/* ************************************************************ */ /* ************************************************************ */
void ConSetAttribute(int *iParam, int iParamCount) void ConSetAttribute(int *iParam, int iParamCount)
{ {
int iAttr = 0; static int iAttr = 0;
int i = 0; int i = 0;
BOOL bRet = TRUE;
if (iParamCount < 1) 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 else
{ {
for (i=0;i<iParamCount;i++) for (i=0;i<iParamCount;i++)
@ -297,7 +312,12 @@ void ConSetAttribute(int *iParam, int iParamCount)
switch (iParam[i]) switch (iParam[i])
{ {
case ANSI_ATTR_RESET: case ANSI_ATTR_RESET:
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;
break; break;
case ANSI_BRIGHT: case ANSI_BRIGHT:
iAttr |= FOREGROUND_INTENSITY; iAttr |= FOREGROUND_INTENSITY;
@ -315,7 +335,7 @@ void ConSetAttribute(int *iParam, int iParamCount)
case ANSI_HIDDEN: case ANSI_HIDDEN:
break; break;
case ANSI_NOREVERSE: case ANSI_NOREVERSE:
iAttr |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; iAttr = iAttr & ~COMMON_LVB_REVERSE_VIDEO;
break; break;
case ANSI_DEFAULT_FOREGROUND: case ANSI_DEFAULT_FOREGROUND:
// White // White
@ -359,6 +379,9 @@ void ConSetAttribute(int *iParam, int iParamCount)
break; break;
case ANSI_DEFAULT_BACKGROUND: case ANSI_DEFAULT_BACKGROUND:
//Black //Black
iAttr = iAttr & ~BACKGROUND_RED;
iAttr = iAttr & ~BACKGROUND_BLUE;
iAttr = iAttr & ~BACKGROUND_GREEN;
iAttr |= 0; iAttr |= 0;
break; break;
case ANSI_BACKGROUND_BLACK: case ANSI_BACKGROUND_BLACK:
@ -400,11 +423,13 @@ void ConSetAttribute(int *iParam, int iParamCount)
case ANSI_BACKGROUND_BRIGHT: case ANSI_BACKGROUND_BRIGHT:
iAttr |= BACKGROUND_INTENSITY; iAttr |= BACKGROUND_INTENSITY;
break; break;
default:
continue;
} }
} }
if (iAttr) if (iAttr)
SetConsoleTextAttribute(hOutputConsole, (WORD)iAttr); bRet = SetConsoleTextAttribute(hOutputConsole, (WORD)iAttr);
} }
} // End procedure } // End procedure