Menu items execute functions on RETURN

This commit is contained in:
Jaidyn Ann 2023-06-07 21:51:22 -05:00
parent f06849b710
commit 7956aef3e5

14
ui.lisp
View File

@ -46,9 +46,9 @@ with menus."
(defun ui-update (matrix menu-alist) (defun ui-update (matrix menu-alist)
"The update loop for menus. It processes all input, state, etc, and "The update loop for menus. It processes all input, state, etc, and
returns the new state of the menu." returns the new state of the menu."
(render-menu-strip matrix menu-alist 0 0)
(progress-menu-items menu-alist) (progress-menu-items menu-alist)
(process-menu-input menu-alist) (process-menu-input menu-alist)
(render-menu-strip matrix menu-alist 0 0)
menu-alist) menu-alist)
@ -172,11 +172,15 @@ That is, 0 for non-selected items and 100 for selected items."
(defun process-menu-input (menu-alist) (defun process-menu-input (menu-alist)
"Get and process any keyboard input, modifying the menu alist as necessary." "Get and process any keyboard input, modifying the menu alist as necessary."
(when (listen) (when (listen)
(let ((input (normalize-char-plist (read-char-plist))) (let* ((input (normalize-char-plist (read-char-plist)))
(current (selected-menu-item-position menu-alist))) (selected-item (nth (selected-menu-item-position menu-alist)
menu-alist)))
(case (getf input :char) (case (getf input :char)
(#\→ (select-right-menu-item menu-alist)) (#\→ (select-right-menu-item menu-alist))
(#\← (select-left-menu-item menu-alist)))))) (#\← (select-left-menu-item menu-alist)))
(if (eq (getf input :char) #\return)
(ignore-errors (apply (cdr (assoc 'function (cdr selected-item))) '()))))))
(defun select-menu-item (menu-alist position) (defun select-menu-item (menu-alist position)