mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
parent
5e6b9cbc91
commit
5d1425718e
2 changed files with 24 additions and 15 deletions
|
@ -557,21 +557,9 @@ auto Editor::get_line(const String& prompt) -> Result<String, Editor::Error>
|
||||||
m_notifier = Core::Notifier::construct(STDIN_FILENO, Core::Notifier::Read);
|
m_notifier = Core::Notifier::construct(STDIN_FILENO, Core::Notifier::Read);
|
||||||
add_child(*m_notifier);
|
add_child(*m_notifier);
|
||||||
|
|
||||||
m_notifier->on_ready_to_read = [&] {
|
m_notifier->on_ready_to_read = [&] { try_update_once(); };
|
||||||
if (m_was_interrupted) {
|
if (!m_incomplete_data.is_empty())
|
||||||
handle_interrupt_event();
|
deferred_invoke([&](auto&) { try_update_once(); });
|
||||||
}
|
|
||||||
|
|
||||||
handle_read_event();
|
|
||||||
|
|
||||||
if (m_always_refresh)
|
|
||||||
m_refresh_needed = true;
|
|
||||||
|
|
||||||
refresh_display();
|
|
||||||
|
|
||||||
if (m_finish)
|
|
||||||
really_quit_event_loop();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (loop.exec() == Retry)
|
if (loop.exec() == Retry)
|
||||||
return get_line(prompt);
|
return get_line(prompt);
|
||||||
|
@ -597,6 +585,23 @@ void Editor::save_to(JsonObject& object)
|
||||||
object.set("used_display_area", move(display_area));
|
object.set("used_display_area", move(display_area));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::try_update_once()
|
||||||
|
{
|
||||||
|
if (m_was_interrupted) {
|
||||||
|
handle_interrupt_event();
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_read_event();
|
||||||
|
|
||||||
|
if (m_always_refresh)
|
||||||
|
m_refresh_needed = true;
|
||||||
|
|
||||||
|
refresh_display();
|
||||||
|
|
||||||
|
if (m_finish)
|
||||||
|
really_quit_event_loop();
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::handle_interrupt_event()
|
void Editor::handle_interrupt_event()
|
||||||
{
|
{
|
||||||
m_was_interrupted = false;
|
m_was_interrupted = false;
|
||||||
|
@ -924,6 +929,9 @@ void Editor::handle_read_event()
|
||||||
for (size_t i = 0; i < consumed_code_points; ++i)
|
for (size_t i = 0; i < consumed_code_points; ++i)
|
||||||
m_incomplete_data.take_first();
|
m_incomplete_data.take_first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_incomplete_data.is_empty() && !m_finish)
|
||||||
|
deferred_invoke([&](auto&) { try_update_once(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::cleanup_suggestions()
|
void Editor::cleanup_suggestions()
|
||||||
|
|
|
@ -262,6 +262,7 @@ private:
|
||||||
// FIXME: Port to Core::Property
|
// FIXME: Port to Core::Property
|
||||||
void save_to(JsonObject&);
|
void save_to(JsonObject&);
|
||||||
|
|
||||||
|
void try_update_once();
|
||||||
void handle_interrupt_event();
|
void handle_interrupt_event();
|
||||||
void handle_read_event();
|
void handle_read_event();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue