summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-03-30 21:55:09 +0430
committerAndreas Kling <kling@serenityos.org>2020-03-31 13:21:46 +0200
commit5062a7d4cd6293b497db88b685648c52da471221 (patch)
tree9be7393273b50a00b020b29853bafb2d6913ce4d /Libraries
parent21c4c671192bd2a2e2b6f9b041a9b3eb0885b6d6 (diff)
downloadserenity-5062a7d4cd6293b497db88b685648c52da471221.zip
LibLinEdit + Shell: handle signals
This allows the LineEditor to get notified about signals, since we cannot set signal handlers in a clean way within the LineEditor instance.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibLineEdit/LineEditor.cpp8
-rw-r--r--Libraries/LibLineEdit/LineEditor.h6
2 files changed, 6 insertions, 8 deletions
diff --git a/Libraries/LibLineEdit/LineEditor.cpp b/Libraries/LibLineEdit/LineEditor.cpp
index 131216a008..e632168b21 100644
--- a/Libraries/LibLineEdit/LineEditor.cpp
+++ b/Libraries/LibLineEdit/LineEditor.cpp
@@ -42,14 +42,8 @@ LineEditor::LineEditor(struct termios termios)
}
LineEditor::LineEditor()
- : m_termios({})
- , m_initialized(false)
+ : LineEditor(termios {})
{
- struct winsize ws;
- if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
- m_num_columns = 80;
- else
- m_num_columns = ws.ws_col;
}
LineEditor::~LineEditor()
diff --git a/Libraries/LibLineEdit/LineEditor.h b/Libraries/LibLineEdit/LineEditor.h
index 75e0e54a89..437d024e43 100644
--- a/Libraries/LibLineEdit/LineEditor.h
+++ b/Libraries/LibLineEdit/LineEditor.h
@@ -70,7 +70,11 @@ public:
Function<Vector<String>(const String&)> on_tab_complete_first_token = nullptr;
Function<Vector<String>(const String&)> on_tab_complete_other_token = nullptr;
- // FIXME: figure out signals
+
+ // FIXME: we will have to kindly ask our instantiators to set our signal handlers
+ // since we can not do this cleanly ourselves (signal() limitation: cannot give member functions)
+ void interrupted() { m_was_interrupted = true; }
+ void resized() { m_was_resized = true; }
size_t cursor() const { return m_cursor; }
const Vector<char, 1024>& buffer() const { return m_buffer; }