summaryrefslogtreecommitdiff
path: root/Shell/LineEditor.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-08 19:04:13 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-08 19:06:06 +0200
commitfc4022d1736e2cce3810698b9fe8a7832625277b (patch)
tree94eec6d9c5d949abfb8e709df3684e3bc79dd953 /Shell/LineEditor.cpp
parent2c81477f1672c6a7bb5f173046694b22d17eb659 (diff)
downloadserenity-fc4022d1736e2cce3810698b9fe8a7832625277b.zip
Shell: Handle SIGWINCH to get a nice behavior when resizing.
When resizing the terminal, we now clear the entire current line and reset the shell's LineEditor input state. This makes it look and feel kinda the same as xterm. Fixes #286.
Diffstat (limited to 'Shell/LineEditor.cpp')
-rw-r--r--Shell/LineEditor.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Shell/LineEditor.cpp b/Shell/LineEditor.cpp
index 78b70794a4..b1bd1df8e8 100644
--- a/Shell/LineEditor.cpp
+++ b/Shell/LineEditor.cpp
@@ -50,10 +50,16 @@ String LineEditor::get_line()
if (nread < 0) {
if (errno == EINTR) {
if (g.was_interrupted) {
+ g.was_interrupted = false;
if (!m_buffer.is_empty())
printf("^C");
}
- g.was_interrupted = false;
+ if (g.was_resized) {
+ g.was_resized = false;
+ printf("\033[2K\r");
+ m_buffer.clear();
+ return String::empty();
+ }
m_buffer.clear();
putchar('\n');
return String::empty();