Changeset View
Changeset View
Standalone View
Standalone View
stand/forth/menu.4th
Show First 20 Lines • Show All 985 Lines • ▼ Show 20 Lines | |||||
\ Erase and redraw the menu. Useful if you change a caption and want to | \ Erase and redraw the menu. Useful if you change a caption and want to | ||||
\ update the menu to reflect the new value. | \ update the menu to reflect the new value. | ||||
\ | \ | ||||
: menu-redraw ( -- ) | : menu-redraw ( -- ) | ||||
menu-erase | menu-erase | ||||
menu-create | menu-create | ||||
; | ; | ||||
: menu-box | |||||
f_double ( default frame type ) | |||||
\ Interpret a custom frame type for the menu | |||||
TRUE ( draw a box? default yes, but might be altered below ) | |||||
s" loader_menu_frame" getenv dup -1 = if ( 1 ) | |||||
drop \ no custom frame type | |||||
else ( 1 ) 2dup s" single" compare-insensitive 0= if ( 2 ) | |||||
f_single ( see frames.4th ) | |||||
else ( 2 ) 2dup s" double" compare-insensitive 0= if ( 3 ) | |||||
f_double ( see frames.4th ) | |||||
else ( 3 ) s" none" compare-insensitive 0= if ( 4 ) | |||||
drop FALSE \ don't draw a box | |||||
( 4 ) then ( 3 ) then ( 2 ) then ( 1 ) then | |||||
if | |||||
42 13 menuX @ 3 - menuY @ 1- box \ Draw frame (w,h,x,y) | |||||
then | |||||
; | |||||
\ This function initializes the menu. Call this from your `loader.rc' file | \ This function initializes the menu. Call this from your `loader.rc' file | ||||
\ before calling any other menu-related functions. | \ before calling any other menu-related functions. | ||||
\ | \ | ||||
: menu-init ( -- ) | : menu-init ( -- ) | ||||
menu_start | menu_start | ||||
1- menuidx ! \ Initialize the starting index for the menu | 1- menuidx ! \ Initialize the starting index for the menu | ||||
0 menurow ! \ Initialize the starting position for the menu | 0 menurow ! \ Initialize the starting position for the menu | ||||
Show All 14 Lines | : menu-init ( -- ) | ||||
else | else | ||||
\ make sure custom position is a number | \ make sure custom position is a number | ||||
?number 0= if | ?number 0= if | ||||
menu_default_x \ or use default | menu_default_x \ or use default | ||||
then | then | ||||
then | then | ||||
menuX ! | menuX ! | ||||
\ Interpret a custom frame type for the menu | ['] menu-box console-iterate | ||||
TRUE ( draw a box? default yes, but might be altered below ) | |||||
s" loader_menu_frame" getenv dup -1 = if ( 1 ) | |||||
drop \ no custom frame type | |||||
else ( 1 ) 2dup s" single" compare-insensitive 0= if ( 2 ) | |||||
f_single ( see frames.4th ) | |||||
else ( 2 ) 2dup s" double" compare-insensitive 0= if ( 3 ) | |||||
f_double ( see frames.4th ) | |||||
else ( 3 ) s" none" compare-insensitive 0= if ( 4 ) | |||||
drop FALSE \ don't draw a box | |||||
( 4 ) then ( 3 ) then ( 2 ) then ( 1 ) then | |||||
if | |||||
42 13 menuX @ 3 - menuY @ 1- box \ Draw frame (w,h,x,y) | |||||
then | |||||
0 25 at-xy \ Move cursor to the bottom for output | 0 25 at-xy \ Move cursor to the bottom for output | ||||
; | ; | ||||
also menu-namespace | also menu-namespace | ||||
\ Main function. Call this from your `loader.rc' file. | \ Main function. Call this from your `loader.rc' file. | ||||
\ | \ | ||||
: menu-display ( -- ) | : menu-display ( -- ) | ||||
▲ Show 20 Lines • Show All 273 Lines • Show Last 20 Lines |