3 # Copyright (c) 2012-2013 Devin Teske
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 ############################################################ INCLUDES
30 BSDCFG_SHARE="/usr/share/bsdconfig"
31 . $BSDCFG_SHARE/common.subr || exit 1
32 f_dprintf "%s: loading includes..." "$0"
33 f_include $BSDCFG_SHARE/dialog.subr
34 f_include $BSDCFG_SHARE/mustberoot.subr
35 f_include $BSDCFG_SHARE/sysrc.subr
37 BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
38 f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
40 f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
43 ############################################################ FUNCTIONS
47 # Display the dialog(1)-based application main menu.
51 local prompt="$msg_font_menu_text"
53 '1 $msg_none' '$msg_use_hardware_default_font'
54 '2 $msg_ibm_437' '$msg_ibm_437_desc'
55 '3 $msg_ibm_850' '$msg_ibm_850_desc'
56 '4 $msg_ibm_865' '$msg_ibm_865_desc'
57 '5 $msg_ibm_866' '$msg_ibm_866_desc'
58 '6 $msg_ibm_866u' '$msg_ibm_866u_desc'
59 '7 $msg_ibm_1251' '$msg_ibm_1251_desc'
60 '8 $msg_iso_8859_1' '$msg_iso_8859_1_desc'
61 '9 $msg_iso_8859_2' '$msg_iso_8859_2_desc'
62 'a $msg_iso_8859_4' '$msg_iso_8859_4_desc'
63 'b $msg_iso_8859_7' '$msg_iso_8859_7_desc'
64 'c $msg_iso_8859_8' '$msg_iso_8859_8_desc'
65 'd $msg_iso_8859_15' '$msg_iso_8859_15_desc'
66 'e $msg_swiss' '$msg_swiss_desc'
68 local defaultitem= # Calculated below
69 local hline="$hline_choose_a_font"
71 local height width rows
72 eval f_dialog_menu_size height width rows \
74 \"\$DIALOG_BACKTITLE\" \
79 case "$( f_sysrc_get font8x8 )" in
80 [Nn][Oo]|'') defaultitem="1 $msg_none" ;;
81 cp437-8x8) defaultitem="2 $msg_ibm_437" ;;
82 cp850-8x8) defaultitem="3 $msg_ibm_850" ;;
83 cp865-8x8) defaultitem="4 $msg_ibm_865" ;;
84 cp866-8x8) defaultitem="5 $msg_ibm_866" ;;
85 cp866u-8x8) defaultitem="6 $msg_ibm_866u" ;;
86 cp1251-8x8) defaultitem="7 $msg_ibm_1251" ;;
87 iso-8x8) defaultitem="8 $msg_iso_8859_1" ;;
88 iso02-8x8) defaultitem="9 $msg_iso_8859_2" ;;
89 iso04-8x8) defaultitem="a $msg_iso_8859_4" ;;
90 iso07-8x8) defaultitem="b $msg_iso_8859_7" ;;
91 iso08-8x8) defaultitem="c $msg_iso_8859_8" ;;
92 iso15-8x8) defaultitem="d $msg_iso_8859_15" ;;
93 swiss-8x8) defaultitem="e $msg_swiss" ;;
97 menu_choice=$( eval $DIALOG \
98 --title \"\$DIALOG_TITLE\" \
99 --backtitle \"\$DIALOG_BACKTITLE\" \
100 --hline \"\$hline\" \
101 --ok-label \"\$msg_ok\" \
102 --cancel-label \"\$msg_cancel\" \
103 --default-item \"\$defaultitem\" \
104 --menu \"\$prompt\" \
105 $height $width $rows \
107 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
110 f_dialog_menutag_store -s "$menu_choice"
114 ############################################################ MAIN
116 # Incorporate rc-file if it exists
117 [ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
120 # Process command-line arguments
122 while getopts h$GETOPTS_STDARGS flag; do
124 h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
127 shift $(( $OPTIND - 1 ))
132 f_dialog_title "$msg_system_console_font"
133 f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
137 # Launch application main menu
139 dialog_menu_main || f_die
140 f_dialog_menutag_fetch mtag
142 f8= f14= f16= mc_start=
144 "1 $msg_none") # Use hardware default font
145 f8="NO" f14="NO" f16="NO" ;;
146 "2 $msg_ibm_437") # English and others, VGA default
147 f8="cp437-8x8" f14="cp437-8x14" f16="cp437-8x16" ;;
148 "3 $msg_ibm_850") # Western Europe, IBM encoding
149 f8="cp850-8x8" f14="cp850-8x14" f16="cp850-8x16" ;;
150 "4 $msg_ibm_865") # Norwegian, IBM encoding
151 f8="cp865-8x8" f14="cp865-8x14" f16="cp865-8x16" ;;
152 "5 $msg_ibm_866") # Russian, IBM encoding (use with KOI8-R screenmap)
153 f8="cp866-8x8" f14="cp866-8x14" f16="cp866b-8x16" mc_start="3" ;;
154 "6 $msg_ibm_866u") # Ukrainian, IBM encoding (use w/ KOI8-U screenmap)
155 f8="cp866u-8x8" f14="cp866u-8x14" f16="cp866u-8x16" mc_start="3" ;;
156 "7 $msg_ibm_1251") # Cyrillic, MS Windows encoding
157 f8="cp1251-8x8" f14="cp1251-8x14" f16="cp1251-8x16" mc_start="3" ;;
158 "8 $msg_iso_8859_1") # Western Europe, ISO encoding
159 f8="iso-8x8" f14="iso-8x14" f16="iso-8x16" ;;
160 "9 $msg_iso_8859_2") # Eastern Europe, ISO encoding
161 f8="iso02-8x8" f14="iso02-8x14" f16="iso02-8x16" ;;
162 "a $msg_iso_8859_4") # Baltic, ISO encoding
163 f8="iso04-8x8" f14="iso04-8x14" f16="iso04-8x16" ;;
164 "b $msg_iso_8859_7") # Greek, ISO encoding
165 f8="iso07-8x8" f14="iso07-8x14" f16="iso07-8x16" ;;
166 "c $msg_iso_8859_8") # Hebrew, ISO encoding
167 f8="iso08-8x8" f14="iso08-8x14" f16="iso08-8x16" ;;
168 "d $msg_iso_8859_15") # Europe, ISO encoding
169 f8="iso15-8x8" f14="iso15-8x14" f16="iso15-8x16" ;;
170 "e $msg_swiss") # English, better resolution
171 f8="swiss-8x8" f14="NO" f16="swiss-8x16" ;;
174 [ "$f8" -a "$f14" -a "$f16" ] || f_die 1 "$msg_unknown_font_selection"
176 f_eval_catch "$0" f_sysrc_set 'f_sysrc_set font8x8 "%s"' "$f8" || f_die
177 f_eval_catch "$0" f_sysrc_set 'f_sysrc_set font8x14 "%s"' "$f14" || f_die
178 f_eval_catch "$0" f_sysrc_set 'f_sysrc_set font8x16 "%s"' "$f16" || f_die
180 if [ "$mc_start" ]; then
181 f_eval_catch "$0" f_sysrc_set \
182 'f_sysrc_set mousechar_start "%s"' "$mc_start" || f_die
184 f_eval_catch "$0" f_sysrc_delete \
185 'f_sysrc_delete mousechar_start' || f_die
190 ################################################################################
192 ################################################################################