diff --git a/SimpleCom/SerialConnection.cpp b/SimpleCom/SerialConnection.cpp index a104761..2dcd2e9 100644 --- a/SimpleCom/SerialConnection.cpp +++ b/SimpleCom/SerialConnection.cpp @@ -31,6 +31,8 @@ typedef struct { SimpleCom::SerialConnection *conn; } TStdOutRedirectorParam; +static COORD current_window_sz = { 0 }; + SimpleCom::SerialConnection::SerialConnection(TString& device, DCB* dcb, HWND hwnd, HANDLE hStdIn, HANDLE hStdOut, bool useTTYResizer, LPCTSTR logfilename, bool enableStdinLogging) : _device(device), @@ -237,8 +239,10 @@ bool SimpleCom::SerialConnection::StdInRedirector(const HANDLE hSerial, const HA ProcessKeyEvents(inputs[idx].Event.KeyEvent, writer); } else if ((inputs[idx].EventType == WINDOW_BUFFER_SIZE_EVENT) && _useTTYResizer) { - CopyMemory(&newConsoleSize, &inputs[idx].Event.WindowBufferSizeEvent, sizeof(COORD)); - isConsoleSizeUpdated = true; + if(memcmp(¤t_window_sz, &inputs[idx].Event.WindowBufferSizeEvent.dwSize, sizeof(COORD)) != 0) { + newConsoleSize = inputs[idx].Event.WindowBufferSizeEvent.dwSize; + isConsoleSizeUpdated = true; + } } if (isConsoleSizeUpdated) { @@ -248,6 +252,7 @@ bool SimpleCom::SerialConnection::StdInRedirector(const HANDLE hSerial, const HA int len = snprintf(buf, sizeof(buf), "%c%d" RESIZER_SEPARATOR "%d%c", RESIZER_START_MARKER, newConsoleSize.Y, newConsoleSize.X, RESIZER_END_MARKER); writer.PutData(buf, len); isConsoleSizeUpdated = false; + current_window_sz = newConsoleSize; } } } @@ -288,6 +293,10 @@ bool SimpleCom::SerialConnection::DoSession(bool allowDetachDevice) { OVERLAPPED serialReadOverlapped = { 0 }; serialReadOverlapped.hEvent = hIoEvent.handle(); + CONSOLE_SCREEN_BUFFER_INFO console_info = { 0 }; + CALL_WINAPI_WITH_DEBUGLOG(GetConsoleScreenBufferInfo(_hStdOut, &console_info), TRUE, __FILE__, __LINE__) + current_window_sz = console_info.dwSize; + // Create stdout redirector TStdOutRedirectorParam param = { .hSerial = hSerial.handle(), diff --git a/tty-resizer/README.md b/tty-resizer/README.md index 4ad8557..2d8987b 100644 --- a/tty-resizer/README.md +++ b/tty-resizer/README.md @@ -93,7 +93,3 @@ Both `Row` and `Col` are unsigned short. When `0x12` (DC2) is received in tty-resizer, subsequent chars are captured in tty-resizer, and they will not propagate to real TTY. `t` is terminator, then capture mode in tty-resizer is finished, and subsequent chars are propagated to real TTY, and `TIOCSWINSZ` ioctl would be issued to the specified TTY. `c` means "cancel" for tty-resizer, then capture mode will be finished, and happens nothing. 0-9 and `;`, `t`, `c` is valid chars on capture mode. Capture mode will be aborted when other char is received - it would be treated as `c`. - -# Known issue - -TTY Resizer might not work fine with full-screen application like Vim. Noisy chars (for Vim) might be input, and TTY Resizer might not be able to set resized console size while that app is running.