Compare commits
3 Commits
703c1a485c
...
d73a270fb1
Author | SHA1 | Date |
---|---|---|
|
d73a270fb1 | |
|
d9647868cc | |
|
85505b0482 |
|
@ -69,8 +69,6 @@ namespace Kernel
|
|||
void do_backspace();
|
||||
|
||||
protected:
|
||||
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
|
||||
TerminalDriver::Color m_background { TerminalColor::BLACK };
|
||||
termios m_termios;
|
||||
|
||||
private:
|
||||
|
|
|
@ -84,6 +84,10 @@ namespace Kernel
|
|||
uint32_t m_column { 0 };
|
||||
Cell* m_buffer { nullptr };
|
||||
|
||||
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
|
||||
TerminalDriver::Color m_background { TerminalColor::BLACK };
|
||||
bool m_colors_inverted { false };
|
||||
|
||||
BAN::RefPtr<TerminalDriver> m_terminal_driver;
|
||||
};
|
||||
|
||||
|
|
|
@ -110,11 +110,11 @@ namespace Kernel
|
|||
case 0:
|
||||
m_foreground = TerminalColor::BRIGHT_WHITE;
|
||||
m_background = TerminalColor::BLACK;
|
||||
m_colors_inverted = false;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
BAN::swap(m_foreground, m_background);
|
||||
break;
|
||||
case 7: m_colors_inverted = true; break;
|
||||
case 27: m_colors_inverted = false; break;
|
||||
|
||||
case 30: m_foreground = TerminalColor::BLACK; break;
|
||||
case 31: m_foreground = TerminalColor::RED; break;
|
||||
|
@ -384,9 +384,9 @@ namespace Kernel
|
|||
ASSERT(x < m_width && y < m_height);
|
||||
auto& cell = m_buffer[y * m_width + x];
|
||||
cell.codepoint = codepoint;
|
||||
cell.foreground = m_foreground;
|
||||
cell.background = m_background;
|
||||
m_terminal_driver->putchar_at(codepoint, x, y, m_foreground, m_background);
|
||||
cell.foreground = m_colors_inverted ? m_background : m_foreground;
|
||||
cell.background = m_colors_inverted ? m_foreground : m_background;
|
||||
m_terminal_driver->putchar_at(codepoint, x, y, cell.foreground, cell.background);
|
||||
}
|
||||
|
||||
void VirtualTTY::putcodepoint(uint32_t codepoint)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <BAN/ScopeGuard.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
@ -192,6 +193,10 @@ BAN::ErrorOr<void> Execute::execute_command(const PipedCommand& piped_command)
|
|||
return result;
|
||||
};
|
||||
|
||||
const int stdin_flags = fcntl(STDIN_FILENO, F_GETFL);
|
||||
if (stdin_flags == -1)
|
||||
perror("fcntl");
|
||||
|
||||
for (size_t i = 0; i < piped_command.commands.size(); i++)
|
||||
{
|
||||
int new_pipe[2] { STDIN_FILENO, STDOUT_FILENO };
|
||||
|
@ -278,8 +283,13 @@ BAN::ErrorOr<void> Execute::execute_command(const PipedCommand& piped_command)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (isatty(STDIN_FILENO) && tcsetpgrp(0, getpgrp()) == -1)
|
||||
if (isatty(STDIN_FILENO))
|
||||
{
|
||||
if (tcsetpgrp(0, getpgrp()) == -1)
|
||||
perror("tcsetpgrp");
|
||||
if (stdin_flags != -1 && fcntl(STDIN_FILENO, F_SETFL, stdin_flags) == -1)
|
||||
perror("fcntl");
|
||||
}
|
||||
m_last_return_value = child_codes.back();
|
||||
|
||||
return {};
|
||||
|
|
|
@ -283,16 +283,20 @@ void Terminal::handle_sgr()
|
|||
case -1: case 0:
|
||||
m_bg_color = s_default_bg_color;
|
||||
m_fg_color = s_default_fg_color;
|
||||
m_colors_inverted = false;
|
||||
break;
|
||||
case 1:
|
||||
// FIXME: bold
|
||||
break;
|
||||
case 7:
|
||||
BAN::swap(m_fg_color, m_bg_color);
|
||||
m_colors_inverted = true;
|
||||
break;
|
||||
case 10:
|
||||
// default font
|
||||
break;
|
||||
case 27:
|
||||
m_colors_inverted = false;
|
||||
break;
|
||||
case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37:
|
||||
m_fg_color = s_colors_dark[m_csi_info.fields[0] - 30];
|
||||
break;
|
||||
|
@ -553,8 +557,11 @@ Rectangle Terminal::putcodepoint(uint32_t codepoint)
|
|||
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);
|
||||
const auto fg_color = m_colors_inverted ? m_bg_color : m_fg_color;
|
||||
const auto bg_color = m_colors_inverted ? m_fg_color : m_bg_color;
|
||||
|
||||
m_window->fill_rect(cell_x, cell_y, cell_w, cell_h, bg_color);
|
||||
m_window->draw_character(codepoint, m_font, cell_x, cell_y, fg_color);
|
||||
m_last_graphic_char = codepoint;
|
||||
should_invalidate = { cell_x, cell_y, cell_w, cell_h };
|
||||
m_cursor.x++;
|
||||
|
|
|
@ -97,4 +97,5 @@ private:
|
|||
Cursor m_saved_cursor { 0, 0 };
|
||||
uint32_t m_fg_color { 0 };
|
||||
uint32_t m_bg_color { 0 };
|
||||
bool m_colors_inverted { false };
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue