From 98d25324fd8cb4c6710b1a57cd661bd68cae5ba9 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 13 May 2020 14:22:47 +0430 Subject: [PATCH] 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. --- Libraries/LibLine/Editor.cpp | 4 ++++ Libraries/LibLine/Editor.h | 1 + 2 files changed, 5 insertions(+) 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(const String&)> on_tab_complete_first_token; Function(const String&)> on_tab_complete_other_token; + Function on_interrupt_handled; Function on_display_refresh; // FIXME: we will have to kindly ask our instantiators to set our signal handlers