From d01917c82d519feca5f937fc52a96ac3f22f4656 Mon Sep 17 00:00:00 2001 From: Christian Burger Date: Thu, 7 Apr 2022 14:28:35 +0200 Subject: [PATCH] increased PTY client output buffer size Corrected error checking for reading output from the client while at it. --- NCursesPtyWindow.cpp | 6 +++--- NCursesPtyWindow.hpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NCursesPtyWindow.cpp b/NCursesPtyWindow.cpp index 510febe..24e02bc 100644 --- a/NCursesPtyWindow.cpp +++ b/NCursesPtyWindow.cpp @@ -87,9 +87,9 @@ namespace krikkel::NCursesPtyWindow void NCursesPtyWindow::readFromPtyClient() { - size_t bytesRead = read(fdPtyHost, clientOutputBuffer, CLIENT_OUTPUT_BUFFER_SIZE); - if(bytesRead) - vterm_input_write(pseudoTerminal, clientOutputBuffer, bytesRead); + size_t bytesRead = read(fdPtyHost, ptyClientOutputBuffer, PTY_CLIENT_OUTPUT_BUFFER_SIZE); + if(bytesRead != -1 && bytesRead != 0) + vterm_input_write(pseudoTerminal, ptyClientOutputBuffer, bytesRead); } VTermScreenCallbacks NCursesPtyWindow::screenCallbacks = diff --git a/NCursesPtyWindow.hpp b/NCursesPtyWindow.hpp index 823bb26..13e6df8 100644 --- a/NCursesPtyWindow.hpp +++ b/NCursesPtyWindow.hpp @@ -37,8 +37,8 @@ namespace krikkel::NCursesPtyWindow VTermScreen *pseudoTerminalScreen; static VTermScreenCallbacks screenCallbacks; /// @todo one line is at most 4096 chars long - static const u_int CLIENT_OUTPUT_BUFFER_SIZE = 512; - char clientOutputBuffer[CLIENT_OUTPUT_BUFFER_SIZE]; + static const size_t PTY_CLIENT_OUTPUT_BUFFER_SIZE = 8192; + char ptyClientOutputBuffer[PTY_CLIENT_OUTPUT_BUFFER_SIZE]; uint16_t cursorX, cursorY; std::thread readPtyClientThread;