mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibLine: Use Core::EventLoop for outer read loop
This commit changes LibLine's internal structure to work in an event loop, and as a result, also switches it to being a Core::Object.
This commit is contained in:
parent
8e6df3949d
commit
70a213a6ec
7 changed files with 583 additions and 517 deletions
|
@ -44,7 +44,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static Line::Editor editor {};
|
||||
RefPtr<Line::Editor> editor;
|
||||
|
||||
OwnPtr<DebugSession> g_debug_session;
|
||||
|
||||
|
@ -173,6 +173,8 @@ void print_help()
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
editor = Line::Editor::construct();
|
||||
|
||||
if (pledge("stdio proc exec rpath tty sigaction", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
|
@ -236,7 +238,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
for (;;) {
|
||||
auto command_result = editor.get_line("(sdb) ");
|
||||
auto command_result = editor->get_line("(sdb) ");
|
||||
|
||||
if (command_result.is_error())
|
||||
return DebugSession::DebugDecision::Detach;
|
||||
|
@ -246,8 +248,8 @@ int main(int argc, char** argv)
|
|||
bool success = false;
|
||||
Optional<DebugSession::DebugDecision> decision;
|
||||
|
||||
if (command.is_empty() && !editor.history().is_empty()) {
|
||||
command = editor.history().last();
|
||||
if (command.is_empty() && !editor->history().is_empty()) {
|
||||
command = editor->history().last();
|
||||
}
|
||||
if (command == "cont") {
|
||||
decision = DebugSession::DebugDecision::Continue;
|
||||
|
@ -276,8 +278,8 @@ int main(int argc, char** argv)
|
|||
|
||||
if (success && !command.is_empty()) {
|
||||
// Don't add repeated commands to history
|
||||
if (editor.history().is_empty() || editor.history().last() != command)
|
||||
editor.add_to_history(command);
|
||||
if (editor->history().is_empty() || editor->history().last() != command)
|
||||
editor->add_to_history(command);
|
||||
}
|
||||
if (!success) {
|
||||
print_help();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue