2024-06-03 18:04:33 +03:00
|
|
|
#include "Terminal.h"
|
|
|
|
|
|
|
|
#include <BAN/Debug.h>
|
|
|
|
#include <BAN/UTF8.h>
|
|
|
|
|
|
|
|
#include <ctype.h>
|
2024-08-11 01:01:05 +03:00
|
|
|
#include <fcntl.h>
|
2024-06-03 18:04:33 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
void Terminal::start_shell()
|
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
int pts_master = posix_openpt(O_RDWR | O_NOCTTY);
|
|
|
|
if (pts_master == -1)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
dwarnln("posix_openpt: {}", strerror(errno));
|
2024-06-03 18:04:33 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
if (grantpt(pts_master) == -1)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
dwarnln("grantpt: {}", strerror(errno));
|
2024-06-03 18:04:33 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
if (unlockpt(pts_master) == -1)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
dwarnln("unlockpt: {}", strerror(errno));
|
2024-06-03 18:04:33 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
pid_t shell_pid = fork();
|
|
|
|
if (shell_pid == 0)
|
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
if (setsid() == -1)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
dwarnln("setsid: {}", strerror(errno));
|
2024-06-03 18:04:33 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
char* pts_slave_name = ptsname(pts_master);
|
|
|
|
if (pts_slave_name == nullptr)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 01:01:05 +03:00
|
|
|
dwarnln("ptsname: {}", strerror(errno));
|
2024-06-03 18:04:33 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
int pts_slave = open(pts_slave_name, O_RDWR);
|
|
|
|
if (pts_slave == -1)
|
|
|
|
{
|
|
|
|
dwarnln("open: {}", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dup2(pts_slave, STDIN_FILENO) == -1 || dup2(pts_slave, STDOUT_FILENO) == -1 || dup2(pts_slave, STDERR_FILENO) == -1)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
|
|
|
dwarnln("dup2: {}", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
2024-08-11 01:01:05 +03:00
|
|
|
|
|
|
|
close(pts_slave);
|
|
|
|
close(pts_master);
|
2024-06-03 18:04:33 +03:00
|
|
|
|
|
|
|
execl("/bin/Shell", "Shell", NULL);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shell_pid == -1)
|
|
|
|
{
|
|
|
|
dwarnln("fork: {}", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_shell_info = {
|
2024-08-11 01:01:05 +03:00
|
|
|
.pts_master = pts_master,
|
2024-06-03 18:04:33 +03:00
|
|
|
.pid = shell_pid
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static volatile bool s_shell_exited = false;
|
|
|
|
|
|
|
|
void Terminal::run()
|
|
|
|
{
|
|
|
|
signal(SIGCHLD, [](int) { s_shell_exited = true; });
|
|
|
|
start_shell();
|
|
|
|
|
2024-06-18 20:32:43 +03:00
|
|
|
m_window = MUST(LibGUI::Window::create(600, 400, "Terminal"_sv));
|
2024-06-03 18:04:33 +03:00
|
|
|
m_window->fill(m_bg_color);
|
|
|
|
m_window->invalidate();
|
|
|
|
|
2024-06-18 20:32:43 +03:00
|
|
|
m_font = MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv));
|
2024-06-03 18:04:33 +03:00
|
|
|
|
2024-08-12 00:50:06 +03:00
|
|
|
MUST(m_cursor_buffer.resize(m_font.width() * m_font.height(), m_bg_color));
|
|
|
|
show_cursor();
|
|
|
|
|
2024-06-03 18:04:33 +03:00
|
|
|
m_window->set_key_event_callback([&](LibGUI::EventPacket::KeyEvent event) { on_key_event(event); });
|
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
const int max_fd = BAN::Math::max(m_shell_info.pts_master, m_window->server_fd());
|
2024-06-03 18:04:33 +03:00
|
|
|
while (!s_shell_exited)
|
|
|
|
{
|
|
|
|
fd_set fds;
|
|
|
|
FD_ZERO(&fds);
|
2024-08-11 01:01:05 +03:00
|
|
|
FD_SET(m_shell_info.pts_master, &fds);
|
2024-06-03 18:04:33 +03:00
|
|
|
FD_SET(m_window->server_fd(), &fds);
|
|
|
|
|
|
|
|
select(max_fd + 1, &fds, nullptr, nullptr, nullptr);
|
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
if (FD_ISSET(m_shell_info.pts_master, &fds))
|
|
|
|
if (!read_shell())
|
2024-06-03 18:04:33 +03:00
|
|
|
break;
|
|
|
|
if (FD_ISSET(m_window->server_fd(), &fds))
|
|
|
|
m_window->poll_events();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-12 00:50:06 +03:00
|
|
|
void Terminal::hide_cursor()
|
|
|
|
{
|
|
|
|
const uint32_t cursor_base_x = m_cursor.x * m_font.width();
|
|
|
|
const uint32_t cursor_base_y = m_cursor.y * m_font.height();
|
|
|
|
for (uint32_t y = 0; y < m_font.height(); y++)
|
|
|
|
for (uint32_t x = 0; x < m_font.width(); x++)
|
|
|
|
m_window->set_pixel(cursor_base_x + x, cursor_base_y + y, m_cursor_buffer[y * m_font.width() + x]);
|
|
|
|
m_window->invalidate(cursor_base_x, cursor_base_y, m_font.width(), m_font.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Terminal::show_cursor()
|
|
|
|
{
|
|
|
|
const uint32_t cursor_base_x = m_cursor.x * m_font.width();
|
|
|
|
const uint32_t cursor_base_y = m_cursor.y * m_font.height();
|
|
|
|
for (uint32_t y = 0; y < m_font.height(); y++)
|
|
|
|
for (uint32_t x = 0; x < m_font.width(); x++)
|
|
|
|
m_cursor_buffer[y * m_font.width() + x] = m_window->get_pixel(cursor_base_x + x, cursor_base_y + y);
|
|
|
|
if (m_cursor_shown)
|
|
|
|
{
|
|
|
|
for (uint32_t y = m_font.height() * 13 / 16; y < m_font.height() - 1; y++)
|
|
|
|
for (uint32_t x = 0; x < m_font.width(); x++)
|
|
|
|
m_window->set_pixel(cursor_base_x + x, cursor_base_y + y, 0xFFFFFFFF);
|
|
|
|
m_window->invalidate(cursor_base_x, cursor_base_y, m_font.width(), m_font.height());
|
|
|
|
}
|
|
|
|
}
|
2024-06-03 18:04:33 +03:00
|
|
|
|
2024-08-11 01:01:05 +03:00
|
|
|
bool Terminal::read_shell()
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-12 00:50:06 +03:00
|
|
|
hide_cursor();
|
|
|
|
|
2024-06-03 18:04:33 +03:00
|
|
|
char buffer[128];
|
2024-08-11 01:01:05 +03:00
|
|
|
ssize_t nread = read(m_shell_info.pts_master, buffer, sizeof(buffer) - 1);
|
2024-06-03 18:04:33 +03:00
|
|
|
if (nread < 0)
|
|
|
|
dwarnln("read: {}", strerror(errno));
|
|
|
|
if (nread <= 0)
|
|
|
|
return false;
|
|
|
|
for (ssize_t i = 0; i < nread; i++)
|
|
|
|
putchar(buffer[i]);
|
2024-08-12 00:50:06 +03:00
|
|
|
|
|
|
|
show_cursor();
|
|
|
|
|
2024-06-03 18:04:33 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Terminal::handle_sgr()
|
|
|
|
{
|
|
|
|
constexpr uint32_t colors_default[] {
|
|
|
|
0x555555,
|
|
|
|
0xFF5555,
|
|
|
|
0x55FF55,
|
|
|
|
0xFFFF55,
|
|
|
|
0x5555FF,
|
|
|
|
0xFF55FF,
|
|
|
|
0x55FFFF,
|
|
|
|
0xFFFFFF,
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr uint32_t colors_bright[] {
|
|
|
|
0xAAAAAA,
|
|
|
|
0xFFAAAA,
|
|
|
|
0xAAFFAA,
|
|
|
|
0xFFFFAA,
|
|
|
|
0xAAAAFF,
|
|
|
|
0xFFAAFF,
|
|
|
|
0xAAFFFF,
|
|
|
|
0xFFFFFF,
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (m_csi_info.fields[0])
|
|
|
|
{
|
|
|
|
case -1: case 0:
|
|
|
|
m_fg_color = 0xFFFFFF;
|
|
|
|
m_bg_color = 0x000000;
|
|
|
|
break;
|
|
|
|
case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37:
|
|
|
|
m_fg_color = colors_default[m_csi_info.fields[0] - 30];
|
|
|
|
break;
|
|
|
|
case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47:
|
|
|
|
m_bg_color = colors_default[m_csi_info.fields[0] - 40];
|
|
|
|
break;
|
|
|
|
case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97:
|
|
|
|
m_fg_color = colors_bright[m_csi_info.fields[0] - 90];
|
|
|
|
break;
|
|
|
|
case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107:
|
|
|
|
m_bg_color = colors_bright[m_csi_info.fields[0] - 100];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dprintln("TODO: SGR {}", m_csi_info.fields[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Terminal::handle_csi(char ch)
|
|
|
|
{
|
|
|
|
if (ch == ';')
|
|
|
|
{
|
|
|
|
m_csi_info.index++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch == '?')
|
2024-08-12 00:50:06 +03:00
|
|
|
{
|
|
|
|
m_csi_info.question = true;
|
2024-06-03 18:04:33 +03:00
|
|
|
return;
|
2024-08-12 00:50:06 +03:00
|
|
|
}
|
2024-06-03 18:04:33 +03:00
|
|
|
|
|
|
|
if (isdigit(ch))
|
|
|
|
{
|
|
|
|
if (m_csi_info.index <= 1)
|
|
|
|
{
|
|
|
|
auto& field = m_csi_info.fields[m_csi_info.index];
|
|
|
|
field = (BAN::Math::max(field, 0) * 10) + (ch - '0');
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case 'C':
|
|
|
|
if (m_csi_info.fields[0] == -1)
|
|
|
|
m_csi_info.fields[0] = 1;
|
|
|
|
m_cursor.x = BAN::Math::clamp<int32_t>(m_cursor.x + m_csi_info.fields[0], 0, cols() - 1);
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
if (m_csi_info.fields[0] == -1)
|
|
|
|
m_csi_info.fields[0] = 1;
|
|
|
|
m_cursor.x = BAN::Math::clamp<int32_t>((int32_t)m_cursor.x - m_csi_info.fields[0], 0, cols() - 1);
|
|
|
|
break;
|
|
|
|
case 'G':
|
|
|
|
m_cursor.x = BAN::Math::clamp<int32_t>(m_csi_info.fields[0], 1, cols()) - 1;
|
|
|
|
break;
|
|
|
|
case 'H':
|
|
|
|
m_cursor.y = BAN::Math::clamp<int32_t>(m_csi_info.fields[0], 1, rows()) - 1;
|
|
|
|
m_cursor.x = BAN::Math::clamp<int32_t>(m_csi_info.fields[1], 1, cols()) - 1;
|
|
|
|
break;
|
|
|
|
case 'J':
|
|
|
|
{
|
|
|
|
uint32_t rects[2][4] { { (uint32_t)-1 }, { (uint32_t)-1 } };
|
|
|
|
|
|
|
|
if (m_csi_info.fields[0] == -1 || m_csi_info.fields[0] == 0)
|
|
|
|
{
|
|
|
|
rects[0][0] = m_cursor.x * m_font.width();
|
|
|
|
rects[0][1] = m_cursor.y * m_font.height();
|
|
|
|
rects[0][2] = m_window->width() - rects[0][0];
|
|
|
|
rects[0][3] = m_font.height();
|
|
|
|
|
|
|
|
rects[1][0] = 0;
|
|
|
|
rects[1][1] = (m_cursor.y + 1) * m_font.height();
|
|
|
|
rects[1][2] = m_window->width();
|
|
|
|
rects[1][3] = m_window->height() - rects[1][1];
|
|
|
|
}
|
|
|
|
else if (m_csi_info.fields[0] == 1)
|
|
|
|
{
|
|
|
|
rects[0][0] = 0;
|
|
|
|
rects[0][1] = m_cursor.y * m_font.height();
|
|
|
|
rects[0][2] = m_cursor.x * m_font.width();
|
|
|
|
rects[0][3] = m_font.height();
|
|
|
|
|
|
|
|
rects[1][0] = 0;
|
|
|
|
rects[1][1] = 0;
|
|
|
|
rects[1][2] = m_window->width();
|
|
|
|
rects[1][3] = m_cursor.y * m_font.height();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rects[0][0] = 0;
|
|
|
|
rects[0][1] = 0;
|
|
|
|
rects[0][2] = m_window->width();
|
|
|
|
rects[0][3] = m_window->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
if (rects[i][0] == (uint32_t)-1)
|
|
|
|
continue;
|
|
|
|
m_window->fill_rect(rects[i][0], rects[i][1], rects[i][2], rects[i][3], m_bg_color);
|
|
|
|
m_window->invalidate(rects[i][0], rects[i][1], rects[i][2], rects[i][3]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'K':
|
|
|
|
{
|
|
|
|
m_csi_info.fields[0] = BAN::Math::max(m_csi_info.fields[0], 0);
|
|
|
|
|
|
|
|
uint32_t rect[4];
|
|
|
|
rect[0] = (m_csi_info.fields[0] == 0) ? m_cursor.x * m_font.width() : 0;
|
|
|
|
rect[1] = m_cursor.y * m_font.height();
|
|
|
|
rect[2] = (m_csi_info.fields[0] == 1) ? m_cursor.x * m_font.width() : m_window->width() - rect[0];
|
|
|
|
rect[3] = m_font.height();
|
|
|
|
|
|
|
|
m_window->fill_rect(rect[0], rect[1], rect[2], rect[3], m_bg_color);
|
|
|
|
m_window->invalidate(rect[0], rect[1], rect[2], rect[3]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'm':
|
|
|
|
handle_sgr();
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
m_saved_cursor = m_cursor;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
m_cursor = m_saved_cursor;
|
|
|
|
break;
|
2024-08-12 00:50:06 +03:00
|
|
|
case 'h':
|
|
|
|
case 'l':
|
|
|
|
if (!m_csi_info.question || m_csi_info.fields[0] != 25)
|
|
|
|
{
|
|
|
|
dprintln("invalid ANSI CSI ?{}{}", m_csi_info.fields[0], (char)ch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_cursor_shown = (ch == 'h');
|
|
|
|
break;
|
2024-06-03 18:04:33 +03:00
|
|
|
default:
|
|
|
|
dprintln("TODO: CSI {}", ch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_state = State::Normal;
|
|
|
|
}
|
|
|
|
|
2024-08-11 00:54:51 +03:00
|
|
|
void Terminal::putchar(uint8_t ch)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
|
|
|
if (m_state == State::ESC)
|
|
|
|
{
|
2024-08-11 00:54:51 +03:00
|
|
|
if (ch != '[')
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 00:54:51 +03:00
|
|
|
dprintln("unknown escape character 0x{2H}", ch);
|
2024-06-03 18:04:33 +03:00
|
|
|
m_state = State::Normal;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_state = State::CSI;
|
|
|
|
m_csi_info.index = 0;
|
|
|
|
m_csi_info.fields[0] = -1;
|
|
|
|
m_csi_info.fields[1] = -1;
|
2024-08-12 00:50:06 +03:00
|
|
|
m_csi_info.question = false;
|
2024-06-03 18:04:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state == State::CSI)
|
|
|
|
{
|
2024-08-11 00:54:51 +03:00
|
|
|
if (ch < 0x20 || ch > 0xFE)
|
2024-06-03 18:04:33 +03:00
|
|
|
{
|
2024-08-11 00:54:51 +03:00
|
|
|
dprintln("invalid CSI 0x{2H}", ch);
|
2024-06-03 18:04:33 +03:00
|
|
|
m_state = State::Normal;
|
|
|
|
return;
|
|
|
|
}
|
2024-08-11 00:54:51 +03:00
|
|
|
handle_csi(ch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_utf8_bytes[m_utf8_index++] = ch;
|
|
|
|
|
|
|
|
const size_t utf8_len = BAN::UTF8::byte_length(m_utf8_bytes[0]);
|
|
|
|
if (utf8_len == 0)
|
|
|
|
{
|
|
|
|
dwarnln("invalid utf8 leading byte 0x{2H}", ch);
|
|
|
|
m_utf8_index = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (m_utf8_index < utf8_len)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const uint32_t codepoint = BAN::UTF8::to_codepoint(m_utf8_bytes);
|
|
|
|
m_utf8_index = 0;
|
|
|
|
|
|
|
|
if (codepoint == BAN::UTF8::invalid)
|
|
|
|
{
|
|
|
|
char utf8_hex[20];
|
|
|
|
char* ptr = utf8_hex;
|
|
|
|
for (uint8_t i = 0; i < utf8_len; i++)
|
|
|
|
{
|
|
|
|
*ptr++ = '0';
|
|
|
|
*ptr++ = 'x';
|
|
|
|
*ptr++ = (m_utf8_bytes[i] >> 4) < 10 ? (m_utf8_bytes[i] >> 4) + '0' : (m_utf8_bytes[i] >> 4) - 10 + 'A';
|
|
|
|
*ptr++ = (m_utf8_bytes[i] & 0xF) < 10 ? (m_utf8_bytes[i] & 0xF) + '0' : (m_utf8_bytes[i] & 0xF) - 10 + 'A';
|
|
|
|
*ptr++ = ' ';
|
|
|
|
}
|
|
|
|
*--ptr = '\0';
|
|
|
|
|
|
|
|
dwarnln("invalid utf8 {}", utf8_hex);
|
2024-06-03 18:04:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (codepoint)
|
|
|
|
{
|
|
|
|
case '\e':
|
|
|
|
m_state = State::ESC;
|
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
m_cursor.x = 0;
|
|
|
|
m_cursor.y++;
|
|
|
|
break;
|
|
|
|
case '\r':
|
|
|
|
m_cursor.x = 0;
|
|
|
|
break;
|
|
|
|
case '\b':
|
|
|
|
if (m_cursor.x > 0)
|
|
|
|
m_cursor.x--;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
const uint32_t cell_w = m_font.width();
|
|
|
|
const uint32_t cell_h = m_font.height();
|
|
|
|
const uint32_t cell_x = m_cursor.x * cell_w;
|
|
|
|
const uint32_t cell_y = m_cursor.y * cell_h;
|
|
|
|
|
|
|
|
m_window->fill_rect(cell_x, cell_y, cell_w, cell_h, m_bg_color);
|
|
|
|
m_window->draw_character(codepoint, m_font, cell_x, cell_y, m_fg_color);
|
|
|
|
m_window->invalidate(cell_x, cell_y, cell_w, cell_h);
|
|
|
|
m_cursor.x++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_cursor.x >= cols())
|
|
|
|
{
|
|
|
|
m_cursor.x = 0;
|
|
|
|
m_cursor.y++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_cursor.y >= rows())
|
|
|
|
{
|
|
|
|
uint32_t scroll = m_cursor.y - rows() + 1;
|
|
|
|
m_cursor.y -= scroll;
|
|
|
|
m_window->shift_vertical(-scroll * (int32_t)m_font.height());
|
|
|
|
m_window->fill_rect(0, m_window->height() - scroll * m_font.height(), m_window->width(), scroll * m_font.height(), m_bg_color);
|
|
|
|
m_window->invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Terminal::on_key_event(LibGUI::EventPacket::KeyEvent event)
|
|
|
|
{
|
|
|
|
if (event.released())
|
|
|
|
return;
|
|
|
|
if (const char* text = LibInput::key_to_utf8_ansi(event.key, event.modifier))
|
2024-08-11 01:01:05 +03:00
|
|
|
write(m_shell_info.pts_master, text, strlen(text));
|
2024-06-03 18:04:33 +03:00
|
|
|
}
|