diff --git a/scheme/nuit-packages.scm b/scheme/nuit-packages.scm index 93d7a97..9f4f9b6 100644 --- a/scheme/nuit-packages.scm +++ b/scheme/nuit-packages.scm @@ -388,7 +388,9 @@ select-list-key? - make-get-selection-as-ref-method)) + make-get-selection-as-ref-method + + select-list-key-help)) (define-structure select-list select-list-interface (open scheme @@ -396,12 +398,14 @@ (subset srfi-13 (string-join)) define-record-types signals + let-opt select-element (subset focus-table (make-focus-object-reference)) layout tty-debug utils + configuration ncurses) (files select-list)) diff --git a/scheme/select-list.scm b/scheme/select-list.scm index ccaa97c..b3eef43 100644 --- a/scheme/select-list.scm +++ b/scheme/select-list.scm @@ -12,31 +12,42 @@ (view-index ,(select-list-view-index r)) (num-lines ,(select-list-num-lines r))))) -(define (make-select-list elements num-lines) - (really-make-select-list elements 0 0 num-lines)) +(define (make-select-list elements num-lines . optional-args) + (let-optionals optional-args + ((cursor-start 0)) + (really-make-select-list elements 0 cursor-start num-lines))) -(define key-m 109) +(define-option 'select-list 'select-list-mark-key (char->ascii #\m)) +(define-option 'select-list 'select-list-unmark-key (char->ascii #\u)) +(define-option 'select-list 'select-list-move-up-key key-up) +(define-option 'select-list 'select-list-move-down-key key-down) -(define key-u 117) +(define select-list-key-help + '(select-list (select-list-mark-key + select-list-unmark-key + select-list-move-up-key + select-list-move-down-key))) (define (select-list-handle-key-press select-list key) (cond - ((= key key-m) + ((= key (config 'select-list 'select-list-mark-key)) (mark-current-line select-list)) - ((= key key-u) + ((= key (config 'select-list 'select-list-unmark-key)) (unmark-current-line select-list)) - ((= key key-up) + ((= key (config 'select-list 'select-list-move-up-key)) (move-cursor-up select-list)) - ((= key key-down) + ((= key (config 'select-list 'select-list-move-down-key)) (move-cursor-down select-list)) (else select-list))) (define (select-list-navigation-key? key) - (or (= key key-up) (= key key-down))) + (or (= key (config 'select-list 'select-list-move-up-key)) + (= key (config 'select-list 'select-list-move-down-key)))) (define (select-list-marking-key? key) - (or (= key key-m) (= key key-u))) + (or (= key (config 'select-list 'select-list-mark-key)) + (= key (config 'select-list 'select-list-unmark-key)))) (define (select-list-key? key) (or (select-list-navigation-key? key)