1
0
Fork 0

- added searching in command's help.

This commit is contained in:
cage 2020-10-03 21:08:55 +02:00
parent 53c0fb4fc5
commit 0274841672
6 changed files with 48 additions and 10 deletions

View File

@ -131,6 +131,10 @@
(define-key "?" #'print-quick-help) (define-key "?" #'print-quick-help)
(define-key "C-h h" #'print-quick-help)
(define-key "C-h a" #'apropos-help)
(define-key "!" #'gemini-search) (define-key "!" #'gemini-search)
(define-key ">" #'open-gemini-address) (define-key ">" #'open-gemini-address)

View File

@ -477,7 +477,7 @@ and `make-blocking-list-dialog-window') showing the full docstring for a command
bg bg
fg))) fg)))
(defun print-help (main-window) (defun print-help (main-window &key (regex ".*"))
"Generate an help text for the focused window and main window" "Generate an help text for the focused window and main window"
(multiple-value-bind (header-bg header-fg attribute-header) (multiple-value-bind (header-bg header-fg attribute-header)
(swconf:quick-help-header-colors) (swconf:quick-help-header-colors)
@ -502,7 +502,13 @@ and `make-blocking-list-dialog-window') showing the full docstring for a command
(alpha-b-p (alpha-b-p
nil) nil)
(t (t
(string< text-a text-b)))))))) (string< text-a text-b)))))))
(make-filter-help-text (scanner)
(lambda (a)
(scan scanner
(if (stringp a)
a
(tui:tui-string->chars-string a))))))
(when-let* ((focused-keybindings (main-window:focused-keybindings main-window)) (when-let* ((focused-keybindings (main-window:focused-keybindings main-window))
(global-help (sort-help (key-paths *global-keymap*))) (global-help (sort-help (key-paths *global-keymap*)))
(header-focused (colorize-header (_ "Focused window keys"))) (header-focused (colorize-header (_ "Focused window keys")))
@ -516,10 +522,15 @@ and `make-blocking-list-dialog-window') showing the full docstring for a command
focused-help focused-help
(list global-header-fields) (list global-header-fields)
global-help)) global-help))
(let ((all-lines (mapcar #'help-fields-get-text (handler-case
fields))) (let* ((scanner (create-scanner regex :case-insensitive-mode t))
(all-lines (remove-if-not (make-filter-help-text scanner)
(mapcar #'help-fields-get-text
fields))))
(line-oriented-window:make-blocking-list-dialog-window specials:*main-window* (line-oriented-window:make-blocking-list-dialog-window specials:*main-window*
fields fields
all-lines all-lines
#'help-expand #'help-expand
(_ "Quick help"))))))) (_ "Quick help")))
(error ()
(ui:error-message (_ "Invalid regular expression"))))))))

View File

@ -328,7 +328,8 @@ this exact quantity wold go beyond the length or rows or zero."
"Draw a window with a scrollable list of entries, pressing enter "Draw a window with a scrollable list of entries, pressing enter
will fire the `callback' function (with the selected field from `all-fields' will fire the `callback' function (with the selected field from `all-fields'
and text from `text-line'. This window is fitten into `screen' sizes." and text from `text-line'. This window is fitten into `screen' sizes."
(assert (length= all-fields text-lines)) (assert (>= (length all-fields)
(length text-lines)))
(let* ((low-level-window (make-blocking-croatoan-window :enable-function-keys t)) (let* ((low-level-window (make-blocking-croatoan-window :enable-function-keys t))
(window-width (max (+ 4 (window-width (max (+ 4
(length title)) (length title))

View File

@ -1260,6 +1260,7 @@
:chat-change-label-event :chat-change-label-event
:chat-create-event :chat-create-event
:search-link-event :search-link-event
:help-apropos-event
:function-event :function-event
:dispatch-program-events :dispatch-program-events
:add-pagination-status-event :add-pagination-status-event
@ -2135,6 +2136,7 @@
:focus-to-tags-window :focus-to-tags-window
:focus-to-conversations-window :focus-to-conversations-window
:print-quick-help :print-quick-help
:apropos-help
:move-message-tree :move-message-tree
:change-folder :change-folder
:change-timeline :change-timeline

View File

@ -1166,6 +1166,16 @@
(regex regex)) object (regex regex)) object
(line-oriented-window:search-row window regex))) (line-oriented-window:search-row window regex)))
(defclass help-apropos-event (program-event)
((regex
:initform nil
:initarg :regex
:accessor regex)))
(defmethod process-event ((object help-apropos-event))
(with-accessors ((regex regex)) object
(keybindings:print-help specials:*main-window* :regex regex)))
;;;; general usage ;;;; general usage
(defclass function-event (program-event) ()) (defclass function-event (program-event) ())

View File

@ -523,6 +523,16 @@ Metadata includes:
"Print a quick help" "Print a quick help"
(keybindings:print-help *main-window*)) (keybindings:print-help *main-window*))
(defun apropos-help ()
"Print a command's documentation matching a regular expression."
(flet ((on-input-complete (regex)
(let ((event (make-instance 'help-apropos-event
:regex regex)))
(push-event event))))
(ask-string-input #'on-input-complete
:prompt (_ "Search for commands (regexp): ")
:complete-fn #'complete:complete-always-empty)))
(defun move-message-tree () (defun move-message-tree ()
"Move messages tree" "Move messages tree"
(flet ((on-input-complete (new-folder) (flet ((on-input-complete (new-folder)