mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibLineEdit + Shell: Handle Termios internally and give a copy if asked
This moves the Termios logic inside LibLineEdit and allows users to simply forget about the existence of termios if they so choose to :^)
This commit is contained in:
parent
5062a7d4cd
commit
6f407fff32
3 changed files with 19 additions and 19 deletions
|
@ -30,9 +30,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
LineEditor::LineEditor(struct termios termios)
|
||||
: m_termios(termios)
|
||||
, m_initialized(true)
|
||||
LineEditor::LineEditor()
|
||||
{
|
||||
struct winsize ws;
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
|
||||
|
@ -41,13 +39,9 @@ LineEditor::LineEditor(struct termios termios)
|
|||
m_num_columns = ws.ws_col;
|
||||
}
|
||||
|
||||
LineEditor::LineEditor()
|
||||
: LineEditor(termios {})
|
||||
{
|
||||
}
|
||||
|
||||
LineEditor::~LineEditor()
|
||||
{
|
||||
tcsetattr(0, TCSANOW, &m_default_termios);
|
||||
}
|
||||
|
||||
void LineEditor::add_to_history(const String& line)
|
||||
|
@ -378,7 +372,7 @@ String LineEditor::get_line(const String& prompt)
|
|||
do_backspace();
|
||||
continue;
|
||||
}
|
||||
if (ch == 0xc) { // ^L
|
||||
if (ch == 0xc) { // ^L
|
||||
printf("\033[3J\033[H\033[2J"); // Clear screen.
|
||||
fputs(prompt.characters(), stdout);
|
||||
for (size_t i = 0; i < m_buffer.size(); ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue