summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibLine/Editor.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-02-21 04:37:43 +0330
committerAndreas Kling <kling@serenityos.org>2021-02-21 09:01:00 +0100
commit9790ee4649f53bd5519f034050786e8c0df8a4f2 (patch)
tree784844b967813c1f231f5f3ebf2c848d300f985b /Userland/Libraries/LibLine/Editor.cpp
parent6472e5239c653bebe3efea79c803aa01b925cccb (diff)
downloadserenity-9790ee4649f53bd5519f034050786e8c0df8a4f2.zip
LibLine: Make clear_lines() work when only clearing the current line
Diffstat (limited to 'Userland/Libraries/LibLine/Editor.cpp')
-rw-r--r--Userland/Libraries/LibLine/Editor.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp
index c11965755e..acab00433d 100644
--- a/Userland/Libraries/LibLine/Editor.cpp
+++ b/Userland/Libraries/LibLine/Editor.cpp
@@ -1531,12 +1531,16 @@ void VT::apply_style(const Style& style, bool is_starting)
void VT::clear_lines(size_t count_above, size_t count_below)
{
- // Go down count_below lines.
- if (count_below > 0)
- fprintf(stderr, "\033[%dB", (int)count_below);
- // Then clear lines going upwards.
- for (size_t i = count_below + count_above; i > 0; --i)
- fputs(i == 1 ? "\033[2K" : "\033[2K\033[A", stderr);
+ if (count_below + count_above == 0) {
+ fputs("\033[2K", stderr);
+ } else {
+ // Go down count_below lines.
+ if (count_below > 0)
+ fprintf(stderr, "\033[%dB", (int)count_below);
+ // Then clear lines going upwards.
+ for (size_t i = count_below + count_above; i > 0; --i)
+ fputs(i == 1 ? "\033[2K" : "\033[2K\033[A", stderr);
+ }
}
void VT::save_cursor()