Lines Matching +full:top +full:- +full:ctrl

3 \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
28 marker task-menu.4th
33 vocabulary menu-infrastructure
34 vocabulary menu-namespace
35 vocabulary menu-command-helpers
37 only forth also menu-infrastructure definitions
53 5 constant menu_x \ Row position of the menu (from the top)
65 \ Menu-item elements
68 \ Parsing of kernels into menu-items
73 \ Menu timer [count-down] variables
80 \ Containers for parsing kernels into menu-items
85 only forth also menu-namespace definitions
87 \ Menu-item key association/detection
143 : arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise.
144 s" arch-i386" environment? dup if
149 : acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise
151 dup -1 = if
158 : acpienabled? ( -- flag ) \ Returns TRUE if ACPI is enabled, FALSE otherwise
160 dup -1 <> if
170 : +c! ( N C-ADDR/U K -- C-ADDR/U )
171 3 pick 3 pick ( n c-addr/u k -- n c-addr/u k n c-addr )
172 rot + c! ( n c-addr/u k n c-addr -- n c-addr/u )
173 rot drop ( n c-addr/u -- c-addr/u )
176 only forth also menu-namespace definitions
179 : namespace ( C-ADDR/U N -- ) also menu-namespace +c! evaluate previous ;
180 : menukeyN ( N -- ADDR ) s" menukeyN" 7 namespace ;
181 : init_stateN ( N -- ADDR ) s" init_stateN" 10 namespace ;
182 : toggle_stateN ( N -- ADDR ) s" toggle_stateN" 12 namespace ;
183 : cycle_stateN ( N -- ADDR ) s" cycle_stateN" 11 namespace ;
184 : init_textN ( N -- C-ADDR ) s" init_textN" 9 namespace ;
187 : kernel[x] ( N -- C-ADDR/U ) s" kernel[x]" 7 +c! ;
188 : menu_init[x] ( N -- C-ADDR/U ) s" menu_init[x]" 10 +c! ;
189 : menu_command[x] ( N -- C-ADDR/U ) s" menu_command[x]" 13 +c! ;
190 : menu_caption[x] ( N -- C-ADDR/U ) s" menu_caption[x]" 13 +c! ;
191 : ansi_caption[x] ( N -- C-ADDR/U ) s" ansi_caption[x]" 13 +c! ;
192 : menu_keycode[x] ( N -- C-ADDR/U ) s" menu_keycode[x]" 13 +c! ;
193 : toggled_text[x] ( N -- C-ADDR/U ) s" toggled_text[x]" 13 +c! ;
194 : toggled_ansi[x] ( N -- C-ADDR/U ) s" toggled_ansi[x]" 13 +c! ;
195 : menu_caption[x][y] ( N M -- C-ADDR/U ) s" menu_caption[x][y]" 16 +c! 13 +c! ;
196 : ansi_caption[x][y] ( N M -- C-ADDR/U ) s" ansi_caption[x][y]" 16 +c! 13 +c! ;
198 also menu-infrastructure definitions
203 \ menu item. This function is called by the menu-create function. You need not
206 : printmenuitem ( menu_item_str -- ascii_keycode )
217 dup menuX @ swap at-xy
220 loader_color? dup ( -- bool bool )
226 dup menuX @ 1+ swap at-xy
233 menuX @ 3 + swap at-xy
245 \ ACPI option is to be presented to the user, otherwise returns -1. Used
246 \ internally by menu-create, you need not (nor should you) call this directly.
248 : acpimenuitem ( -- C-Addr/U | -1 )
250 arch-i386? if
267 -1
270 -1
274 : delim? ( C -- BOOL )
275 dup 32 = ( c -- c bool ) \ [sp] space
276 over 9 = or ( c bool -- c bool ) \ [ht] horizontal tab
277 over 10 = or ( c bool -- c bool ) \ [nl] newline
278 over 13 = or ( c bool -- c bool ) \ [cr] carriage return
279 over [char] , = or ( c bool -- c bool ) \ comma
280 swap drop ( c bool -- bool ) \ return boolean
285 \ Used internally by menu-create, you need not (nor should you) call this
288 : parse-kernels ( N -- ) \ kernidx
289 kernidx ! ( n -- ) \ store provided `x' value
293 s" kernels" getenv dup -1 = if
296 then ( -- c-addr/u )
301 dup -1 <> if
302 s" kernel" getenv dup -1 = if
312 s" kernel" getenv dup -1 = if
316 then ( c-addr/u -- c-addr/u c-addr/u,-1 | 0 )
318 kerndefault 1+ 0 2swap strcat swap 1- c!
321 \ Clear out existing parsed-kernels
338 over c@ delim? ( c-addr/u -- c-addr/u bool )
340 false ( c-addr/u -- c-addr/u bool )
343 1- swap 1+ swap ( c-addr/u -- c-addr'/u' )
345 ( c-addr/u -- c-addr'/u' )
348 2drop ( c-addr/u -- )
354 s" kernel" getenv dup -1 = if
356 then ( -- c-addr/u )
361 2dup ( c-addr/u -- c-addr/u c-addr/u )
367 1- swap 1+ swap \ c-addr++ u--
370 2drop ( c-addr/u c-addr'/u' -- c-addr/u )
382 ( c-addr/u -- c-addr'/u' )
387 over kernlen @ ( c-addr/u -- c-addr/u c-addr/u2 )
411 2drop ( c-addr/u c-addr/u2 -- c-addr/u )
414 2drop ( c-addr/u -- ) exit
417 kernlen @ - swap kernlen @ + swap ( c-addr/u -- c-addr'/u' )
422 \ parse-kernels function [above], adding " (# of #)" text to the end of each
425 : tag-kernels ( -- )
426 kernidx @ ( -- x ) dup 0= if exit then
427 [char] 0 s" (Y of Z)" ( x -- x y c-addr/u )
428 kernmenuidx @ -rot 7 +c! \ Replace 'Z' with number of kernels parsed
430 2 pick 1+ -rot 2 +c! \ Replace 'Y' with current ASCII num
432 2over menu_caption[x][y] getenv dup -1 <> if
433 2dup + 1- c@ [char] ) = if
444 2over ansi_caption[x][y] getenv dup -1 <> if
445 2dup + 1- c@ [char] ) = if
457 -rot 2drop TRUE ( break )
459 -rot FALSE
462 2drop ( x y -- )
466 \ menu-display function. You need not call it directly.
468 : menu-create ( -- )
471 s" loader_menu_title" getenv dup -1 = if
475 s" loader_menu_title_align" getenv dup -1 <> if
476 2dup s" left" compare-insensitive 0= if ( 1 )
477 2drop ( c-addr/u ) drop ( bool )
478 menuX @ menuY @ 1-
480 else ( 1 ) 2dup s" right" compare-insensitive 0= if ( 2 )
481 2drop ( c-addr/u ) drop ( bool )
482 menuX @ 42 + 4 - over - menuY @ 1-
484 else ( 2 ) 2drop ( c-addr/u ) then ( 1 ) then
489 menuX @ 19 + over 2 / - menuY @ 1-
491 swap 1- swap
492 at-xy dup 0= if
499 \ constructed dynamically -- as this function could conceivably set
502 s" menu_init" getenv dup -1 <> if
527 s" menu_acpi" getenv -1 <> if
530 arch-i386? if acpipresent? if
546 s" menu_kernel" getenv -1 <> if
549 dup parse-kernels tag-kernels
552 s" kernel_state" evaluate @ 48 + ( n -- n y )
555 dup kernmenuidx @ 1- > if
556 drop [char] 0 ( n y -- n 48 )
561 \ Set the current non-ANSI caption
562 2dup swap dup ( n y -- n y y n n )
565 ( n y y n n c-addr/u -- n y )
568 2dup swap dup ( n y -- n y y n n )
571 ( n y y n n c-addr/u -- n y )
574 48 - ( n y -- n k )
575 s" init_cyclestate" evaluate ( n k -- n )
578 s" activate_kernel" evaluate ( n -- n )
587 s" menu_options" getenv -1 <> if
595 \ Initialize "Reboot" menu state variable (prevents double-entry)
599 1- menuidx ! \ Initialize the starting index for the menu
607 s" menu_reboot" getenv -1 <> if
616 at-xy
617 s" menu_optionstext" getenv dup -1 <> if
626 dup acpimenuitem ( n -- n n c-addr/u | n n -1 )
627 dup -1 <> if
628 13 +c! ( n n c-addr/u -- n c-addr/u )
631 swap drop ( n n -1 -- n -1 )
641 getenv dup -1 <> if
658 dup -1 <> if
660 getenv dup -1 <> if
661 printmenuitem ( c-addr/u -- n )
676 s" menu_reboot" getenv -1 <> if
692 : menu-timeout-update ( N -- )
698 s" Autoboot in N seconds. [Space] to pause" ( n -- n c-addr/u )
701 rot 48 + -rot ( n c-addr/u -- n' c-addr/u ) \ convert to ASCII
702 12 +c! ( n' c-addr/u -- c-addr/u ) \ replace 'N' above
704 menu_timeout_x @ menu_timeout_y @ at-xy \ position cursor
705 type ( c-addr/u -- ) \ print message
707 menu_timeout_x @ menu_timeout_y @ at-xy \ position cursor
708 spaces ( n c-addr/u -- n c-addr ) \ erase message
709 2drop ( n c-addr -- )
712 0 25 at-xy ( position cursor back at bottom-left )
716 \ The key that was pressed is added to the top of the stack in the form of its
717 \ decimal ASCII representation. This function is called by the menu-display
720 : getkey ( -- ascii_keycode )
725 ( -- )
726 seconds ( get current time: -- N )
727 dup menu_time @ <> if ( has time elapsed?: N N N -- N )
734 menu_time ! ( update time record: N -- )
735 menu_timeout @ ( "time" remaining: -- N )
736 dup 0> if ( greater than 0?: N N 0 -- N )
737 1- ( decrement counter: N -- N )
739 ( re-assign: N N Addr -- N )
741 ( -- N )
743 dup 0= swap 0< or if ( N <= 0?: N N -- )
745 0 menu_timeout ! ( 0 Addr -- )
746 0 menu_timeout_enabled ! ( 0 Addr -- )
749 \ update the timer display ( N -- )
750 menu_timeout @ menu-timeout-update
758 -1 = if
759 drop \ clean-up
765 else ( -- N )
767 drop ( N -- )
769 ( -- )
781 0 menu-timeout-update
785 \ get a non-zero ASCII code)
797 : menu-erase ( -- ) \ Erases menu and resets positioning variable to position 1.
801 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
802 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
803 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
804 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
805 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
806 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces
810 menu_start 1- menuidx !
815 also menu-infrastructure
816 also menu-namespace
817 also menu-command-helpers definitions
819 : toggle_menuitem ( N -- N ) \ toggles caption text and internal menuitem state
821 \ ASCII numeral equal to user-selected menu item must be on the stack.
822 \ We do not modify the stack, so the ASCII numeral is left on top.
832 dup ( n -- n n ) \ key pressed
838 getenv dup -1 <> if
840 2 pick ( n c-addr/u -- n c-addr/u n )
841 init_textN ( n c-addr/u n -- n c-addr/u c-addr )
843 \ now we have the buffer c-addr on top
844 \ ( followed by c-addr/u of current caption )
847 2dup c! -rot \ store strlen at first byte
849 rot 1+ \ bring alt addr to top and increment
850 -rot -rot \ bring buffer addr to top
853 rot 1- \ bring buffer len to top and decrement
876 dup ( n -- n n ) \ key pressed
882 getenv dup -1 <> if
884 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
893 drop ( n -1 -- n ) \ getenv cruft
900 dup init_textN count ( n -- n c-addr/u )
903 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
914 \ now we'll store the new toggle state (on top of stack)
918 : cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem
920 \ ASCII numeral equal to user-selected menu item must be on the stack.
921 \ We do not modify the stack, so the ASCII numeral is left on top.
930 dup 48 + ( n addr k -- n addr k k' )
933 3 pick swap ( n addr k k' -- n addr k n k' ) \ (n,k') as (x,y)
939 ( n addr k n k' -- n addr k c-addr/u )
945 getenv dup -1 = if
948 drop ( n addr k -1 -- n addr k ) \ getenv cruft
949 drop 0 ( n addr k -- n addr 0 ) \ new value to store later
951 2 pick [char] 0 ( n addr 0 -- n addr 0 n 48 ) \ (n,48) as (x,y)
957 ( n addr 0 n 48 -- n addr 0 c-addr/u )
958 getenv dup -1 = if
966 \ from bottom to top):
968 \ n - Ascii numeral representing the menu choice (inherited)
969 \ addr - address of our internal cycle_stateN variable
970 \ k - zero-based number we intend to store to the above
971 \ c-addr/u - string value we intend to store to menu_caption[x]
977 4 pick ( n addr k c-addr/u -- n addr k c-addr/u n )
985 swap ! ( n addr k -- n ) \ update array state variable
988 only forth definitions also menu-infrastructure
993 : menu-redraw ( -- )
994 menu-erase
995 menu-create
998 : menu-box
1002 s" loader_menu_frame" getenv dup -1 = if ( 1 )
1004 else ( 1 ) 2dup s" single" compare-insensitive 0= if ( 2 )
1006 else ( 2 ) 2dup s" double" compare-insensitive 0= if ( 3 )
1008 else ( 3 ) s" none" compare-insensitive 0= if ( 4 )
1012 42 13 menuX @ 3 - menuY @ 1- box \ Draw frame (w,h,x,y)
1017 \ before calling any other menu-related functions.
1019 : menu-init ( -- )
1021 1- menuidx ! \ Initialize the starting index for the menu
1025 s" loader_menu_y" getenv dup -1 = if
1035 s" loader_menu_x" getenv dup -1 = if
1046 ['] menu-box console-iterate
1047 0 25 at-xy \ Move cursor to the bottom for output
1050 also menu-namespace
1054 : menu-display ( -- )
1059 s" menu_timeout_command" getenv -1 <> if ( Addr C -1 -- | Addr )
1060 drop ( just testing existence right now: Addr -- )
1066 \ read custom time-duration (if set)
1067 s" autoboot_delay" getenv dup -1 = if
1068 drop \ no custom duration (remove dup'd bunk -1)
1073 s" NO" compare-insensitive 0= if
1080 -rot 2drop
1085 menu-create
1086 0 25 at-xy
1095 s" loader_menu_timeout_x" getenv dup -1 = if
1107 s" loader_menu_timeout_y" getenv dup -1 = if
1120 menu-create
1124 0 25 at-xy \ Move cursor to the bottom for output
1127 dup -1 = if
1131 \ Boot if the user pressed Enter/Ctrl-M (13) or
1132 \ Ctrl-Enter/Ctrl-J (10)
1149 \ Adjust for missing ACPI menuitem on non-i386
1150 arch-i386? true <> menuacpi @ 0<> and if
1151 menuacpi @ over 2dup < -rot = or
1153 ( key >= menuacpi && key < 58: N -- N )
1160 getenv dup -1 <> if
1164 \ We expect there to be a non-zero
1174 swap \ need iterator on top
1178 \ Re-adjust for missing ACPI menuitem
1179 arch-i386? true <> menuacpi @ 0<> and if
1181 menuacpi @ 1+ over 2dup < -rot = or
1183 1-
1188 swap \ need iterator on top
1195 getenv dup -1 = if
1202 getenv dup -1 <> if
1223 again \ Non-operational key was pressed; repeat
1229 : menu-unset ( -- )
1250 0 over menukeyN ! \ used by menu-create, menu-display
1251 0 over init_stateN ! \ used by menu-create
1273 only forth definitions also menu-infrastructure
1276 \ in-preparation for another menu.
1278 : menu-clear ( -- )
1279 menu-unset
1280 menu-erase
1285 also menu-namespace