Quellcode durchsuchen

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.
AnotherTest vor 5 Jahren
Ursprung
Commit
98d25324fd
2 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen
  1. 4 0
      Libraries/LibLine/Editor.cpp
  2. 1 0
      Libraries/LibLine/Editor.h

+ 4 - 0
Libraries/LibLine/Editor.cpp

@@ -171,6 +171,10 @@ String Editor::get_line(const String& prompt)
 
 
                 m_buffer.clear();
                 m_buffer.clear();
                 m_cursor = 0;
                 m_cursor = 0;
+
+                if (on_interrupt_handled)
+                    on_interrupt_handled();
+
                 m_refresh_needed = true;
                 m_refresh_needed = true;
                 continue;
                 continue;
             }
             }

+ 1 - 0
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_first_token;
     Function<Vector<CompletionSuggestion>(const String&)> on_tab_complete_other_token;
     Function<Vector<CompletionSuggestion>(const String&)> on_tab_complete_other_token;
+    Function<void()> on_interrupt_handled;
     Function<void(Editor&)> on_display_refresh;
     Function<void(Editor&)> on_display_refresh;
 
 
     // FIXME: we will have to kindly ask our instantiators to set our signal handlers
     // FIXME: we will have to kindly ask our instantiators to set our signal handlers