summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-05-26 15:04:39 +0430
committerAndreas Kling <kling@serenityos.org>2020-05-27 11:13:02 +0200
commit70a213a6ec19aeee99af6a747c5b12890c038690 (patch)
tree586baffec497398f75535d58e1ed206f569370ba /Applications
parent8e6df3949d2e885c1566c7a3f9cf14b38419bcbb (diff)
downloadserenity-70a213a6ec19aeee99af6a747c5b12890c038690.zip
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.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Debugger/main.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Applications/Debugger/main.cpp b/Applications/Debugger/main.cpp
index 61817c8839..31f47046a2 100644
--- a/Applications/Debugger/main.cpp
+++ b/Applications/Debugger/main.cpp
@@ -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();