More-accurately replicate the help system from sysinstall(8). However, also

improve upon the system by giving the user a "Help" button instead of requiring
the user to press F1.

NOTE: In FreeBSD-9 and higher, dialog(1) does not support the F1 hook, so the
      mechanism for providing help to the user had to be changed to a button.

This now means we can resurrect *.hlp files from usr.sbin/sysinstall/help/ as-
is and reusing them as-needed in bsdconfig (holding to the goal of losing as
little functionality from sysinstall as possible).

Reviewed by:	adrian (co-mentor)
Approved by:	adrian (co-mentor)
This commit is contained in:
Devin Teske 2012-10-18 18:43:54 +00:00
parent 7fba6f489e
commit 6e0adcda1f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241701
5 changed files with 61 additions and 5 deletions

View File

@ -37,6 +37,7 @@ f_include $BSDCFG_SHARE/strings.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig"
f_include_lang $BSDCFG_LIBE/include/messages.subr
f_include_help $BSDCFG_LIBE/include/bsdconfig.hlp
############################################################ FUNCTIONS
@ -185,6 +186,8 @@ dialog_menu_main()
--item-help \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_exit_bsdconfig\" \
--help-button \
${USE_XDIALOG:+--help \"\$( f_include_help )\"} \
--menu \"\$prompt\" $size $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
@ -286,8 +289,6 @@ if [ "$1" ]; then
exec $cmd ${USE_XDIALOG:+-X} "$@" || exit 1
fi
[ -f "$HOME/.bsdconfigrc" ] || f_dialog_msgbox "$msg_help_text"
#
# Launch application main menu
#
@ -297,7 +298,13 @@ while :; do
mtag=$( f_dialog_menutag )
f_dprintf "retval=$retval mtag=[$mtag]"
[ $retval -eq 0 ] || f_die
if [ $retval -eq 2 ]; then
# The Help button was pressed
f_show_msg "%s" "$( f_include_help )"
continue
elif [ $retval -ne 0 ]; then
f_die
fi
case "$mtag" in
X) # Exit

View File

@ -3,7 +3,7 @@
NO_OBJ=
FILESDIR= ${LIBEXECDIR}/bsdconfig/include
FILES= messages.subr
FILES= bsdconfig.hlp messages.subr
beforeinstall:
mkdir -p ${DESTDIR}${FILESDIR}

View File

@ -0,0 +1,12 @@
This menu allows you to configure your system after the installation
process is complete. At the minimum, you should probably set the root
password and the system time zone.
For extra goodies like bash, emacs, firefox, etc., you should look at
the Packages item in this menu.
For setting the timezone after the system is installed, use the 'Time
Zone' item in this menu.
For more information on the overall general system configuration, see
the /etc/rc.conf and /etc/defaults/rc.conf files.

View File

@ -38,7 +38,6 @@ msg_created_path="Created %s"
msg_directory_not_found="%s: Directory not found."
msg_exit="Exit"
msg_exit_bsdconfig="Exit bsdconfig"
msg_help_text="This menu allows you to configure your system after the installation\nprocess is complete. At the minimum, you should probably set the root\npassword and the system time zone.\n\nFor extra goodies like bash, emacs, firefox, etc., you should look at the\n'Packages' item in this menu.\n\nFor setting the timezone after the system is installed, use the 'Time\nZone' item in this menu.\n\nFor more information on the overall general system configuration, see the\n/etc/rc.conf and /etc/defaults/rc.conf files. (Note: to inhibit displaying\nof this message, create an empty file: \$HOME/.bsdconfigrc or copy it from\n/usr/share/examples/bsdconfig/bsdconfigrc)"
msg_main_menu="Main Menu"
msg_menu_text="If you've already installed FreeBSD, you may use\nthis menu to customize it somewhat to suit your\nparticular configuration. Most importantly, you\ncan use the Packages utility to load extra '3rd\nparty' software not provided in the base\ndistributions."
msg_must_be_root_to_execute="%s: must be root to execute"

View File

@ -179,6 +179,44 @@ f_include_lang()
fi
}
# f_include_help [$file]
#
# When given an argument, cache the contents of a language help-file (to later
# be retrieved by executing again without arguments).
#
# Automatically takes $LANG and $LC_ALL into consideration when reading $file
# (suffix ".$LC_ALL" or ".$LANG" will automatically be added prior to loading
# the language help-file).
#
# No error is produced if (a) a language has been requested (by setting either
# $LANG or $LC_ALL in the environment) and (b) the language help-file does not
# exist -- in which case we will fall back to loading $file without-suffix.
#
# If the language help-file does not exist, an error is cached in place of the
# help-file contents.
#
# When called without arguments, the cached value (if any) is produced. Each
# time this function is called, the cache is overwritten with the newly loaded
# contents.
#
f_include_help()
{
local file="$1"
if [ "$file" ]; then
local lang="${LANG:-$LC_ALL}"
f_dprintf "lang=[$lang]"
if [ -f "$file.$lang" ]; then
setvar HELP_$$ "$( cat "$file.$lang" 2>&1 )"
else
setvar HELP_$$ "$( cat "$file" 2>&1 )"
fi
else
eval echo \"\$HELP_$$\"
fi
}
# f_usage $file [ $key1 $value1 ... ]
#
# Display USAGE file with optional pre-processor macro definitions. The first