screenmap revision 251190
167754Smsmith#!/bin/sh
267754Smsmith#-
367754Smsmith# Copyright (c) 2012-2013 Devin Teske
4117521Snjl# All Rights Reserved.
567754Smsmith#
667754Smsmith# Redistribution and use in source and binary forms, with or without
767754Smsmith# modification, are permitted provided that the following conditions
867754Smsmith# are met:
967754Smsmith# 1. Redistributions of source code must retain the above copyright
1067754Smsmith#    notice, this list of conditions and the following disclaimer.
1167754Smsmith# 2. Redistributions in binary form must reproduce the above copyright
12114237Snjl#    notice, this list of conditions and the following disclaimer in the
1370243Smsmith#    documentation and/or other materials provided with the distribution.
1467754Smsmith#
1567754Smsmith# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1667754Smsmith# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
1767754Smsmith# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1867754Smsmith# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1967754Smsmith# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2067754Smsmith# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2167754Smsmith# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2267754Smsmith# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2367754Smsmith# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2467754Smsmith# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2567754Smsmith# SUCH DAMAGE.
2667754Smsmith#
2767754Smsmith# $FreeBSD: head/usr.sbin/bsdconfig/console/screenmap 251190 2013-05-31 19:07:17Z dteske $
2867754Smsmith#
2967754Smsmith############################################################ INCLUDES
3067754Smsmith
3167754SmsmithBSDCFG_SHARE="/usr/share/bsdconfig"
3267754Smsmith. $BSDCFG_SHARE/common.subr || exit 1
3367754Smsmithf_dprintf "%s: loading includes..." "$0"
3467754Smsmithf_include $BSDCFG_SHARE/dialog.subr
3567754Smsmithf_include $BSDCFG_SHARE/mustberoot.subr
3667754Smsmithf_include $BSDCFG_SHARE/sysrc.subr
3767754Smsmith
3867754SmsmithBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
3967754Smsmithf_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
4067754Smsmith
4167754Smsmithipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
4267754Smsmith[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
4367754Smsmith
4467754Smsmith############################################################ FUNCTIONS
4567754Smsmith
4667754Smsmith# dialog_menu_main
4767754Smsmith#
4867754Smsmith# Display the dialog(1)-based application main menu.
4967754Smsmith#
5067754Smsmithdialog_menu_main()
5167754Smsmith{
5267754Smsmith	local menu_list defaultitem=
5367754Smsmith	local hline="$hline_choose_a_screen_map"
5467754Smsmith	local prompt="$msg_screenmap_menu_text"
5567754Smsmith
5667754Smsmith	menu_list="
5767754Smsmith		'1 $msg_none'                 '$msg_none_screenmap_desc'
5867754Smsmith		'2 $msg_iso_8859_1_to_ibm437' '$msg_iso_8859_1_to_ibm437_desc'
5967754Smsmith		'3 $msg_iso_8859_7_to_ibm437' '$msg_iso_8859_7_to_ibm437_desc'
6067754Smsmith		'4 $msg_us_ascii_to_ibm327'   '$msg_us_ascii_to_ibm327_desc'
6167754Smsmith		'5 $msg_koi8_r_to_ibm866'     '$msg_koi8_r_to_ibm866_desc'
6267754Smsmith		'6 $msg_koi8_u_to_ibm866u'    '$msg_koi8_u_to_ibm866u_desc'
6367754Smsmith	" # END-QUOTE
6467754Smsmith
6567754Smsmith	local height width rows
6667754Smsmith	eval f_dialog_menu_size height width rows \
6767754Smsmith	                        \"\$DIALOG_TITLE\"     \
6867754Smsmith	                        \"\$DIALOG_BACKTITLE\" \
6967754Smsmith	                        \"\$prompt\"           \
7067754Smsmith	                        \"\$hline\"            \
7167754Smsmith	                        $menu_list
7267754Smsmith
7367754Smsmith	case "$( f_sysrc_get scrnmap )" in
7467754Smsmith	[Nn][Oo]|'')         defaultitem="1 $msg_none"                 ;;
7567754Smsmith	iso-8859-1_to_cp437) defaultitem="2 $msg_iso_8859_1_to_ibm437" ;;
7667754Smsmith	iso-8859-7_to_cp437) defaultitem="3 $msg_iso_8859_7_to_ibm437" ;;
7767754Smsmith	us-ascii_to_cp437)   defaultitem="4 $msg_us_ascii_to_ibm327"   ;;
7867754Smsmith	koi8-r2cp866)        defaultitem="5 $msg_koi8_r_to_ibm866"     ;;
7967754Smsmith	koi8-u2cp866u)       defaultitem="6 $msg_koi8_u_to_ibm866u"    ;;
8067754Smsmith	esac
8167754Smsmith
8267754Smsmith	local dialog_menu
8367754Smsmith	dialog_menu=$( eval $DIALOG \
8467754Smsmith		--title \"\$DIALOG_TITLE\"         \
8567754Smsmith		--backtitle \"\$DIALOG_BACKTITLE\" \
8667754Smsmith		--hline \"\$hline\"                \
8767754Smsmith		--ok-label \"\$msg_ok\"            \
8867754Smsmith		--cancel-label \"\$msg_cancel\"    \
8967754Smsmith		--default-item \"\$defaultitem\"   \
9067754Smsmith		--menu \"\$prompt\"                \
9167754Smsmith		$height $width $rows               \
9267754Smsmith		$menu_list                         \
9367754Smsmith		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
9467754Smsmith	)
9567754Smsmith	local retval=$?
9667754Smsmith	setvar DIALOG_MENU_$$ "$dialog_menu"
9767754Smsmith	return $retval
9867754Smsmith}
9967754Smsmith
10067754Smsmith############################################################ MAIN
10167754Smsmith
10267754Smsmith# Incorporate rc-file if it exists
10367754Smsmith[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
10467754Smsmith
10567754Smsmith#
10667754Smsmith# Process command-line arguments
10767754Smsmith#
10867754Smsmithwhile getopts h$GETOPTS_STDARGS flag; do
10967754Smsmith	case "$flag" in
11067754Smsmith	h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
11167754Smsmith	esac
11267754Smsmithdone
11367754Smsmithshift $(( $OPTIND - 1 ))
11467754Smsmith
11567754Smsmith#
11667754Smsmith# Initialize
11767754Smsmith#
11867754Smsmithf_dialog_title "$msg_system_console_screenmap"
11967754Smsmithf_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
12067754Smsmithf_mustberoot_init
12167754Smsmith
12267754Smsmith#
123117521Snjl# Launch application main menu
12467754Smsmith#
12567754Smsmithwhile :; do
12667754Smsmith	dialog_menu_main
12767754Smsmith	retval=$?
128102550Siwasaki	mtag=$( f_dialog_menutag )
12991116Smsmith
13091116Smsmith	[ $retval -eq 0 ] || f_die
13187031Smsmith
13267754Smsmith	case "$mtag" in
13367754Smsmith	"1 $msg_none") # No screenmap, don't touch font
13487031Smsmith		f_sysrc_set scrnmap "NO" || f_die
13567754Smsmith		break ;;
13667754Smsmith	"2 $msg_iso_8859_1_to_ibm437") # W-Europe ISO 8859-1 to IBM 437 scrnmap
13767754Smsmith		f_sysrc_set scrnmap "iso-8859-1_to_cp437" || f_die
138117521Snjl		break ;;
13967754Smsmith	"3 $msg_iso_8859_7_to_ibm437") # Greek ISO 8859-7 to IBM 437 screenmap
140117521Snjl		f_sysrc_set scrnmap "iso-8859-7_to_cp437" || f_die
141117521Snjl		break ;;
142117521Snjl	"4 $msg_us_ascii_to_ibm327") # US-ASCII to IBM 437 screenmap
143117521Snjl		f_sysrc_set scrnmap "us-ascii_to_cp437" || f_die
144117521Snjl		break ;;
145117521Snjl	"5 $msg_koi8_r_to_ibm866") # Russian KOI8-R to IBM 866 screenmap
146117521Snjl		f_sysrc_set scrnmap "koi8-r2cp866" || f_die
147117521Snjl		break ;;
148117521Snjl	"6 $msg_koi8_u_to_ibm866u") # Ukrainian KOI8-U to IBM 866u screenmap
149117521Snjl		f_sysrc_set scrnmap "koi8-u2cp866u" || f_die
150117521Snjl		break ;;
151117521Snjl	esac
152117521Snjl
153117521Snjldone
154117521Snjl
155117521Snjlexit $SUCCESS
156117521Snjl
15767754Smsmith################################################################################
15867754Smsmith# END
15967754Smsmith################################################################################
16067754Smsmith