1#!/bin/sh 2#- 3# Copyright (c) 2012-2013 Devin Teske 4# All Rights Reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 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. 14# 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 (INLUDING, 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 25# SUCH DAMAGE. 26#
| 1#!/bin/sh 2#- 3# Copyright (c) 2012-2013 Devin Teske 4# All Rights Reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 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. 14# 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 (INLUDING, 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 25# SUCH DAMAGE. 26#
|
27# $FreeBSD: head/usr.sbin/bsdconfig/console/font 251236 2013-06-01 23:58:44Z dteske $
| 27# $FreeBSD: head/usr.sbin/bsdconfig/console/font 251264 2013-06-02 20:02:50Z dteske $
|
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/mustberoot.subr 36f_include $BSDCFG_SHARE/sysrc.subr 37 38BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console" 39f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40 41ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 42[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" 43 44############################################################ FUNCTIONS 45 46# dialog_menu_main 47# 48# Display the dialog(1)-based application main menu. 49# 50dialog_menu_main() 51{
| 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/mustberoot.subr 36f_include $BSDCFG_SHARE/sysrc.subr 37 38BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console" 39f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40 41ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 42[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" 43 44############################################################ FUNCTIONS 45 46# dialog_menu_main 47# 48# Display the dialog(1)-based application main menu. 49# 50dialog_menu_main() 51{
|
52 local menu_list defaultitem= 53 local hline="$hline_choose_a_font"
| |
54 local prompt="$msg_font_menu_text"
| 52 local prompt="$msg_font_menu_text"
|
55 56 menu_list="
| 53 local menu_list="
|
57 '1 $msg_none' '$msg_use_hardware_default_font' 58 '2 $msg_ibm_437' '$msg_ibm_437_desc' 59 '3 $msg_ibm_850' '$msg_ibm_850_desc' 60 '4 $msg_ibm_865' '$msg_ibm_865_desc' 61 '5 $msg_ibm_866' '$msg_ibm_866_desc' 62 '6 $msg_ibm_866u' '$msg_ibm_866u_desc' 63 '7 $msg_ibm_1251' '$msg_ibm_1251_desc' 64 '8 $msg_iso_8859_1' '$msg_iso_8859_1_desc' 65 '9 $msg_iso_8859_2' '$msg_iso_8859_2_desc' 66 'a $msg_iso_8859_4' '$msg_iso_8859_4_desc' 67 'b $msg_iso_8859_7' '$msg_iso_8859_7_desc' 68 'c $msg_iso_8859_8' '$msg_iso_8859_8_desc' 69 'd $msg_iso_8859_15' '$msg_iso_8859_15_desc' 70 'e $msg_swiss' '$msg_swiss_desc' 71 " # END-QUOTE
| 54 '1 $msg_none' '$msg_use_hardware_default_font' 55 '2 $msg_ibm_437' '$msg_ibm_437_desc' 56 '3 $msg_ibm_850' '$msg_ibm_850_desc' 57 '4 $msg_ibm_865' '$msg_ibm_865_desc' 58 '5 $msg_ibm_866' '$msg_ibm_866_desc' 59 '6 $msg_ibm_866u' '$msg_ibm_866u_desc' 60 '7 $msg_ibm_1251' '$msg_ibm_1251_desc' 61 '8 $msg_iso_8859_1' '$msg_iso_8859_1_desc' 62 '9 $msg_iso_8859_2' '$msg_iso_8859_2_desc' 63 'a $msg_iso_8859_4' '$msg_iso_8859_4_desc' 64 'b $msg_iso_8859_7' '$msg_iso_8859_7_desc' 65 'c $msg_iso_8859_8' '$msg_iso_8859_8_desc' 66 'd $msg_iso_8859_15' '$msg_iso_8859_15_desc' 67 'e $msg_swiss' '$msg_swiss_desc' 68 " # END-QUOTE
|
| 69 local defaultitem= # Calculated below 70 local hline="$hline_choose_a_font"
|
72 73 local height width rows 74 eval f_dialog_menu_size height width rows \ 75 \"\$DIALOG_TITLE\" \ 76 \"\$DIALOG_BACKTITLE\" \ 77 \"\$prompt\" \ 78 \"\$hline\" \ 79 $menu_list 80 81 case "$( f_sysrc_get font8x8 )" in 82 [Nn][Oo]|'') defaultitem="1 $msg_none";; 83 cp437-8x8) defaultitem="2 $msg_ibm_437";; 84 cp850-8x8) defaultitem="3 $msg_ibm_850";; 85 cp865-8x8) defaultitem="4 $msg_ibm_865";; 86 cp866-8x8) defaultitem="5 $msg_ibm_866";; 87 cp866u-8x8) defaultitem="6 $msg_ibm_866u";; 88 cp1251-8x8) defaultitem="7 $msg_ibm_1251";; 89 iso-8x8) defaultitem="8 $msg_iso_8859_1";; 90 iso02-8x8) defaultitem="9 $msg_iso_8859_2";; 91 iso04-8x8) defaultitem="a $msg_iso_8859_4";; 92 iso07-8x8) defaultitem="b $msg_iso_8859_7";; 93 iso08-8x8) defaultitem="c $msg_iso_8859_8";; 94 iso15-8x8) defaultitem="d $msg_iso_8859_15";; 95 swiss-8x8) defaultitem="e $msg_swiss";; 96 esac 97 98 local menu_choice 99 menu_choice=$( eval $DIALOG \ 100 --title \"\$DIALOG_TITLE\" \ 101 --backtitle \"\$DIALOG_BACKTITLE\" \ 102 --hline \"\$hline\" \ 103 --ok-label \"\$msg_ok\" \ 104 --cancel-label \"\$msg_cancel\" \ 105 --default-item \"\$defaultitem\" \ 106 --menu \"\$prompt\" \ 107 $height $width $rows \ 108 $menu_list \ 109 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 110 ) 111 local retval=$? 112 f_dialog_menutag_store -s "$menu_choice" 113 return $retval 114} 115 116############################################################ MAIN 117 118# Incorporate rc-file if it exists 119[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 120 121# 122# Process command-line arguments 123# 124while getopts h$GETOPTS_STDARGS flag; do 125 case "$flag" in 126 h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";; 127 esac 128done 129shift $(( $OPTIND - 1 )) 130 131# 132# Initialize 133# 134f_dialog_title "$msg_system_console_font" 135f_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 136f_mustberoot_init 137 138# 139# Launch application main menu 140# 141while :; do 142 dialog_menu_main || f_die 143 f_dialog_menutag_fetch mtag 144 145 case "$mtag" in 146 "1 $msg_none") # Use hardware default font 147 f_sysrc_set font8x8 "NO" || f_die 148 f_sysrc_set font8x14 "NO" || f_die 149 f_sysrc_set font8x16 "NO" || f_die 150 break ;; 151 "2 $msg_ibm_437") # English and others, VGA default 152 f_sysrc_set font8x8 "cp437-8x8" || f_die 153 f_sysrc_set font8x14 "cp437-8x14" || f_die 154 f_sysrc_set font8x16 "cp437-8x16" || f_die 155 break ;; 156 "3 $msg_ibm_850") # Western Europe, IBM encoding 157 f_sysrc_set font8x8 "cp850-8x8" || f_die 158 f_sysrc_set font8x14 "cp850-8x14" || f_die 159 f_sysrc_set font8x16 "cp850-8x16" || f_die 160 break ;; 161 "4 $msg_ibm_865") # Norwegian, IBM encoding 162 f_sysrc_set font8x8 "cp865-8x8" || f_die 163 f_sysrc_set font8x14 "cp865-8x14" || f_die 164 f_sysrc_set font8x16 "cp865-8x16" || f_die 165 break ;; 166 "5 $msg_ibm_866") # Russian, IBM encoding (use with KOI8-R screenmap) 167 f_sysrc_set font8x8 "cp866-8x8" || f_die 168 f_sysrc_set font8x14 "cp866-8x14" || f_die 169 f_sysrc_set font8x16 "cp866b-8x16" || f_die 170 f_sysrc_set mousechar_start 3 || f_die 171 break ;; 172 "6 $msg_ibm_866u") # Ukrainian, IBM encoding (use w/ KOI8-U screenmap) 173 f_sysrc_set font8x8 "cp866u-8x8" || f_die 174 f_sysrc_set font8x14 "cp866u-8x14" || f_die 175 f_sysrc_set font8x16 "cp866u-8x16" || f_die 176 f_sysrc_set mousechar_start 3 || f_die 177 break ;; 178 "7 $msg_ibm_1251") # Cyrillic, MS Windows encoding 179 f_sysrc_set font8x8 "cp1251-8x8" || f_die 180 f_sysrc_set font8x14 "cp1251-8x14" || f_die 181 f_sysrc_set font8x16 "cp1251-8x16" || f_die 182 f_sysrc_set mousechar_start 3 || f_die 183 break ;; 184 "8 $msg_iso_8859_1") # Western Europe, ISO encoding 185 f_sysrc_set font8x8 "iso-8x8" || f_die 186 f_sysrc_set font8x14 "iso-8x14" || f_die 187 f_sysrc_set font8x16 "iso-8x16" || f_die 188 break ;; 189 "9 $msg_iso_8859_2") # Eastern Europe, ISO encoding 190 f_sysrc_set font8x8 "iso02-8x8" || f_die 191 f_sysrc_set font8x14 "iso02-8x14" || f_die 192 f_sysrc_set font8x16 "iso02-8x16" || f_die 193 break ;; 194 "a $msg_iso_8859_4") # Baltic, ISO encoding 195 f_sysrc_set font8x8 "iso04-8x8" || f_die 196 f_sysrc_set font8x14 "iso04-8x14" || f_die 197 f_sysrc_set font8x16 "iso04-8x16" || f_die 198 break ;; 199 "b $msg_iso_8859_7") # Greek, ISO encoding 200 f_sysrc_set font8x8 "iso07-8x8" || f_die 201 f_sysrc_set font8x14 "iso07-8x14" || f_die 202 f_sysrc_set font8x16 "iso07-8x16" || f_die 203 break ;; 204 "c $msg_iso_8859_8") # Hebrew, ISO encoding 205 f_sysrc_set font8x8 "iso08-8x8" || f_die 206 f_sysrc_set font8x14 "iso08-8x14" || f_die 207 f_sysrc_set font8x16 "iso08-8x16" || f_die 208 break ;; 209 "d $msg_iso_8859_15") # Europe, ISO encoding 210 f_sysrc_set font8x8 "iso15-8x8" || f_die 211 f_sysrc_set font8x14 "iso15-8x14" || f_die 212 f_sysrc_set font8x16 "iso15-8x16" || f_die 213 break ;; 214 "e $msg_swiss") # English, better resolution 215 f_sysrc_set font8x8 "swiss-8x8" || f_die 216 f_sysrc_set font8x14 "NO" || f_die 217 f_sysrc_set font8x16 "swiss-8x16" || f_die 218 break ;; 219 esac 220 221done 222 223exit $SUCCESS 224 225################################################################################ 226# END 227################################################################################
| 71 72 local height width rows 73 eval f_dialog_menu_size height width rows \ 74 \"\$DIALOG_TITLE\" \ 75 \"\$DIALOG_BACKTITLE\" \ 76 \"\$prompt\" \ 77 \"\$hline\" \ 78 $menu_list 79 80 case "$( f_sysrc_get font8x8 )" in 81 [Nn][Oo]|'') defaultitem="1 $msg_none";; 82 cp437-8x8) defaultitem="2 $msg_ibm_437";; 83 cp850-8x8) defaultitem="3 $msg_ibm_850";; 84 cp865-8x8) defaultitem="4 $msg_ibm_865";; 85 cp866-8x8) defaultitem="5 $msg_ibm_866";; 86 cp866u-8x8) defaultitem="6 $msg_ibm_866u";; 87 cp1251-8x8) defaultitem="7 $msg_ibm_1251";; 88 iso-8x8) defaultitem="8 $msg_iso_8859_1";; 89 iso02-8x8) defaultitem="9 $msg_iso_8859_2";; 90 iso04-8x8) defaultitem="a $msg_iso_8859_4";; 91 iso07-8x8) defaultitem="b $msg_iso_8859_7";; 92 iso08-8x8) defaultitem="c $msg_iso_8859_8";; 93 iso15-8x8) defaultitem="d $msg_iso_8859_15";; 94 swiss-8x8) defaultitem="e $msg_swiss";; 95 esac 96 97 local menu_choice 98 menu_choice=$( eval $DIALOG \ 99 --title \"\$DIALOG_TITLE\" \ 100 --backtitle \"\$DIALOG_BACKTITLE\" \ 101 --hline \"\$hline\" \ 102 --ok-label \"\$msg_ok\" \ 103 --cancel-label \"\$msg_cancel\" \ 104 --default-item \"\$defaultitem\" \ 105 --menu \"\$prompt\" \ 106 $height $width $rows \ 107 $menu_list \ 108 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 109 ) 110 local retval=$? 111 f_dialog_menutag_store -s "$menu_choice" 112 return $retval 113} 114 115############################################################ MAIN 116 117# Incorporate rc-file if it exists 118[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 119 120# 121# Process command-line arguments 122# 123while getopts h$GETOPTS_STDARGS flag; do 124 case "$flag" in 125 h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";; 126 esac 127done 128shift $(( $OPTIND - 1 )) 129 130# 131# Initialize 132# 133f_dialog_title "$msg_system_console_font" 134f_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 135f_mustberoot_init 136 137# 138# Launch application main menu 139# 140while :; do 141 dialog_menu_main || f_die 142 f_dialog_menutag_fetch mtag 143 144 case "$mtag" in 145 "1 $msg_none") # Use hardware default font 146 f_sysrc_set font8x8 "NO" || f_die 147 f_sysrc_set font8x14 "NO" || f_die 148 f_sysrc_set font8x16 "NO" || f_die 149 break ;; 150 "2 $msg_ibm_437") # English and others, VGA default 151 f_sysrc_set font8x8 "cp437-8x8" || f_die 152 f_sysrc_set font8x14 "cp437-8x14" || f_die 153 f_sysrc_set font8x16 "cp437-8x16" || f_die 154 break ;; 155 "3 $msg_ibm_850") # Western Europe, IBM encoding 156 f_sysrc_set font8x8 "cp850-8x8" || f_die 157 f_sysrc_set font8x14 "cp850-8x14" || f_die 158 f_sysrc_set font8x16 "cp850-8x16" || f_die 159 break ;; 160 "4 $msg_ibm_865") # Norwegian, IBM encoding 161 f_sysrc_set font8x8 "cp865-8x8" || f_die 162 f_sysrc_set font8x14 "cp865-8x14" || f_die 163 f_sysrc_set font8x16 "cp865-8x16" || f_die 164 break ;; 165 "5 $msg_ibm_866") # Russian, IBM encoding (use with KOI8-R screenmap) 166 f_sysrc_set font8x8 "cp866-8x8" || f_die 167 f_sysrc_set font8x14 "cp866-8x14" || f_die 168 f_sysrc_set font8x16 "cp866b-8x16" || f_die 169 f_sysrc_set mousechar_start 3 || f_die 170 break ;; 171 "6 $msg_ibm_866u") # Ukrainian, IBM encoding (use w/ KOI8-U screenmap) 172 f_sysrc_set font8x8 "cp866u-8x8" || f_die 173 f_sysrc_set font8x14 "cp866u-8x14" || f_die 174 f_sysrc_set font8x16 "cp866u-8x16" || f_die 175 f_sysrc_set mousechar_start 3 || f_die 176 break ;; 177 "7 $msg_ibm_1251") # Cyrillic, MS Windows encoding 178 f_sysrc_set font8x8 "cp1251-8x8" || f_die 179 f_sysrc_set font8x14 "cp1251-8x14" || f_die 180 f_sysrc_set font8x16 "cp1251-8x16" || f_die 181 f_sysrc_set mousechar_start 3 || f_die 182 break ;; 183 "8 $msg_iso_8859_1") # Western Europe, ISO encoding 184 f_sysrc_set font8x8 "iso-8x8" || f_die 185 f_sysrc_set font8x14 "iso-8x14" || f_die 186 f_sysrc_set font8x16 "iso-8x16" || f_die 187 break ;; 188 "9 $msg_iso_8859_2") # Eastern Europe, ISO encoding 189 f_sysrc_set font8x8 "iso02-8x8" || f_die 190 f_sysrc_set font8x14 "iso02-8x14" || f_die 191 f_sysrc_set font8x16 "iso02-8x16" || f_die 192 break ;; 193 "a $msg_iso_8859_4") # Baltic, ISO encoding 194 f_sysrc_set font8x8 "iso04-8x8" || f_die 195 f_sysrc_set font8x14 "iso04-8x14" || f_die 196 f_sysrc_set font8x16 "iso04-8x16" || f_die 197 break ;; 198 "b $msg_iso_8859_7") # Greek, ISO encoding 199 f_sysrc_set font8x8 "iso07-8x8" || f_die 200 f_sysrc_set font8x14 "iso07-8x14" || f_die 201 f_sysrc_set font8x16 "iso07-8x16" || f_die 202 break ;; 203 "c $msg_iso_8859_8") # Hebrew, ISO encoding 204 f_sysrc_set font8x8 "iso08-8x8" || f_die 205 f_sysrc_set font8x14 "iso08-8x14" || f_die 206 f_sysrc_set font8x16 "iso08-8x16" || f_die 207 break ;; 208 "d $msg_iso_8859_15") # Europe, ISO encoding 209 f_sysrc_set font8x8 "iso15-8x8" || f_die 210 f_sysrc_set font8x14 "iso15-8x14" || f_die 211 f_sysrc_set font8x16 "iso15-8x16" || f_die 212 break ;; 213 "e $msg_swiss") # English, better resolution 214 f_sysrc_set font8x8 "swiss-8x8" || f_die 215 f_sysrc_set font8x14 "NO" || f_die 216 f_sysrc_set font8x16 "swiss-8x16" || f_die 217 break ;; 218 esac 219 220done 221 222exit $SUCCESS 223 224################################################################################ 225# END 226################################################################################
|