Fix unicode rendering issue at ssh client (#338)
This commit is contained in:
parent
d74ae2e5dd
commit
8ff5517c3a
|
@ -56,6 +56,8 @@ int ScrollBottom;
|
||||||
int LastCursorX;
|
int LastCursorX;
|
||||||
int LastCursorY;
|
int LastCursorY;
|
||||||
BOOL isAnsiParsingRequired = FALSE;
|
BOOL isAnsiParsingRequired = FALSE;
|
||||||
|
/* 1 - We track the viewport (visible window) and restore it back because console renders badly when user scroll up/down */
|
||||||
|
int track_view_port = 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 };
|
||||||
|
@ -138,6 +140,10 @@ ConEnterRawMode()
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo(hOutputConsole, &csbi);
|
GetConsoleScreenBufferInfo(hOutputConsole, &csbi);
|
||||||
|
|
||||||
|
/* We track the view port, if conpty is not supported */
|
||||||
|
if (!is_conpty_supported())
|
||||||
|
track_view_port = 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.
|
||||||
*/
|
*/
|
||||||
|
@ -146,7 +152,6 @@ ConEnterRawMode()
|
||||||
debug("console doesn't support the ansi parsing");
|
debug("console doesn't support the ansi parsing");
|
||||||
} else {
|
} else {
|
||||||
debug("console supports the ansi parsing");
|
debug("console supports the ansi parsing");
|
||||||
if (is_conpty_supported()) {
|
|
||||||
console_out_cp_saved = GetConsoleOutputCP();
|
console_out_cp_saved = GetConsoleOutputCP();
|
||||||
console_in_cp_saved = GetConsoleCP();
|
console_in_cp_saved = GetConsoleCP();
|
||||||
if (SetConsoleOutputCP(CP_UTF8))
|
if (SetConsoleOutputCP(CP_UTF8))
|
||||||
|
@ -158,7 +163,8 @@ ConEnterRawMode()
|
||||||
debug3("Successfully set console input code page from:%d to %d", console_in_cp_saved, CP_UTF8);
|
debug3("Successfully set console input code page from:%d to %d", console_in_cp_saved, CP_UTF8);
|
||||||
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());
|
||||||
} else {
|
|
||||||
|
if (track_view_port) {
|
||||||
ConSaveViewRect();
|
ConSaveViewRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +184,7 @@ ConExitRawMode()
|
||||||
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), stdin_dwSavedAttributes);
|
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), stdin_dwSavedAttributes);
|
||||||
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), stdout_dwSavedAttributes);
|
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), stdout_dwSavedAttributes);
|
||||||
|
|
||||||
if (FALSE == isAnsiParsingRequired && is_conpty_supported()) {
|
if (FALSE == isAnsiParsingRequired) {
|
||||||
if (console_out_cp_saved) {
|
if (console_out_cp_saved) {
|
||||||
if(SetConsoleOutputCP(console_out_cp_saved))
|
if(SetConsoleOutputCP(console_out_cp_saved))
|
||||||
debug3("Successfully set console output code page from %d to %d", CP_UTF8, console_out_cp_saved);
|
debug3("Successfully set console output code page from %d to %d", CP_UTF8, console_out_cp_saved);
|
||||||
|
@ -256,7 +262,7 @@ ConSetScreenRect(int xSize, int ySize)
|
||||||
bSuccess = SetConsoleScreenBufferSize(hOutputConsole, coordScreen);
|
bSuccess = SetConsoleScreenBufferSize(hOutputConsole, coordScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSuccess && !is_conpty_supported())
|
if (bSuccess && track_view_port)
|
||||||
ConSaveViewRect();
|
ConSaveViewRect();
|
||||||
|
|
||||||
/* 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! */
|
||||||
|
@ -303,7 +309,7 @@ ConSetScreenSize(int xSize, int ySize)
|
||||||
bSuccess = SetConsoleWindowInfo(hOutputConsole, TRUE, &srWindowRect);
|
bSuccess = SetConsoleWindowInfo(hOutputConsole, TRUE, &srWindowRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSuccess && !is_conpty_supported())
|
if (bSuccess && track_view_port)
|
||||||
ConSaveViewRect();
|
ConSaveViewRect();
|
||||||
|
|
||||||
/* 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! */
|
||||||
|
@ -1622,7 +1628,7 @@ ConMoveCursorTopOfVisibleWindow()
|
||||||
offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top;
|
offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top;
|
||||||
ConMoveVisibleWindow(offset);
|
ConMoveVisibleWindow(offset);
|
||||||
|
|
||||||
if(!is_conpty_supported())
|
if(track_view_port)
|
||||||
ConSaveViewRect();
|
ConSaveViewRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#define dwBuffer 4096
|
#define dwBuffer 4096
|
||||||
|
|
||||||
extern BOOL isAnsiParsingRequired;
|
extern BOOL isAnsiParsingRequired;
|
||||||
|
extern int track_view_port;
|
||||||
extern bool gbVTAppMode;
|
extern bool gbVTAppMode;
|
||||||
BOOL isFirstPacket = TRUE;
|
BOOL isFirstPacket = TRUE;
|
||||||
|
|
||||||
|
@ -62,7 +63,6 @@ processBuffer(HANDLE handle, char *buf, DWORD len, unsigned char **respbuf, size
|
||||||
const char *normalModeSeq = "\x1b[?1l";
|
const char *normalModeSeq = "\x1b[?1l";
|
||||||
const DWORD normalModeSeqLen = (DWORD)strlen(normalModeSeq);
|
const DWORD normalModeSeqLen = (DWORD)strlen(normalModeSeq);
|
||||||
const char *clsSeq = "\x1b[2J";
|
const char *clsSeq = "\x1b[2J";
|
||||||
static int track_view_port = 1;
|
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -71,9 +71,6 @@ processBuffer(HANDLE handle, char *buf, DWORD len, unsigned char **respbuf, size
|
||||||
if(isFirstPacket) {
|
if(isFirstPacket) {
|
||||||
isFirstPacket = FALSE;
|
isFirstPacket = FALSE;
|
||||||
|
|
||||||
if (is_conpty_supported())
|
|
||||||
track_view_port = 0;
|
|
||||||
|
|
||||||
/* Windows server at first sends the "cls" after the connection is established.
|
/* Windows server at first sends the "cls" after the connection is established.
|
||||||
* There is a bug in the conhost which causes the visible window data to loose so to
|
* There is a bug in the conhost which causes the visible window data to loose so to
|
||||||
* mitigate that issue we need to first move the visible window so that the cursor is at the top of the visible window.
|
* mitigate that issue we need to first move the visible window so that the cursor is at the top of the visible window.
|
||||||
|
|
Loading…
Reference in New Issue