Remove passthru, fix check for ansi console support. Removed VT52. (https://github.com/PowerShell/Win32-OpenSSH/issues/430)
This commit is contained in:
parent
d34edc89db
commit
d10d8a8f36
|
@ -56,6 +56,8 @@ extern int ScreenY;
|
|||
extern int ScrollTop;
|
||||
extern int ScrollBottom;
|
||||
|
||||
extern BOOL bAnsiParsing;
|
||||
|
||||
// end of imports from outside module
|
||||
|
||||
bool gbVTAppMode = false;
|
||||
|
@ -67,7 +69,7 @@ static int AutoWrap = 1;
|
|||
|
||||
BOOL bAtEOLN = FALSE;
|
||||
|
||||
static int term_mode;
|
||||
static int term_mode = TERM_ANSI;
|
||||
|
||||
// ParseANSI globals - these need to be here, because sometimes blocks are sent
|
||||
// in mid ANSI sequence
|
||||
|
@ -176,14 +178,10 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
|
|||
unsigned char * pszCurrent = pszBuffer+1;
|
||||
unsigned char * pszNewCurrent = pszCurrent;
|
||||
|
||||
if (term_mode == TERM_ANSI)
|
||||
if (term_mode == TERM_ANSI && bAnsiParsing)
|
||||
{
|
||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||
}
|
||||
else if (term_mode == TERM_VT52)
|
||||
{
|
||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||
}
|
||||
|
||||
if (pszCurrent == pszNewCurrent) // Pointer didn't move inside Parse function
|
||||
{
|
||||
|
@ -294,10 +292,6 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
|
|||
{
|
||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||
}
|
||||
else if (term_mode == TERM_VT52)
|
||||
{
|
||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||
}
|
||||
}
|
||||
if (pszNewCurrent > pszCurrent)
|
||||
pszBuffer = pszNewCurrent;
|
||||
|
@ -427,11 +421,6 @@ void ConSetExtendedMode(int iFunction, BOOL bEnable)
|
|||
break;
|
||||
|
||||
}
|
||||
|
||||
if ((iFunction == 2) && (bEnable))
|
||||
{
|
||||
term_mode = TERM_VT52;
|
||||
}
|
||||
}
|
||||
|
||||
#define MODE_EXT 0x00000001
|
||||
|
@ -893,108 +882,3 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
|||
else
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer;
|
||||
int iLine;
|
||||
int iColumn;
|
||||
|
||||
switch ((unsigned char) *pszCurrent)
|
||||
{
|
||||
case 'A': // Cursor Up
|
||||
ConMoveCursorPosition(0, -1);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 'B': // Cursor Down
|
||||
ConMoveCursorPosition(0, 1);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 'C': // Cursor Right
|
||||
ConMoveCursorPosition(1, 0);
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case 'D': // Cursor Left
|
||||
ConMoveCursorPosition(-1, 0);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 'F': // Special Graphics Character Set
|
||||
case 'G': // ASCII Character Set
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case 'H': // Cursor Home
|
||||
ConSetCursorPosition(1, 1);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
case 'I': // Reverse Line Feed
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case 'J': // Erase to End of Screen
|
||||
ConClearEOScreen();
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case 'K': // Erase to End of Line
|
||||
ConClearEOLine();
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case 'Y': // Direct Cursor Addressing
|
||||
pszCurrent = GetNextChar(pszCurrent, pszBufferEnd);
|
||||
if (pszCurrent != NULL)
|
||||
{
|
||||
iLine = *pszCurrent - 31;
|
||||
|
||||
pszCurrent = GetNextChar(pszCurrent, pszBufferEnd);
|
||||
if (pszCurrent != NULL)
|
||||
{
|
||||
iColumn = *pszCurrent - 31;
|
||||
ConSetCursorPosition(iLine,iColumn);
|
||||
pszCurrent++;
|
||||
}
|
||||
else
|
||||
pszCurrent = pszBuffer;
|
||||
}
|
||||
else
|
||||
pszCurrent = pszBuffer;
|
||||
break;
|
||||
|
||||
case 'Z': // Identify
|
||||
*respbuf = VT52_TERMINAL_ID;
|
||||
if (resplen != NULL)
|
||||
{
|
||||
*resplen = 3;
|
||||
}
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case '=': // Enter Alt Keypad mode
|
||||
case '>': // Exit Alt Keypad mode
|
||||
case '1': // Graphics processor on
|
||||
case '2': // Graphics processor off
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
case '<': // Enter ANSI mode
|
||||
term_mode = TERM_ANSI;
|
||||
pszCurrent++;
|
||||
break;
|
||||
|
||||
default:
|
||||
pszCurrent++;
|
||||
break;
|
||||
}
|
||||
|
||||
return pszCurrent;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,12 +37,10 @@
|
|||
#define __ANSIPRSR_H
|
||||
|
||||
#define TERM_ANSI 0
|
||||
#define TERM_VT52 1
|
||||
|
||||
unsigned char * ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
||||
unsigned char * GetNextChar(unsigned char * pszBuffer, unsigned char *pszBufferEnd);
|
||||
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
||||
|
||||
#define true TRUE
|
||||
#define false FALSE
|
||||
|
|
|
@ -57,6 +57,8 @@ int ScrollBottom;
|
|||
int LastCursorX;
|
||||
int LastCursorY;
|
||||
|
||||
BOOL bAnsiParsing = FALSE;
|
||||
|
||||
char *pSavedScreen = NULL;
|
||||
static COORD ZeroCoord = {0,0};
|
||||
COORD SavedScreenSize = {0,0};
|
||||
|
@ -82,6 +84,7 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
|||
OSVERSIONINFO os;
|
||||
DWORD dwAttributes = 0;
|
||||
DWORD dwRet = 0;
|
||||
BOOL bRet = FALSE;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
static bool bFirstConInit = true;
|
||||
|
||||
|
@ -91,13 +94,13 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
|||
hOutputConsole = GetStdHandle(OutputHandle);
|
||||
if (hOutputConsole == INVALID_HANDLE_VALUE) {
|
||||
dwRet = GetLastError();
|
||||
printf("GetStdHandle failed with %d\n", dwRet);
|
||||
printf("GetStdHandle on OutputHandle failed with %d\n", dwRet);
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes)) {
|
||||
dwRet = GetLastError();
|
||||
printf("GetConsoleMode failed with %d\n", GetLastError());
|
||||
printf("GetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
|
@ -106,12 +109,23 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
|||
ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
|
||||
dwAttributes |= ENABLE_WINDOW_INPUT;
|
||||
|
||||
char *term = getenv("TERM");
|
||||
if (!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes)) { // Windows NT
|
||||
dwRet = GetLastError();
|
||||
printf("SetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
if (term != NULL && (_stricmp(term, "ansi") == 0 || _stricmp(term, "passthru") == 0))
|
||||
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||
if (!GetConsoleMode(hOutputConsole, &dwAttributes)) {
|
||||
dwRet = GetLastError();
|
||||
printf("GetConsoleMode on hOutputConsole failed with %d\n", dwRet);
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes); // Windows NT
|
||||
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||
|
||||
if (!SetConsoleMode(hOutputConsole, dwAttributes)) { // Windows NT
|
||||
bAnsiParsing = TRUE;
|
||||
}
|
||||
|
||||
ConSetScreenX();
|
||||
ConSetScreenY();
|
||||
|
|
|
@ -57,16 +57,9 @@ size_t telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t
|
|||
unsigned char* pszHead = NULL;
|
||||
unsigned char* pszTail = NULL;
|
||||
|
||||
char *term = NULL;
|
||||
|
||||
if (len == 0)
|
||||
return len;
|
||||
|
||||
term = getenv("TERM");
|
||||
|
||||
if (term != NULL && _stricmp(term, "passthru") == 0)
|
||||
return len;
|
||||
|
||||
// Transform a single carriage return into a single linefeed before
|
||||
// continuing.
|
||||
if ((len == 1) && (buf[0] == 13))
|
||||
|
|
Loading…
Reference in New Issue