cl-menusystem test
The test menu:
(defpackage #:cl-menusystem-test
(:use #:cl-menusystem #:common-lisp)
(:export *test-menu* *a-string*))
(in-package #:cl-menusystem-test)
(defvar *a-string* "Hi!")
(defmenu *test-menu* "A Menu" "Some Help"
(make-menu-action "Hello world!" nil
(rst) (format t "Hello yourself!~&"))
(make-menu "A random submenu" "Select an option from this submenu"
(make-menu-action "Jump!" nil
(rst) (format t "Whee!~&"))
(make-menu-action "Exit to previous menu" nil
(rst) (invoke-restart rst)))
(make-menu-action "A submenu with two exits" nil
(toplevel-rst) (do-menu (make-menu "Two exits!" nil
(make-menu-action "Exit this submenu" nil
(rst) (invoke-restart rst))
(make-menu-action "Exit all the way" nil
(rst) (invoke-restart toplevel-rst "Foo!")))
*menu-output*
*menu-input*))
(make-menu "A preference" "This submenu allows you to edit cl-menusystem-test:*a-string*"
(make-state-presentable "Value of *a-string*" (format nil "*a-string*'s value is currently: ~A" *a-string*))
(make-menu-action "Edit the value of *a-string*" nil
(rst) (setf *a-string* (request-one-line-string *menu-output* *menu-input* "Set the value of *a-string*")))
(make-menu-action "Exit to previous menu" nil
(rst) (invoke-restart rst)))
(make-menu-action "Exit this menu" nil
(rst) (invoke-restart rst 42)))
And using it:
CL-USER(8): (cl-menusystem:do-menu cl-menusystem-test:*test-menu* *query-io* *query-io*)
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 1
Hello yourself!
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 2
Please select from the following 3 options:
1: Jump!
2: Exit to previous menu
3: Detailed help on this menu
Select an option from the menu> 1
Whee!
Please select from the following 3 options:
1: Jump!
2: Exit to previous menu
3: Detailed help on this menu
Select an option from the menu> 2
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 4
Please select from the following 4 options:
1: State hidden for: Value of *a-string*
2: Edit the value of *a-string*
3: Exit to previous menu
4: Detailed help on this menu
Select an option from the menu> 1
Value of *a-string*
*a-string*'s value is currently: Hi!
Please select from the following 4 options:
1: State hidden for: Value of *a-string*
2: Edit the value of *a-string*
3: Exit to previous menu
4: Detailed help on this menu
Select an option from the menu> 2
Enter a string> Hello, world!
Please select from the following 4 options:
1: State hidden for: Value of *a-string*
2: Edit the value of *a-string*
3: Exit to previous menu
4: Detailed help on this menu
Select an option from the menu> 1
Value of *a-string*
*a-string*'s value is currently: Hello, world!
Please select from the following 4 options:
1: State hidden for: Value of *a-string*
2: Edit the value of *a-string*
3: Exit to previous menu
4: Detailed help on this menu
Select an option from the menu> 4
This submenu allows you to edit cl-menusystem-test:*a-string*
Please select from the following 4 options:
1: State hidden for: Value of *a-string*
2: Edit the value of *a-string*
3: Exit to previous menu
4: Detailed help on this menu
Select an option from the menu> 5
Invalid entry: Please select an option between 1 and 4.
Please select from the following 4 options:
1: State hidden for: Value of *a-string*
2: Edit the value of *a-string*
3: Exit to previous menu
4: Detailed help on this menu
Select an option from the menu> 3
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> ngawekl
Invalid entry: This input must be an integer.
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 5
42
CL-USER(9): (cl-menusystem:do-menu cl-menusystem-test:*test-menu* *query-io* *query-io*)
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 3
Please select from the following 3 options:
1: Exit this submenu
2: Exit all the way
3: Detailed help on this menu
Select an option from the menu> 1
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu>
Invalid entry: This input must be an integer.
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 3
Please select from the following 3 options:
1: Exit this submenu
2: Exit all the way
3: Detailed help on this menu
Select an option from the menu> 1
Please select from the following 6 options:
1: Hello world!
2: A random submenu
3: A submenu with two exits
4: A preference
5: Exit this menu
6: Detailed help on this menu
Select an option from the menu> 3
Please select from the following 3 options:
1: Exit this submenu
2: Exit all the way
3: Detailed help on this menu
Select an option from the menu> 2
"Foo!"
Local exit