fixes #4 — albeit very slow

#2 needs fixing to remedy that problem with performance
Gentoo
Christian Burger 2022-04-05 12:34:35 +02:00
parent 2171a3daa4
commit 6d02539162
3 changed files with 25 additions and 2 deletions

View File

@ -46,6 +46,11 @@ namespace krikkel::NCursesPtyWindow
while(true)
{
input = ptyWindow->getch();
if(input == KEY_RESIZE)
{
ptyWindow->wresize(Root_Window->lines(), Root_Window->cols());
continue;
}
ptyWindow->writeToClient((unsigned char) input);
}

View File

@ -20,6 +20,7 @@ namespace krikkel::NCursesPtyWindow
: NCursesWindow(lines, columns, y, x)
{
// to get the original terminal we need to shutdown ncurses for a moment
/// @todo maybe try `reset_prog_mode()` and `reset_shell_mode()` instead
::endwin();
tcgetattr(STDIN_FILENO, &terminalParameters);
::refresh();
@ -32,7 +33,6 @@ namespace krikkel::NCursesPtyWindow
openpty(&fdPtyHost, &fdPtyClient, NULL, &terminalParameters, &windowSize);
pseudoTerminal = vterm_new(windowSize.ws_row, windowSize.ws_col);
__debug_log("window size (x: " + std::to_string(windowSize.ws_col) + ", y: " + std::to_string(windowSize.ws_row) + ")");
vterm_set_utf8(pseudoTerminal, true);
pseudoTerminalScreen = vterm_obtain_screen(pseudoTerminal);
vterm_screen_reset(pseudoTerminalScreen, true);
@ -42,7 +42,8 @@ namespace krikkel::NCursesPtyWindow
keypad(false);
/// @todo block all signals, this thread does not handle any
readPtyClientThread = std::thread(&NCursesPtyWindow::readFromPtyClientThreadMethod, this);
readPtyClientThread =
std::thread(&NCursesPtyWindow::readFromPtyClientThreadMethod, this);
}
NCursesPtyWindow::~NCursesPtyWindow()
@ -129,6 +130,7 @@ namespace krikkel::NCursesPtyWindow
int NCursesPtyWindow::handlerMoveCursor(VTermPos pos, VTermPos oldpos, int visible)
{
/// @todo maybe use `mvcur()` instead?
cursorX = pos.col;
cursorY = pos.row;
refresh();
@ -249,6 +251,21 @@ namespace krikkel::NCursesPtyWindow
return NCursesWindow::refresh();
}
/// @todo potential racing condition where drawing into terminal while
/// resizing?
int NCursesPtyWindow::wresize(int rows, int cols)
{
winsize windowSize =
{
.ws_row = narrow<unsigned short>(rows)
, .ws_col = narrow<unsigned short>(cols)
};
ioctl(fdPtyHost, TIOCSWINSZ, &windowSize);
vterm_set_size(pseudoTerminal, rows, cols);
return NCursesWindow::wresize(rows, cols);
}
int NCursesPtyWindow::staticHandlerDamage(VTermRect rect, void *user)
{
NCursesPtyWindow *instance = static_cast<NCursesPtyWindow *>(user);

View File

@ -28,6 +28,7 @@ namespace krikkel::NCursesPtyWindow
int add_wch(cchar_t *character);
int refresh() override;
int wresize(int rows, int cols);
private:
int fdPtyHost, fdPtyClient;