From c4887882cc7e0f0dcc520678983c3ae727d38b1d Mon Sep 17 00:00:00 2001 From: Lennon Donaghy Date: Tue, 27 Jul 2021 06:35:07 +0100 Subject: [PATCH] Utilities: Allow 'less' to scroll to top/bottom using 'G' and 'g' --- Userland/Utilities/less.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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~") {