Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Apr 2015 01:54:29 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r280937 - head/sys/boot/forth
Message-ID:  <201504010154.t311sTSf053084@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Wed Apr  1 01:54:28 2015
New Revision: 280937
URL: https://svnweb.freebsd.org/changeset/base/280937

Log:
  Solve dreaded "dictionary full" issue by segregating words into new
  vocabularies delay-processing, password-processing, version-processing,
  frame-drawing, menu-infrastructure, menu-namespace, menu-command-helpers,
  and menusets-infrastructure. The net effect is to remove almost 200
  definitions from the main forth vocabulary reducing the dictionary size
  by over 50%. The chances of hitting "dictionary full" should be greatly
  reduced by this patch.
  
  MFC after:	3 days
  X-MFC-to:	stable/10

Modified:
  head/sys/boot/forth/beastie.4th
  head/sys/boot/forth/check-password.4th
  head/sys/boot/forth/delay.4th
  head/sys/boot/forth/frames.4th
  head/sys/boot/forth/loader.4th
  head/sys/boot/forth/menu-commands.4th
  head/sys/boot/forth/menu.4th
  head/sys/boot/forth/menusets.4th
  head/sys/boot/forth/support.4th
  head/sys/boot/forth/version.4th

Modified: head/sys/boot/forth/beastie.4th
==============================================================================
--- head/sys/boot/forth/beastie.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/beastie.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -28,7 +28,7 @@
 
 marker task-beastie.4th
 
-only forth definitions also support-functions
+only forth definitions
 
 variable logoX
 variable logoY
@@ -82,6 +82,8 @@ variable logoY
 	then
 ;
 
+also support-functions
+
 : beastie-start ( -- ) \ starts the menu
 	s" console" getenv dup -1 <> if
 		s" efi" 2swap contains? if
@@ -110,4 +112,4 @@ variable logoY
 	then
 ;
 
-only forth also
+only forth definitions

Modified: head/sys/boot/forth/check-password.4th
==============================================================================
--- head/sys/boot/forth/check-password.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/check-password.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -28,6 +28,9 @@ marker task-check-password.4th
 
 include /boot/screen.4th
 
+vocabulary password-processing
+only forth also password-processing definitions
+
 13  constant enter_key       \ The decimal ASCII value for Enter key
 8   constant bs_key          \ The decimal ASCII value for Backspace key
 21  constant ctrl_u          \ The decimal ASCII value for Ctrl-U sequence
@@ -126,6 +129,8 @@ variable readlen             \ input len
 	again \ Enter was not pressed; repeat
 ;
 
+only forth definitions also password-processing
+
 : check-password ( -- )
 
 	\ Do not allow the user to proceed beyond this point if a boot-lock
@@ -161,3 +166,5 @@ variable readlen             \ input len
 		3000 ms ." loader: incorrect password" 10 emit
 	again
 ;
+
+only forth definitions

Modified: head/sys/boot/forth/delay.4th
==============================================================================
--- head/sys/boot/forth/delay.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/delay.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2008-2011 Devin Teske <dteske@FreeBSD.org>
+\ Copyright (c) 2008-2015 Devin Teske <dteske@FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -26,6 +26,9 @@
 
 marker task-delay.4th
 
+vocabulary delay-processing
+only forth also delay-processing definitions
+
 2  constant delay_default \ Default delay (in seconds)
 3  constant etx_key       \ End-of-Text character produced by Ctrl+C
 13 constant enter_key     \ Carriage-Return character produce by ENTER
@@ -36,6 +39,8 @@ variable delay_delay      \ determined c
 variable delay_cancelled  \ state variable for user cancellation
 variable delay_showdots   \ whether continually print dots while waiting
 
+only forth definitions also delay-processing
+
 : delay_execute ( -- )
 
 	\ make sure that we have a command to execute
@@ -110,3 +115,5 @@ variable delay_showdots   \ whether cont
 		evaluate \ evaluate/execute the command string
  	then
 ;
+
+only forth definitions

Modified: head/sys/boot/forth/frames.4th
==============================================================================
--- head/sys/boot/forth/frames.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/frames.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -27,6 +27,9 @@
 
 marker task-frames.4th
 
+vocabulary frame-drawing
+only forth also frame-drawing definitions
+
 \ XXX Filled boxes are left as an exercise for the reader... ;-/
 
 variable h_el
@@ -87,6 +90,8 @@ s" arch-pc98" environment? [if]
 	178 constant fill_bright
 [then]
 
