guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20/20: installer: Enable direct scrolling to top or bottom of menus.


From: John Darrington
Subject: 20/20: installer: Enable direct scrolling to top or bottom of menus.
Date: Thu, 12 Jan 2017 20:41:04 +0000 (UTC)

jmd pushed a commit to branch wip-installer
in repository guix.

commit 3673cd86e1b3271095e6affa4f74565cd3d4013f
Author: John Darrington <address@hidden>
Date:   Thu Jan 12 16:57:38 2017 +0100

    installer: Enable direct scrolling to top or bottom of menus.
    
    * gurses/menu.scm (menu-goto-start, menu-goto-end): New procedures.
    (std-menu-key-handler): connect them to Home and End keys.
---
 gurses/menu.scm |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/gurses/menu.scm b/gurses/menu.scm
index 8a8f74b..1fca9bc 100644
--- a/gurses/menu.scm
+++ b/gurses/menu.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016 John Darrington <address@hidden>
+;;; Copyright © 2016, 2017 John Darrington <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -78,6 +78,19 @@
   (menu-set-top-item! menu (max 0 (- (menu-top-item menu) step)))
   (menu-redraw menu))
 
+(define (menu-goto-start menu)
+  (menu-set-top-item! menu 0)
+  (menu-set-current-item! menu 0)
+  (menu-redraw menu))
+
+(define (menu-goto-end menu)
+  (let ((n-items (length (menu-items menu)))
+        (window-height (getmaxy (menu-window menu))))
+    (menu-set-top-item! menu (max 0 (- n-items window-height)))
+    (menu-set-current-item! menu (1- n-items))
+    (menu-redraw menu)))
+
+
 (define* (menu-down menu #:key (step 1))
   "Move the selected item down by STEP items.  Returns #f if on the last item."
   (if (< (menu-current-item menu) (1- (length (menu-items menu))))
@@ -141,7 +154,13 @@
    ((eq? ch KEY_PPAGE)
     (menu-active menu)
     (menu-up menu #:step (getmaxy (menu-window menu))))
-   
+
+   ((eq? ch KEY_HOME)
+    (menu-goto-start menu))
+
+   ((eq? ch KEY_END)
+    (menu-goto-end menu))
+
    ((or (eq? ch KEY_DOWN)
        (eq? ch #\so))
     (if (menu-active menu)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]