summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-05-13 14:22:47 +0430
committerAndreas Kling <kling@serenityos.org>2020-05-13 15:07:44 +0200
commit98d25324fd8cb4c6710b1a57cd661bd68cae5ba9 (patch)
tree842e24757e1a0c28555e9e129bc31560e3457fb3 /Libraries
parent2c45076e6861786f7000cbac812d6b3c63a9e3ca (diff)
downloadserenity-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.cpp4
-rw-r--r--Libraries/LibLine/Editor.h1
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