+only forth definitions also frame-drawing
+
 : hline	( len x y -- )	\ Draw horizontal single line
 	at-xy		\ move cursor
 	0 do
@@ -156,3 +161,5 @@ s" arch-pc98" environment? [if]
 
 f_single
 fill_none fill !
+
+only forth definitions

Modified: head/sys/boot/forth/loader.4th
==============================================================================
--- head/sys/boot/forth/loader.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/loader.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -25,6 +25,8 @@
 \
 \ $FreeBSD$
 
+only forth definitions
+
 s" arch-i386" environment? [if] [if]
 	s" loader_version" environment?  [if]
 		11 < [if]
@@ -45,7 +47,7 @@ include /boot/color.4th
 include /boot/delay.4th
 include /boot/check-password.4th
 
-only forth also support-functions also builtins definitions
+only forth definitions
 
 : bootmsg ( -- )
   loader_color? dup ( -- bool bool )
@@ -79,6 +81,8 @@ only forth also support-functions also b
   then
 ;
 
+only forth also support-functions also builtins definitions
+
 : boot
   0= if ( interpreted ) get_arguments then
 
@@ -122,7 +126,7 @@ only forth also support-functions also b
   ?dup 0= if 0 1 autoboot then
 ;
 
-also forth definitions also builtins
+also forth definitions previous
 
 builtin: boot
 builtin: boot-conf
