diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-05-13 14:22:47 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-13 15:07:44 +0200 |
commit | 98d25324fd8cb4c6710b1a57cd661bd68cae5ba9 (patch) | |
tree | 842e24757e1a0c28555e9e129bc31560e3457fb3 /Libraries | |
parent | 2c45076e6861786f7000cbac812d6b3c63a9e3ca (diff) | |
download | serenity-98d25324fd8cb4c6710b1a57cd661bd68cae5ba9.zip |
LibLine: Add a hook to run when an interrupt is handled
We do not want to clog up signal handlers by putting possibly complex
logic inside them, so allow the editor to handle that.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibLine/Editor.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibLine/Editor.h | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index a38fb2d5f0..b1ed9dcdb4 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -171,6 +171,10 @@ String Editor::get_line(const String& prompt) m_buffer.clear(); m_cursor = 0; + + if (on_interrupt_handled) + on_interrupt_handled(); + m_refresh_needed = true; continue; } diff --git a/Libraries/LibLine/Editor.h b/Libraries/LibLine/Editor.h index 6ac01bb9e5..384966e0bd 100644 --- a/Libraries/LibLine/Editor.h +++ b/Libraries/LibLine/Editor.h @@ -134,6 +134,7 @@ public: Function<Vector<CompletionSuggestion>(const String&)> on_tab_complete_first_token; Function<Vector<CompletionSuggestion>(const String&)> on_tab_complete_other_token; + Function<void()> on_interrupt_handled; Function<void(Editor&)> on_display_refresh; // FIXME: we will have to kindly ask our instantiators to set our signal handlers |