summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibLine
diff options
context:
space:
mode:
authorAnonymous <anon@mous.org>2022-02-12 20:26:09 -0800
committerAndreas Kling <kling@serenityos.org>2022-02-13 14:44:36 +0100
commit77511627e9ec3f047ad647aedf2c09b770dbe4cb (patch)
tree704a8ce7b79a67185530d5d708bf337392eaeb66 /Userland/Libraries/LibLine
parent434925bbd8b254668291d5e4b595244eecfca806 (diff)
downloadserenity-77511627e9ec3f047ad647aedf2c09b770dbe4cb.zip
LibLine: Fix loading of terminal dimensions when running under lldb
Diffstat (limited to 'Userland/Libraries/LibLine')
-rw-r--r--Userland/Libraries/LibLine/Editor.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp
index 44b8884229..0c87ec4234 100644
--- a/Userland/Libraries/LibLine/Editor.cpp
+++ b/Userland/Libraries/LibLine/Editor.cpp
@@ -23,6 +23,7 @@
#include <LibCore/File.h>
#include <LibCore/Notifier.h>
#include <errno.h>
+#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <sys/ioctl.h>
@@ -222,6 +223,14 @@ void Editor::get_terminal_size()
m_num_columns = 80;
m_num_lines = 25;
} else {
+ if (ws.ws_col == 0 || ws.ws_row == 0) {
+ // LLDB uses ttys which "work" and then gives us a zero sized
+ // terminal which is far from useful
+ if (int fd = open("/dev/tty", O_RDONLY); fd != -1) {
+ ioctl(fd, TIOCGWINSZ, &ws);
+ close (fd);
+ }
+ }
m_num_columns = ws.ws_col;
m_num_lines = ws.ws_row;
}