diff --git a/NCursesPtyApp.cpp b/NCursesPtyApp.cpp index 7d3e3b8..84d445c 100644 --- a/NCursesPtyApp.cpp +++ b/NCursesPtyApp.cpp @@ -51,7 +51,8 @@ namespace krikkel::NCursesPtyWindow ptyWindow->wresize(Root_Window->lines(), Root_Window->cols()); continue; } - ptyWindow->writeToClient((unsigned char) input); + + ptyWindow->writeToClient((char *) &input, 1); } return 0; diff --git a/NCursesPtyWindow.cpp b/NCursesPtyWindow.cpp index 24e02bc..0356e94 100644 --- a/NCursesPtyWindow.cpp +++ b/NCursesPtyWindow.cpp @@ -37,9 +37,11 @@ namespace krikkel::NCursesPtyWindow pseudoTerminalScreen = vterm_obtain_screen(pseudoTerminal); vterm_screen_reset(pseudoTerminalScreen, true); vterm_screen_set_callbacks(pseudoTerminalScreen, &screenCallbacks, this); + vterm_output_set_callback(pseudoTerminal, &staticHandlerOutput, this); + //vterm_screen_enable_altscreen(pseudoTerminalScreen, true); // the terminal is doing most of the work - //raw(); — cbreak might suffice + //raw(); //— cbreak might suffice //noecho(); — already set //nodelay(true); — @todo needs some reprogramming keypad(false); @@ -62,10 +64,11 @@ namespace krikkel::NCursesPtyWindow return fdPtyClient; } - /// @todo maybe implement a function with a string buffer - void NCursesPtyWindow::writeToClient(char character) + void NCursesPtyWindow::writeToClient(const char *output, size_t length) const { - write(fdPtyHost, &character, sizeof(character)); + write(fdPtyHost, output, length); + __debug_log("written to PTY client: "); + __debug_log(__debug_bytes_printable_table(output, length)); } void NCursesPtyWindow::readFromPtyClientThreadMethod() @@ -90,6 +93,7 @@ namespace krikkel::NCursesPtyWindow size_t bytesRead = read(fdPtyHost, ptyClientOutputBuffer, PTY_CLIENT_OUTPUT_BUFFER_SIZE); if(bytesRead != -1 && bytesRead != 0) vterm_input_write(pseudoTerminal, ptyClientOutputBuffer, bytesRead); + __debug_log("read from PTY client: '" + __debug_bytes_printable(ptyClientOutputBuffer, bytesRead) + "'"); } VTermScreenCallbacks NCursesPtyWindow::screenCallbacks = @@ -210,13 +214,13 @@ namespace krikkel::NCursesPtyWindow attr_t NCursesPtyWindow::extractAttributesFromVTermCell(VTermScreenCell vTermCell) { attr_t result = A_NORMAL; - __debug_log("unimplemented method called"); + //__debug_log("unimplemented method called"); return result; } short NCursesPtyWindow::extractColorFromVTermCell(VTermScreenCell vTermCell) { - __debug_log("unimplemented method called"); + //__debug_log("unimplemented method called"); return 0; } @@ -317,4 +321,11 @@ namespace krikkel::NCursesPtyWindow NCursesPtyWindow *instance = static_cast(user); return instance->handlerPopLine(cols, cells); } + + void NCursesPtyWindow::staticHandlerOutput(const char *s, size_t len, void *user) + { + NCursesPtyWindow *instance = static_cast(user); + for(size_t index = 0; index < len; ++index) + instance->writeToClient(s, len); + } } \ No newline at end of file diff --git a/NCursesPtyWindow.hpp b/NCursesPtyWindow.hpp index 13e6df8..7d9fe5a 100644 --- a/NCursesPtyWindow.hpp +++ b/NCursesPtyWindow.hpp @@ -24,7 +24,7 @@ namespace krikkel::NCursesPtyWindow ~NCursesPtyWindow(); int getFdPtyClient() const; - void writeToClient(char character); + void writeToClient(const char * string, size_t length) const; int add_wch(cchar_t *character); int refresh() override; @@ -66,5 +66,6 @@ namespace krikkel::NCursesPtyWindow static int staticHandlerResize(int rows, int cols, void *user); static int staticHandlerPushLine(int cols, const VTermScreenCell *cells, void *user); static int staticHandlerPopLine(int cols, VTermScreenCell *cells, void *user); - }; + static void staticHandlerOutput(const char *s, size_t len, void *user); + }; } \ No newline at end of file