diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index 61508f6fe0..458f08d30d 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -404,6 +405,14 @@ void Editor::initialize() for (auto& keybind : m_configuration.keybindings) register_key_input_callback(keybind); + Core::EventLoop::register_signal(SIGINT, [this](int) { + interrupted(); + }); + + Core::EventLoop::register_signal(SIGWINCH, [this](int) { + resized(); + }); + m_initialized = true; } diff --git a/Libraries/LibLine/Editor.h b/Libraries/LibLine/Editor.h index 01640777dd..2774ab3901 100644 --- a/Libraries/LibLine/Editor.h +++ b/Libraries/LibLine/Editor.h @@ -194,8 +194,6 @@ public: #undef __ENUMERATE_EDITOR_INTERNAL_FUNCTION - // 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(); void resized() { @@ -451,7 +449,6 @@ private: HashMap> m_key_callbacks; - // TODO: handle signals internally. struct termios m_termios { }; struct termios m_default_termios { diff --git a/Shell/main.cpp b/Shell/main.cpp index a3fdf5e6a2..4786c088bd 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -93,12 +93,10 @@ int main(int argc, char** argv) Core::EventLoop loop; Core::EventLoop::register_signal(SIGINT, [](int) { - editor->interrupted(); s_shell->kill_job(s_shell->current_job(), SIGINT); }); Core::EventLoop::register_signal(SIGWINCH, [](int) { - editor->resized(); s_shell->kill_job(s_shell->current_job(), SIGWINCH); }); diff --git a/Userland/js.cpp b/Userland/js.cpp index 66298b07da..f08b336184 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -572,11 +572,6 @@ int main(int argc, char** argv) signal(SIGINT, [](int) { if (!s_editor->is_editing()) sigint_handler(); - s_editor->interrupted(); - }); - - signal(SIGWINCH, [](int) { - s_editor->resized(); }); s_editor->on_display_refresh = [syntax_highlight](Line::Editor& editor) {