remove setting the console title (#494)

This commit is contained in:
bagajjal 2021-03-31 11:43:49 -07:00 committed by GitHub
parent 794bf53f49
commit 5bcc5aa4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 25 deletions

View File

@ -56,8 +56,10 @@ int LastCursorX;
int LastCursorY; int LastCursorY;
BOOL isAnsiParsingRequired = FALSE; BOOL isAnsiParsingRequired = FALSE;
BOOL isConsoleVTSeqAvailable = FALSE; BOOL isConsoleVTSeqAvailable = FALSE;
/* 1 - We track the viewport (visible window) and restore it back because console renders badly when user scroll up/down */ /* 1 - We track the viewport (visible window) and restore it back because
int track_view_port = 0; * console renders badly when user scroll up/down. Only used if ConPTY not
* available. */
int track_view_port_no_pty_hack= 0;
char *pSavedScreen = NULL; char *pSavedScreen = NULL;
static COORD ZeroCoord = { 0,0 }; static COORD ZeroCoord = { 0,0 };
COORD SavedScreenSize = { 0,0 }; COORD SavedScreenSize = { 0,0 };
@ -75,8 +77,6 @@ typedef struct _SCREEN_RECORD {
PSCREEN_RECORD pSavedScreenRec = NULL; PSCREEN_RECORD pSavedScreenRec = NULL;
int in_raw_mode = 0; int in_raw_mode = 0;
char *consoleTitle = "OpenSSH SSH client";
HANDLE HANDLE
GetConsoleOutputHandle() GetConsoleOutputHandle()
@ -140,8 +140,6 @@ ConEnterRawMode()
return; return;
} }
SetConsoleTitle(consoleTitle);
dwAttributes = stdin_dwSavedAttributes; dwAttributes = stdin_dwSavedAttributes;
dwAttributes &= ~(ENABLE_LINE_INPUT | dwAttributes &= ~(ENABLE_LINE_INPUT |
ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT); ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
@ -188,7 +186,7 @@ ConEnterRawMode()
/* We track the view port, if conpty is not supported */ /* We track the view port, if conpty is not supported */
if (!is_conpty_supported()) if (!is_conpty_supported())
track_view_port = 1; track_view_port_no_pty_hack= 1;
/* if we are passing rawbuffer to console then we need to move the cursor to top /* if we are passing rawbuffer to console then we need to move the cursor to top
* so that the clearscreen will not erase any lines. * so that the clearscreen will not erase any lines.
@ -210,8 +208,8 @@ ConEnterRawMode()
else else
error("Failed to set console input code page from:%d to %d error:%d", console_in_cp_saved, CP_UTF8, GetLastError()); error("Failed to set console input code page from:%d to %d error:%d", console_in_cp_saved, CP_UTF8, GetLastError());
if (track_view_port) { if (track_view_port_no_pty_hack) {
ConSaveViewRect(); ConSaveViewRect_NoPtyHack();
} }
} }
@ -325,8 +323,8 @@ ConSetScreenRect(int xSize, int ySize)
bSuccess = SetConsoleScreenBufferSize(GetConsoleOutputHandle(), coordScreen); bSuccess = SetConsoleScreenBufferSize(GetConsoleOutputHandle(), coordScreen);
} }
if (bSuccess && track_view_port) if (bSuccess && track_view_port_no_pty_hack)
ConSaveViewRect(); ConSaveViewRect_NoPtyHack();
/* if the current buffer *is* the size we want, don't do anything! */ /* if the current buffer *is* the size we want, don't do anything! */
return bSuccess; return bSuccess;
@ -372,8 +370,8 @@ ConSetScreenSize(int xSize, int ySize)
bSuccess = SetConsoleWindowInfo(GetConsoleOutputHandle(), TRUE, &srWindowRect); bSuccess = SetConsoleWindowInfo(GetConsoleOutputHandle(), TRUE, &srWindowRect);
} }
if (bSuccess && track_view_port) if (bSuccess && track_view_port_no_pty_hack)
ConSaveViewRect(); ConSaveViewRect_NoPtyHack();
/* if the current buffer *is* the size we want, don't do anything! */ /* if the current buffer *is* the size we want, don't do anything! */
return bSuccess; return bSuccess;
@ -1589,7 +1587,7 @@ ConSaveScreen()
} }
void void
ConSaveViewRect() ConSaveViewRect_NoPtyHack()
{ {
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(GetConsoleOutputHandle(), &csbi)) if (GetConsoleScreenBufferInfo(GetConsoleOutputHandle(), &csbi))
@ -1597,10 +1595,10 @@ ConSaveViewRect()
} }
void void
ConRestoreViewRect() ConRestoreViewRect_NoPtyHack()
{ {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
HWND hwnd = FindWindow(NULL, consoleTitle); HWND hwnd = GetConsoleWindow();
WINDOWPLACEMENT wp; WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT); wp.length = sizeof(WINDOWPLACEMENT);
@ -1646,8 +1644,8 @@ ConMoveCursorTopOfVisibleWindow()
offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top; offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top;
ConMoveVisibleWindow(offset); ConMoveVisibleWindow(offset);
if(track_view_port) if(track_view_port_no_pty_hack)
ConSaveViewRect(); ConSaveViewRect_NoPtyHack();
} }
} }

View File

@ -140,8 +140,8 @@ BOOL ConRestoreScreenHandle(SCREEN_HANDLE hScreen);
BOOL ConRestoreScreenColors(); BOOL ConRestoreScreenColors();
SCREEN_HANDLE ConSaveScreenHandle(SCREEN_HANDLE); SCREEN_HANDLE ConSaveScreenHandle(SCREEN_HANDLE);
void ConDeleteScreenHandle(SCREEN_HANDLE hScreen); void ConDeleteScreenHandle(SCREEN_HANDLE hScreen);
void ConSaveViewRect(); void ConSaveViewRect_NoPtyHack();
void ConRestoreViewRect(); void ConRestoreViewRect_NoPtyHack();
void ConDeleteChars(int n); void ConDeleteChars(int n);
void ConSaveWindowsState(); void ConSaveWindowsState();
void ConMoveVisibleWindow(int offset); void ConMoveVisibleWindow(int offset);

View File

@ -44,7 +44,7 @@
extern BOOL isAnsiParsingRequired; extern BOOL isAnsiParsingRequired;
extern BOOL isConsoleVTSeqAvailable; extern BOOL isConsoleVTSeqAvailable;
extern int track_view_port; extern int track_view_port_no_pty_hack;
extern bool gbVTAppMode; extern bool gbVTAppMode;
BOOL isFirstPacket = TRUE; BOOL isFirstPacket = TRUE;
@ -99,14 +99,14 @@ processBuffer(HANDLE handle, char *buf, DWORD len, unsigned char **respbuf, size
/* WriteFile() gets messy when user does scroll up/down so we need to restore the visible window. /* WriteFile() gets messy when user does scroll up/down so we need to restore the visible window.
* It's a conhost bug but we need to live with it as they are not going to back port the fix. * It's a conhost bug but we need to live with it as they are not going to back port the fix.
*/ */
if(track_view_port) if(track_view_port_no_pty_hack)
ConRestoreViewRect(); ConRestoreViewRect_NoPtyHack();
/* Console has the capability to parse so pass the raw buffer to console directly */ /* Console has the capability to parse so pass the raw buffer to console directly */
WriteFile(handle, buf, len, 0, 0); WriteFile(handle, buf, len, 0, 0);
if (track_view_port) if (track_view_port_no_pty_hack)
ConSaveViewRect(); ConSaveViewRect_NoPtyHack();
return; return;
} }