fixes #4 — albeit very slow
#2 needs fixing to remedy that problem with performance
This commit is contained in:
parent
2171a3daa4
commit
6d02539162
|
@ -46,6 +46,11 @@ namespace krikkel::NCursesPtyWindow
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
input = ptyWindow->getch();
|
input = ptyWindow->getch();
|
||||||
|
if(input == KEY_RESIZE)
|
||||||
|
{
|
||||||
|
ptyWindow->wresize(Root_Window->lines(), Root_Window->cols());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ptyWindow->writeToClient((unsigned char) input);
|
ptyWindow->writeToClient((unsigned char) input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace krikkel::NCursesPtyWindow
|
||||||
: NCursesWindow(lines, columns, y, x)
|
: NCursesWindow(lines, columns, y, x)
|
||||||
{
|
{
|
||||||
// to get the original terminal we need to shutdown ncurses for a moment
|
// 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();
|
::endwin();
|
||||||
tcgetattr(STDIN_FILENO, &terminalParameters);
|
tcgetattr(STDIN_FILENO, &terminalParameters);
|
||||||
::refresh();
|
::refresh();
|
||||||
|
@ -32,7 +33,6 @@ namespace krikkel::NCursesPtyWindow
|
||||||
openpty(&fdPtyHost, &fdPtyClient, NULL, &terminalParameters, &windowSize);
|
openpty(&fdPtyHost, &fdPtyClient, NULL, &terminalParameters, &windowSize);
|
||||||
|
|
||||||
pseudoTerminal = vterm_new(windowSize.ws_row, windowSize.ws_col);
|
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);
|
vterm_set_utf8(pseudoTerminal, true);
|
||||||
pseudoTerminalScreen = vterm_obtain_screen(pseudoTerminal);
|
pseudoTerminalScreen = vterm_obtain_screen(pseudoTerminal);
|
||||||
vterm_screen_reset(pseudoTerminalScreen, true);
|
vterm_screen_reset(pseudoTerminalScreen, true);
|
||||||
|
@ -42,7 +42,8 @@ namespace krikkel::NCursesPtyWindow
|
||||||
keypad(false);
|
keypad(false);
|
||||||
|
|
||||||
/// @todo block all signals, this thread does not handle any
|
/// @todo block all signals, this thread does not handle any
|
||||||
readPtyClientThread = std::thread(&NCursesPtyWindow::readFromPtyClientThreadMethod, this);
|
readPtyClientThread =
|
||||||
|
std::thread(&NCursesPtyWindow::readFromPtyClientThreadMethod, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
NCursesPtyWindow::~NCursesPtyWindow()
|
NCursesPtyWindow::~NCursesPtyWindow()
|
||||||
|
@ -129,6 +130,7 @@ namespace krikkel::NCursesPtyWindow
|
||||||
|
|
||||||
int NCursesPtyWindow::handlerMoveCursor(VTermPos pos, VTermPos oldpos, int visible)
|
int NCursesPtyWindow::handlerMoveCursor(VTermPos pos, VTermPos oldpos, int visible)
|
||||||
{
|
{
|
||||||
|
/// @todo maybe use `mvcur()` instead?
|
||||||
cursorX = pos.col;
|
cursorX = pos.col;
|
||||||
cursorY = pos.row;
|
cursorY = pos.row;
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -249,6 +251,21 @@ namespace krikkel::NCursesPtyWindow
|
||||||
return NCursesWindow::refresh();
|
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)
|
int NCursesPtyWindow::staticHandlerDamage(VTermRect rect, void *user)
|
||||||
{
|
{
|
||||||
NCursesPtyWindow *instance = static_cast<NCursesPtyWindow *>(user);
|
NCursesPtyWindow *instance = static_cast<NCursesPtyWindow *>(user);
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace krikkel::NCursesPtyWindow
|
||||||
|
|
||||||
int add_wch(cchar_t *character);
|
int add_wch(cchar_t *character);
|
||||||
int refresh() override;
|
int refresh() override;
|
||||||
|
int wresize(int rows, int cols);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fdPtyHost, fdPtyClient;
|
int fdPtyHost, fdPtyClient;
|
||||||
|
|
Loading…
Reference in a new issue