@@ -245,5 +249,4 @@ only forth definitions also support-func
   then
 ; immediate \ interpret immediately for access to `source' (aka tib)
 
-only forth also
-
+only forth definitions

Modified: head/sys/boot/forth/menu-commands.4th
==============================================================================
--- head/sys/boot/forth/menu-commands.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/menu-commands.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2006-2013 Devin Teske <dteske@FreeBSD.org>
+\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -28,11 +28,15 @@ marker task-menu-commands.4th
 
 include /boot/menusets.4th
 
+only forth definitions
+
 variable kernel_state
 variable root_state
 0 kernel_state !
 0 root_state !
 
+also menu-namespace also menu-command-helpers
+
 \ 
 \ Boot
 \ 
@@ -346,3 +350,5 @@ variable root_state
 	verbose_disable
 	2 goto_menu
 ;
+
+only forth definitions

Modified: head/sys/boot/forth/menu.4th
==============================================================================
--- head/sys/boot/forth/menu.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/menu.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -31,6 +31,12 @@ marker task-menu.4th
 \ 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,19 +64,7 @@ variable menuX     \ Menu X offset (colu
 variable menuY     \ Menu Y offset (rows)
 
 \ Menu-item elements
-variable menukey1
-variable menukey2
-variable menukey3
-variable menukey4
-variable menukey5
-variable menukey6
-variable menukey7
-variable menukey8
-variable menureboot
 variable menurebootadded
-variable menuacpi
-variable menuoptions
-variable menukernel
 
 \ Parsing of kernels into menu-items
 variable kernidx
@@ -84,6 +78,27 @@ variable menu_timeout         \ determin
 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
+variable menukey3
+variable menukey4
+variable menukey5
+variable menukey6
+variable menukey7
+variable menukey8
+variable menureboot
+variable menuacpi
+variable menuoptions
+variable menukernel
+
 \ Menu initialization status variables
 variable init_state1
 variable init_state2
@@ -124,10 +139,34 @@ create init_text6 64 allot
 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 )
@@ -135,21 +174,15 @@ create kernelsbuf 256 allot
 	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
 
 \ Forth variables
-: 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 ;
+: 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! ;
@@ -163,11 +196,7 @@ create kernelsbuf 256 allot
 : 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
@@ -214,196 +243,6 @@ create kernelsbuf 256 allot
 	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.
@@ -434,6 +273,15 @@ create kernelsbuf 256 allot
 	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.
 \ Used internally by menu-create, you need not (nor should you) call this
@@ -959,6 +807,182 @@ create kernelsbuf 256 allot
 	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.
 \ 
@@ -1015,6 +1039,8 @@ create kernelsbuf 256 allot
 	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 ( -- )
@@ -1236,6 +1262,8 @@ create kernelsbuf 256 allot
 	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.
 \ 
@@ -1246,6 +1274,8 @@ create kernelsbuf 256 allot
 
 bullet menubllt !
 
+also menu-namespace
+
 \ Initialize our menu initialization state variables
 0 init_state1 !
 0 init_state2 !
@@ -1285,3 +1315,5 @@ bullet menubllt !
 0 init_text6 c!
 0 init_text7 c!
 0 init_text8 c!
+
+only forth definitions

Modified: head/sys/boot/forth/menusets.4th
==============================================================================
--- head/sys/boot/forth/menusets.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/menusets.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -26,6 +26,9 @@
 
 marker task-menusets.4th
 
+vocabulary menusets-infrastructure
+only forth also menusets-infrastructure definitions
+
 variable menuset_use_name
 
 create menuset_affixbuf	255 allot
@@ -437,6 +440,8 @@ create menuset_y        1   allot
 	s" affix" unsetenv
 ;
 
+only forth definitions also menusets-infrastructure
+
 : menuset-loadsetnum ( N -- )
 
 	menuset-checksetnum ( n -- )
@@ -537,16 +542,6 @@ create menuset_y        1   allot
 	menuset-cleanup
 ;
 
-: menuset-loadinitial ( -- )
-	s" menuset_initial" getenv dup -1 <> if
-		?number 0<> if
-			menuset-loadsetnum
-		then
-	else
-		drop \ cruft
-	then
-;
-
 : menusets-unset ( -- )
 
 	s" menuset_initial" unsetenv
@@ -615,3 +610,15 @@ create menuset_y        1   allot
 	s" buf" unsetenv
 	menuset-cleanup
 ;
+
+only forth definitions
+
+: menuset-loadinitial ( -- )
+	s" menuset_initial" getenv dup -1 <> if
+		?number 0<> if
+			menuset-loadsetnum
+		then
+	else
+		drop \ cruft
+	then
+;

Modified: head/sys/boot/forth/support.4th
==============================================================================
--- head/sys/boot/forth/support.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/support.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -315,7 +315,7 @@ string value_buffer
 \	reset_line_reading
 
 vocabulary line-reading
-also line-reading definitions also
+also line-reading definitions
 
 \ File data temporary storage
 
@@ -324,13 +324,13 @@ string read_buffer
 
 \ File's line reading function
 
-support-functions definitions
+get-current ( -- wid ) previous definitions
 
 string line_buffer
 0 value end_of_file?
 variable fd
 
-line-reading definitions
+>search ( wid -- ) definitions
 
 : skip_newlines
   begin
@@ -405,7 +405,7 @@ line-reading definitions
   read_buffer .len !
 ;
 
-support-functions definitions
+get-current ( -- wid ) previous definitions >search ( wid -- )
 
 : reset_line_reading
   0 to read_buffer_ptr
@@ -447,7 +447,7 @@ also file-processing definitions
 \	get_assignment
 
 vocabulary parser
-also parser definitions also
+also parser definitions
 
 0 value parsing_function
 0 value end_of_line
@@ -606,7 +606,7 @@ also parser definitions also
   end_of_line? 0= if ESYNTAX throw then
 ;
 
-file-processing definitions
+get-current ( -- wid ) previous definitions >search ( wid -- )
 
 : get_assignment
   line_buffer strget + to end_of_line
@@ -623,7 +623,7 @@ file-processing definitions
   or or 0= if ESYNTAX throw then
 ;
 
-only forth also support-functions also file-processing definitions also
+only forth also support-functions also file-processing definitions
 
 \ Process line
 
@@ -818,7 +818,7 @@ only forth also support-functions also f
 
 \ Higher level file processing
 
-support-functions definitions
+get-current ( -- wid ) previous definitions >search ( wid -- )
 
 : process_conf
   begin
@@ -1580,7 +1580,4 @@ also builtins
   then
 ;
 
-\ Go back to straight forth vocabulary
-
-only forth also definitions
-
+only forth definitions

Modified: head/sys/boot/forth/version.4th
==============================================================================
--- head/sys/boot/forth/version.4th	Wed Apr  1 01:25:58 2015	(r280936)
+++ head/sys/boot/forth/version.4th	Wed Apr  1 01:54:28 2015	(r280937)
@@ -26,6 +26,9 @@
 
 marker task-version.4th
 
+vocabulary version-processing
+only forth also version-processing definitions
+
 variable versionX
 variable versionY
 
@@ -36,6 +39,8 @@ variable versionY
 80 versionX !	\ NOTE: this is the ending column (text is right-justified)
 24 versionY !
 
+only forth definitions also version-processing
+
 : print_version ( -- )
 
 	\ Get the text placement position (if set)
@@ -86,3 +91,5 @@ variable versionY
 		type
 	then
 ;
+
+only forth definitions



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504010154.t311sTSf053084>