mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
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.
This commit is contained in:
parent
21c4c67119
commit
5062a7d4cd
Notes:
sideshowbarker
2024-07-19 08:02:12 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/5062a7d4cd6 Pull-request: https://github.com/SerenityOS/serenity/pull/1539
3 changed files with 12 additions and 12 deletions
|
@ -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()
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -1154,14 +1154,16 @@ int main(int argc, char** argv)
|
|||
|
||||
signal(SIGINT, [](int) {
|
||||
g.was_interrupted = true;
|
||||
});
|
||||
|
||||
signal(SIGHUP, [](int) {
|
||||
save_history();
|
||||
editor.interrupted();
|
||||
});
|
||||
|
||||
signal(SIGWINCH, [](int) {
|
||||
g.was_resized = true;
|
||||
editor.resized();
|
||||
});
|
||||
|
||||
signal(SIGHUP, [](int) {
|
||||
save_history();
|
||||
});
|
||||
|
||||
int rc = gethostname(g.hostname, sizeof(g.hostname));
|
||||
|
|
Loading…
Add table
Reference in a new issue