summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorLennon Donaghy <donaghylennon@gmail.com>2021-07-27 06:35:07 +0100
committerAndreas Kling <kling@serenityos.org>2021-07-27 13:08:43 +0200
commitc4887882cc7e0f0dcc520678983c3ae727d38b1d (patch)
treeef9a34a4300ae6800c2f412cd805bc8e055db6ae /Userland/Utilities
parent751cb094ff5f2752cca3629f951bd9e99efc77f4 (diff)
downloadserenity-c4887882cc7e0f0dcc520678983c3ae727d38b1d.zip
Utilities: Allow 'less' to scroll to top/bottom using 'G' and 'g'
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/less.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Utilities/less.cpp b/Userland/Utilities/less.cpp
index ccb0cf5542..7c1d6a74ac 100644
--- a/Userland/Utilities/less.cpp
+++ b/Userland/Utilities/less.cpp
@@ -151,6 +151,18 @@ public:
fflush(m_tty);
}
+ void top()
+ {
+ up_n(m_line);
+ }
+
+ void bottom()
+ {
+ while (read_line())
+ ;
+ down_n(m_lines.size() - m_line);
+ }
+
void init()
{
while (m_lines.size() < m_height) {
@@ -369,6 +381,10 @@ int main(int argc, char** argv)
} else if (sequence == "k" || sequence == "\e[A") {
if (!emulate_more)
pager.up();
+ } else if (sequence == "g") {
+ pager.top();
+ } else if (sequence == "G") {
+ pager.bottom();
} else if (sequence == " " || sequence == "\e[6~") {
pager.down_page();
} else if (sequence == "\e[5~") {