mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibLine: Handle interrupts/window size changes internally
This commit is contained in:
parent
238e87de4e
commit
30554c969c
Notes:
sideshowbarker
2024-07-19 03:21:24 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/30554c969c3 Pull-request: https://github.com/SerenityOS/serenity/pull/3230 Reviewed-by: https://github.com/awesomekling
4 changed files with 9 additions and 10 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Key, NonnullOwnPtr<KeyCallback>> m_key_callbacks;
|
||||
|
||||
// TODO: handle signals internally.
|
||||
struct termios m_termios {
|
||||
};
|
||||
struct termios m_default_termios {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue