[Midnightbsd-cvs] src [10198] trunk/sys/boot/forth/menu.4th: update menu file

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Jun 1 19:56:29 EDT 2018


Revision: 10198
          http://svnweb.midnightbsd.org/src/?rev=10198
Author:   laffer1
Date:     2018-06-01 19:56:29 -0400 (Fri, 01 Jun 2018)
Log Message:
-----------
update menu file

Modified Paths:
--------------
    trunk/sys/boot/forth/menu.4th

Modified: trunk/sys/boot/forth/menu.4th
===================================================================
--- trunk/sys/boot/forth/menu.4th	2018-06-01 23:55:37 UTC (rev 10197)
+++ trunk/sys/boot/forth/menu.4th	2018-06-01 23:56:29 UTC (rev 10198)
@@ -1,6 +1,6 @@
-\ Copyright (c) 2003 Scott Long <scottl at freebsd.org>
+\ Copyright (c) 2003 Scott Long <scottl at FreeBSD.org>
 \ Copyright (c) 2003 Aleksander Fafula <alex at fafula.com>
-\ Copyright (c) 2006-2013 Devin Teske <dteske at FreeBSD.org>
+\ Copyright (c) 2006-2015 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
 \ SUCH DAMAGE.
 \ 
 \ $MidnightBSD$
-\ $FreeBSD: stable/9/sys/boot/forth/menu.4th 263701 2014-03-25 03:19:03Z dteske $
+\ $FreeBSD: stable/10/sys/boot/forth/menu.4th 299706 2016-05-14 00:44:23Z pfg $
 
 marker task-menu.4th
 
@@ -32,6 +32,12 @@
 \ Frame drawing
 include /boot/frames.4th
 
+vocabulary menu-infrastructure
+vocabulary menu-namespace
+vocabulary menu-command-helpers
+
+only forth also menu-infrastructure definitions
+
 f_double        \ Set frames to double (see frames.4th). Replace with
                 \ f_single if you want single frames.
 46 constant dot \ ASCII definition of a period (in decimal)
@@ -58,6 +64,28 @@
 variable menuX     \ Menu X offset (columns)
 variable menuY     \ Menu Y offset (rows)
 
+\ Menu-item elements
+variable menurebootadded
+
+\ Parsing of kernels into menu-items
+variable kernidx
+variable kernlen
+variable kernmenuidx
+
+\ Menu timer [count-down] variables
+variable menu_timeout_enabled \ timeout state (internal use only)
+variable menu_time            \ variable for tracking the passage of time
+variable menu_timeout         \ determined configurable delay duration
+variable menu_timeout_x       \ column position of timeout message
+variable menu_timeout_y       \ row position of timeout message
+
+\ Containers for parsing kernels into menu-items
+create kerncapbuf 64 allot
+create kerndefault 64 allot
+create kernelsbuf 256 allot
+
+only forth also menu-namespace definitions
+
 \ Menu-item key association/detection
 variable menukey1
 variable menukey2
@@ -68,23 +96,10 @@
 variable menukey7
 variable menukey8
 variable menureboot
-variable menurebootadded
 variable menuacpi
 variable menuoptions
 variable menukernel
 
-\ Parsing of kernels into menu-items
-variable kernidx
-variable kernlen
-variable kernmenuidx
-
-\ Menu timer [count-down] variables
-variable menu_timeout_enabled \ timeout state (internal use only)
-variable menu_time            \ variable for tracking the passage of time
-variable menu_timeout         \ determined configurable delay duration
-variable menu_timeout_x       \ column position of timeout message
-variable menu_timeout_y       \ row position of timeout message
-
 \ Menu initialization status variables
 variable init_state1
 variable init_state2
@@ -125,11 +140,35 @@
 create init_text7 64 allot
 create init_text8 64 allot
 
-\ Containers for parsing kernels into menu-items
-create kerncapbuf 64 allot
-create kerndefault 64 allot
-create kernelsbuf 256 allot
+only forth definitions
 
+: arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise.
+	s" arch-i386" environment? dup if
+		drop
+	then
+;
+
+: acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise
+	s" hint.acpi.0.rsdp" getenv
+	dup -1 = if
+		drop false exit
+	then
+	2drop
+	true
+;
+
+: acpienabled? ( -- flag ) \ Returns TRUE if ACPI is enabled, FALSE otherwise
+	s" hint.acpi.0.disabled" getenv
+	dup -1 <> if
+		s" 0" compare 0<> if
+			false exit
+		then
+	else
+		drop
+	then
+	true
+;
+
 : +c! ( N C-ADDR/U K -- C-ADDR/U )
 	3 pick 3 pick	( n c-addr/u k -- n c-addr/u k n c-addr )
 	rot + c!	( n c-addr/u k n c-addr -- n c-addr/u )
@@ -136,21 +175,17 @@
 	rot drop	( n c-addr/u -- c-addr/u )
 ;
 
-: delim? ( C -- BOOL )
-	dup  32 =		( c -- c bool )		\ [sp] space
-	over  9 = or		( c bool -- c bool )	\ [ht] horizontal tab
-	over 10 = or		( c bool -- c bool )	\ [nl] newline
-	over 13 = or		( c bool -- c bool )	\ [cr] carriage return
-	over [char] , =	or	( c bool -- c bool )	\ comma
-	swap drop		( c bool -- bool )	\ return boolean
-;
+only forth also menu-namespace definitions
 
-: menukeyN      ( N -- ADDR )   s" menukeyN"       7 +c! evaluate ;
-: init_stateN   ( N -- ADDR )   s" init_stateN"   10 +c! evaluate ;
-: toggle_stateN ( N -- ADDR )   s" toggle_stateN" 12 +c! evaluate ;
-: cycle_stateN  ( N -- ADDR )   s" cycle_stateN"  11 +c! evaluate ;
-: init_textN    ( N -- C-ADDR ) s" init_textN"     9 +c! evaluate ;
+\ Forth variables
+: namespace     ( C-ADDR/U N -- ) also menu-namespace +c! evaluate previous ;
+: menukeyN      ( N -- ADDR )   s" menukeyN"       7 namespace ;
+: init_stateN   ( N -- ADDR )   s" init_stateN"   10 namespace ;
+: toggle_stateN ( N -- ADDR )   s" toggle_stateN" 12 namespace ;
+: cycle_stateN  ( N -- ADDR )   s" cycle_stateN"  11 namespace ;
+: init_textN    ( N -- C-ADDR ) s" init_textN"     9 namespace ;
 
+\ Environment variables
 : kernel[x]          ( N -- C-ADDR/U )   s" kernel[x]"           7 +c! ;
 : menu_init[x]       ( N -- C-ADDR/U )   s" menu_init[x]"       10 +c! ;
 : menu_command[x]    ( N -- C-ADDR/U )   s" menu_command[x]"    13 +c! ;
@@ -162,11 +197,7 @@
 : menu_caption[x][y] ( N M -- C-ADDR/U ) s" menu_caption[x][y]" 16 +c! 13 +c! ;
 : ansi_caption[x][y] ( N M -- C-ADDR/U ) s" ansi_caption[x][y]" 16 +c! 13 +c! ;
 
-: arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise.
-	s" arch-i386" environment? dup if
-		drop
-	then
-;
+also menu-infrastructure definitions
 
 \ This function prints a menu item at menuX (row) and menuY (column), returns
 \ the incremental decimal ASCII value associated with the menu item, and
@@ -176,6 +207,8 @@
 \ 
 : printmenuitem ( menu_item_str -- ascii_keycode )
 
+	loader_color? if [char] ^ escc! then
+
 	menurow dup @ 1+ swap ! ( increment menurow )
 	menuidx dup @ 1+ swap ! ( increment menuidx )
 
@@ -186,13 +219,10 @@
 	dup menuX @ swap at-xy
 
 	\ Print the value of menuidx
-	loader_color? if
-		." " (  )
-	then
+	loader_color? dup ( -- bool bool )
+	if b then
 	menuidx @ .
-	loader_color? if
-		." " (  )
-	then
+	if me then
 
 	\ Move the cursor forward 1 column
 	dup menuX @ 1+ swap at-xy
@@ -213,196 +243,6 @@
 	menuidx @ 48 +
 ;
 
-: toggle_menuitem ( N -- N ) \ toggles caption text and internal menuitem state
-
-	\ ASCII numeral equal to user-selected menu item must be on the stack.
-	\ We do not modify the stack, so the ASCII numeral is left on top.
-
-	dup init_textN c@ 0= if
-		\ NOTE: no need to check toggle_stateN since the first time we
-		\ are called, we will populate init_textN. Further, we don't
-		\ need to test whether menu_caption[x] (ansi_caption[x] when
-		\ loader_color?=1) is available since we would not have been
-		\ called if the caption was NULL.
-
-		\ base name of environment variable
-		dup ( n -- n n ) \ key pressed
-		loader_color? if
-			ansi_caption[x]
-		else
-			menu_caption[x]
-		then	
-		getenv dup -1 <> if
-
-			2 pick ( n c-addr/u -- n c-addr/u n )
-			init_textN ( n c-addr/u n -- n c-addr/u c-addr )
-
-			\ now we have the buffer c-addr on top
-			\ ( followed by c-addr/u of current caption )
-
-			\ Copy the current caption into our buffer
-			2dup c! -rot \ store strlen at first byte
-			begin
-				rot 1+    \ bring alt addr to top and increment
-				-rot -rot \ bring buffer addr to top
-				2dup c@ swap c! \ copy current character
-				1+     \ increment buffer addr
-				rot 1- \ bring buffer len to top and decrement
-				dup 0= \ exit loop if buffer len is zero
-			until
-			2drop \ buffer len/addr
-			drop  \ alt addr
-
-		else
-			drop
-		then
-	then
-
-	\ Now we are certain to have init_textN populated with the initial
-	\ value of menu_caption[x] (ansi_caption[x] with loader_color enabled).
-	\ We can now use init_textN as the untoggled caption and
-	\ toggled_text[x] (toggled_ansi[x] with loader_color enabled) as the
-	\ toggled caption and store the appropriate value into menu_caption[x]
-	\ (again, ansi_caption[x] with loader_color enabled). Last, we'll
-	\ negate the toggled state so that we reverse the flow on subsequent
-	\ calls.
-
-	dup toggle_stateN @ 0= if
-		\ state is OFF, toggle to ON
-
-		dup ( n -- n n ) \ key pressed
-		loader_color? if
-			toggled_ansi[x]
-		else
-			toggled_text[x]
-		then
-		getenv dup -1 <> if
-			\ Assign toggled text to menu caption
-			2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
-			loader_color? if
-				ansi_caption[x]
-			else
-				menu_caption[x]
-			then
-			setenv
-		else
-			\ No toggled text, keep the same caption
-			drop ( n -1 -- n ) \ getenv cruft
-		then
-
-		true \ new value of toggle state var (to be stored later)
-	else
-		\ state is ON, toggle to OFF
-
-		dup init_textN count ( n -- n c-addr/u )
-
-		\ Assign init_textN text to menu caption
-		2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
-		loader_color? if
-			ansi_caption[x]
-		else
-			menu_caption[x]
-		then
-		setenv
-
-		false \ new value of toggle state var (to be stored below)
-	then
-
-	\ now we'll store the new toggle state (on top of stack)
-	over toggle_stateN !
-;
-
-: cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem
-
-	\ ASCII numeral equal to user-selected menu item must be on the stack.
-	\ We do not modify the stack, so the ASCII numeral is left on top.
-
-	dup cycle_stateN dup @ 1+ \ get value and increment
-
-	\ Before assigning the (incremented) value back to the pointer,
-	\ let's test for the existence of this particular array element.
-	\ If the element exists, we'll store index value and move on.
-	\ Otherwise, we'll loop around to zero and store that.
-
-	dup 48 + ( n addr k -- n addr k k' )
-	         \ duplicate array index and convert to ASCII numeral
-
-	3 pick swap ( n addr k k' -- n addr k n k' ) \ (n,k') as (x,y)
-	loader_color? if
-		ansi_caption[x][y]
-	else
-		menu_caption[x][y]
-	then
-	( n addr k n k' -- n addr k c-addr/u )
-
-	\ Now test for the existence of our incremented array index in the
-	\ form of $menu_caption[x][y] ($ansi_caption[x][y] with loader_color
-	\ enabled) as set in loader.rc(5), et. al.
-
-	getenv dup -1 = if
-		\ No caption set for this array index. Loop back to zero.
-
-		drop ( n addr k -1 -- n addr k ) \ getenv cruft
-		drop 0 ( n addr k -- n addr 0 )  \ new value to store later
-
-		2 pick [char] 0 ( n addr 0 -- n addr 0 n 48 ) \ (n,48) as (x,y)
-		loader_color? if
-			ansi_caption[x][y]
-		else
-			menu_caption[x][y]
-		then
-		( n addr 0 n 48 -- n addr 0 c-addr/u )
-		getenv dup -1 = if
-			\ Highly unlikely to occur, but to ensure things move
-			\ along smoothly, allocate a temporary NULL string
-			drop ( cruft ) s" "
-		then
-	then
-
-	\ At this point, we should have the following on the stack (in order,
-	\ from bottom to top):
-	\ 
-	\    n        - Ascii numeral representing the menu choice (inherited)
-	\    addr     - address of our internal cycle_stateN variable
-	\    k        - zero-based number we intend to store to the above
-	\    c-addr/u - string value we intend to store to menu_caption[x]
-	\               (or ansi_caption[x] with loader_color enabled)
-	\ 
-	\ Let's perform what we need to with the above.
-
-	\ Assign array value text to menu caption
-	4 pick ( n addr k c-addr/u -- n addr k c-addr/u n )
-	loader_color? if
-		ansi_caption[x]
-	else
-		menu_caption[x]
-	then
-	setenv
-
-	swap ! ( n addr k -- n ) \ update array state variable
-;
-
-: acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise
-	s" hint.acpi.0.rsdp" getenv
-	dup -1 = if
-		drop false exit
-	then
-	2drop
-	true
-;
-
-: acpienabled? ( -- flag ) \ Returns TRUE if ACPI is enabled, FALSE otherwise
-	s" hint.acpi.0.disabled" getenv
-	dup -1 <> if
-		s" 0" compare 0<> if
-			false exit
-		then
-	else
-		drop
-	then
-	true
-;
-
 \ This function prints the appropriate menuitem basename to the stack if an
 \ ACPI option is to be presented to the user, otherwise returns -1. Used
 \ internally by menu-create, you need not (nor should you) call this directly.
@@ -433,8 +273,17 @@
 	then
 ;
 
+: delim? ( C -- BOOL )
+	dup  32 =		( c -- c bool )		\ [sp] space
+	over  9 = or		( c bool -- c bool )	\ [ht] horizontal tab
+	over 10 = or		( c bool -- c bool )	\ [nl] newline
+	over 13 = or		( c bool -- c bool )	\ [cr] carriage return
+	over [char] , =	or	( c bool -- c bool )	\ comma
+	swap drop		( c bool -- bool )	\ return boolean
+;
+
 \ This function parses $kernels into variables that are used by the menu to
-\ display wich kernel to boot when the [overloaded] `boot' word is interpreted.
+\ display which kernel to boot when the [overloaded] `boot' word is interpreted.
 \ Used internally by menu-create, you need not (nor should you) call this
 \ directly.
 \ 
@@ -549,14 +398,15 @@
 		setenv
 
 		\ Assign third to ansi_caption[x][y]
-		kerncapbuf 0 s" Kernel: " strcat
+		kerncapbuf 0 s" @[1mK@[37mernel: " [char] @ escc! strcat
 		kernmenuidx @ [char] 0 = if
-			s" default/"
+			s" default/@[32m"
 		else
-			s" "
-		then strcat
+			s" @[34;1m"
+		then
+		[char] @ escc! strcat
 		2over strcat
-		s" " strcat
+		s" @[37m" [char] @ escc! strcat
 		kernidx @ kernmenuidx @ ansi_caption[x][y]
 		setenv
 
@@ -615,13 +465,13 @@
 ;
 
 \ This function creates the list of menu items. This function is called by the
-\ menu-display function. You need not be call it directly.
+\ menu-display function. You need not call it directly.
 \ 
 : menu-create ( -- )
 
 	\ Print the frame caption at (x,y)
 	s" loader_menu_title" getenv dup -1 = if
-		drop s" Welcome to MidnightBSD"
+		drop s" Welcome to FreeBSD"
 	then
 	TRUE ( use default alignment )
 	s" loader_menu_title_align" getenv dup -1 <> if
@@ -941,7 +791,7 @@
 	again
 ;
 
-: menu-erase ( -- ) \ Erases menu and resets positioning variable to positon 1.
+: menu-erase ( -- ) \ Erases menu and resets positioning variable to position 1.
 
 	\ Clear the screen area associated with the interactive menu
 	menuX @ menuY @
@@ -958,6 +808,182 @@
 	0 menurow !
 ;
 
+only forth
+also menu-infrastructure
+also menu-namespace
+also menu-command-helpers definitions
+
+: toggle_menuitem ( N -- N ) \ toggles caption text and internal menuitem state
+
+	\ ASCII numeral equal to user-selected menu item must be on the stack.
+	\ We do not modify the stack, so the ASCII numeral is left on top.
+
+	dup init_textN c@ 0= if
+		\ NOTE: no need to check toggle_stateN since the first time we
+		\ are called, we will populate init_textN. Further, we don't
+		\ need to test whether menu_caption[x] (ansi_caption[x] when
+		\ loader_color?=1) is available since we would not have been
+		\ called if the caption was NULL.
+
+		\ base name of environment variable
+		dup ( n -- n n ) \ key pressed
+		loader_color? if
+			ansi_caption[x]
+		else
+			menu_caption[x]
+		then	
+		getenv dup -1 <> if
+
+			2 pick ( n c-addr/u -- n c-addr/u n )
+			init_textN ( n c-addr/u n -- n c-addr/u c-addr )
+
+			\ now we have the buffer c-addr on top
+			\ ( followed by c-addr/u of current caption )
+
+			\ Copy the current caption into our buffer
+			2dup c! -rot \ store strlen at first byte
+			begin
+				rot 1+    \ bring alt addr to top and increment
+				-rot -rot \ bring buffer addr to top
+				2dup c@ swap c! \ copy current character
+				1+     \ increment buffer addr
+				rot 1- \ bring buffer len to top and decrement
+				dup 0= \ exit loop if buffer len is zero
+			until
+			2drop \ buffer len/addr
+			drop  \ alt addr
+
+		else
+			drop
+		then
+	then
+
+	\ Now we are certain to have init_textN populated with the initial
+	\ value of menu_caption[x] (ansi_caption[x] with loader_color enabled).
+	\ We can now use init_textN as the untoggled caption and
+	\ toggled_text[x] (toggled_ansi[x] with loader_color enabled) as the
+	\ toggled caption and store the appropriate value into menu_caption[x]
+	\ (again, ansi_caption[x] with loader_color enabled). Last, we'll
+	\ negate the toggled state so that we reverse the flow on subsequent
+	\ calls.
+
+	dup toggle_stateN @ 0= if
+		\ state is OFF, toggle to ON
+
+		dup ( n -- n n ) \ key pressed
+		loader_color? if
+			toggled_ansi[x]
+		else
+			toggled_text[x]
+		then
+		getenv dup -1 <> if
+			\ Assign toggled text to menu caption
+			2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
+			loader_color? if
+				ansi_caption[x]
+			else
+				menu_caption[x]
+			then
+			setenv
+		else
+			\ No toggled text, keep the same caption
+			drop ( n -1 -- n ) \ getenv cruft
+		then
+
+		true \ new value of toggle state var (to be stored later)
+	else
+		\ state is ON, toggle to OFF
+
+		dup init_textN count ( n -- n c-addr/u )
+
+		\ Assign init_textN text to menu caption
+		2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
+		loader_color? if
+			ansi_caption[x]
+		else
+			menu_caption[x]
+		then
+		setenv
+
+		false \ new value of toggle state var (to be stored below)
+	then
+
+	\ now we'll store the new toggle state (on top of stack)
+	over toggle_stateN !
+;
+
+: cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem
+
+	\ ASCII numeral equal to user-selected menu item must be on the stack.
+	\ We do not modify the stack, so the ASCII numeral is left on top.
+
+	dup cycle_stateN dup @ 1+ \ get value and increment
+
+	\ Before assigning the (incremented) value back to the pointer,
+	\ let's test for the existence of this particular array element.
+	\ If the element exists, we'll store index value and move on.
+	\ Otherwise, we'll loop around to zero and store that.
+
+	dup 48 + ( n addr k -- n addr k k' )
+	         \ duplicate array index and convert to ASCII numeral
+
+	3 pick swap ( n addr k k' -- n addr k n k' ) \ (n,k') as (x,y)
+	loader_color? if
+		ansi_caption[x][y]
+	else
+		menu_caption[x][y]
+	then
+	( n addr k n k' -- n addr k c-addr/u )
+
+	\ Now test for the existence of our incremented array index in the
+	\ form of $menu_caption[x][y] ($ansi_caption[x][y] with loader_color
+	\ enabled) as set in loader.rc(5), et. al.
+
+	getenv dup -1 = if
+		\ No caption set for this array index. Loop back to zero.
+
+		drop ( n addr k -1 -- n addr k ) \ getenv cruft
+		drop 0 ( n addr k -- n addr 0 )  \ new value to store later
+
+		2 pick [char] 0 ( n addr 0 -- n addr 0 n 48 ) \ (n,48) as (x,y)
+		loader_color? if
+			ansi_caption[x][y]
+		else
+			menu_caption[x][y]
+		then
+		( n addr 0 n 48 -- n addr 0 c-addr/u )
+		getenv dup -1 = if
+			\ Highly unlikely to occur, but to ensure things move
+			\ along smoothly, allocate a temporary NULL string
+			drop ( cruft ) s" "
+		then
+	then
+
+	\ At this point, we should have the following on the stack (in order,
+	\ from bottom to top):
+	\ 
+	\    n        - Ascii numeral representing the menu choice (inherited)
+	\    addr     - address of our internal cycle_stateN variable
+	\    k        - zero-based number we intend to store to the above
+	\    c-addr/u - string value we intend to store to menu_caption[x]
+	\               (or ansi_caption[x] with loader_color enabled)
+	\ 
+	\ Let's perform what we need to with the above.
+
+	\ Assign array value text to menu caption
+	4 pick ( n addr k c-addr/u -- n addr k c-addr/u n )
+	loader_color? if
+		ansi_caption[x]
+	else
+		menu_caption[x]
+	then
+	setenv
+
+	swap ! ( n addr k -- n ) \ update array state variable
+;
+
+only forth definitions also menu-infrastructure
+
 \ Erase and redraw the menu. Useful if you change a caption and want to
 \ update the menu to reflect the new value.
 \ 
@@ -1014,6 +1040,8 @@
 	0 25 at-xy \ Move cursor to the bottom for output
 ;
 
+also menu-namespace
+
 \ Main function. Call this from your `loader.rc' file.
 \ 
 : menu-display ( -- )
@@ -1235,6 +1263,8 @@
 	0 menuoptions !
 ;
 
+only forth definitions also menu-infrastructure
+
 \ This function both unsets menu variables and visually erases the menu area
 \ in-preparation for another menu.
 \ 
@@ -1245,6 +1275,8 @@
 
 bullet menubllt !
 
+also menu-namespace
+
 \ Initialize our menu initialization state variables
 0 init_state1 !
 0 init_state2 !
@@ -1284,3 +1316,5 @@
 0 init_text6 c!
 0 init_text7 c!
 0 init_text8 c!
+
+only forth definitions



More information about the Midnightbsd-cvs mailing list