screenmap revision 249746
1238438Sdteske#!/bin/sh
2238438Sdteske#-
3249746Sdteske# Copyright (c) 2012-2013 Devin Teske
4238438Sdteske# All Rights Reserved.
5238438Sdteske#
6238438Sdteske# Redistribution and use in source and binary forms, with or without
7238438Sdteske# modification, are permitted provided that the following conditions
8238438Sdteske# are met:
9238438Sdteske# 1. Redistributions of source code must retain the above copyright
10238438Sdteske#    notice, this list of conditions and the following disclaimer.
11238438Sdteske# 2. Redistributions in binary form must reproduce the above copyright
12238438Sdteske#    notice, this list of conditions and the following disclaimer in the
13238438Sdteske#    documentation and/or other materials provided with the distribution.
14238438Sdteske#
15238438Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16238438Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
17238438Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18238438Sdteske# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19238438Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20238438Sdteske# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21238438Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22238438Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23238438Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24238438Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25238438Sdteske# SUCH DAMAGE.
26238438Sdteske#
27238438Sdteske# $FreeBSD: head/usr.sbin/bsdconfig/console/screenmap 249746 2013-04-22 05:02:34Z dteske $
28238438Sdteske#
29238438Sdteske############################################################ INCLUDES
30238438Sdteske
31240684SdteskeBSDCFG_SHARE="/usr/share/bsdconfig"
32240684Sdteske. $BSDCFG_SHARE/common.subr || exit 1
33244675Sdteskef_dprintf "%s: loading includes..." "$0"
34240684Sdteskef_include $BSDCFG_SHARE/dialog.subr
35240684Sdteskef_include $BSDCFG_SHARE/mustberoot.subr
36240684Sdteskef_include $BSDCFG_SHARE/sysrc.subr
37238438Sdteske
38240684SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
39238438Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
40238438Sdteske
41243112Sdteskeipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
42238438Sdteske[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
43238438Sdteske
44238438Sdteske############################################################ FUNCTIONS
45238438Sdteske
46238438Sdteske# dialog_menu_main
47238438Sdteske#
48238438Sdteske# Display the dialog(1)-based application main menu.
49238438Sdteske#
50238438Sdteskedialog_menu_main()
51238438Sdteske{
52238438Sdteske	local menu_list size
53238438Sdteske	local hline="$hline_choose_a_screen_map"
54238438Sdteske	local prompt="$msg_screenmap_menu_text"
55238438Sdteske
56238438Sdteske	menu_list="
57238438Sdteske		'1 $msg_none'                 '$msg_none_screenmap_desc'
58238438Sdteske		'2 $msg_iso_8859_1_to_ibm437' '$msg_iso_8859_1_to_ibm437_desc'
59238438Sdteske		'3 $msg_iso_8859_7_to_ibm437' '$msg_iso_8859_7_to_ibm437_desc'
60238438Sdteske		'4 $msg_us_ascii_to_ibm327'   '$msg_us_ascii_to_ibm327_desc'
61238438Sdteske		'5 $msg_koi8_r_to_ibm866'     '$msg_koi8_r_to_ibm866_desc'
62238438Sdteske		'6 $msg_koi8_u_to_ibm866u'    '$msg_koi8_u_to_ibm866u_desc'
63238438Sdteske	" # END-QUOTE
64238438Sdteske
65238438Sdteske	size=$( eval f_dialog_menu_size \
66238438Sdteske	        	\"\$DIALOG_TITLE\"     \
67238438Sdteske	        	\"\$DIALOG_BACKTITLE\" \
68238438Sdteske	                \"\$prompt\"           \
69238438Sdteske	        	\"\$hline\"            \
70238438Sdteske	        	$menu_list             )
71238438Sdteske
72240768Sdteske	local dialog_menu
73240768Sdteske	dialog_menu=$( eval $DIALOG \
74238438Sdteske		--clear --title \"\$DIALOG_TITLE\" \
75238438Sdteske		--backtitle \"\$DIALOG_BACKTITLE\" \
76238438Sdteske		--hline \"\$hline\"                \
77238438Sdteske		--ok-label \"\$msg_ok\"            \
78238438Sdteske		--cancel-label \"\$msg_cancel\"    \
79238438Sdteske		--menu \"\$prompt\" $size          \
80238438Sdteske		$menu_list                         \
81240768Sdteske		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
82240768Sdteske	)
83240768Sdteske	local retval=$?
84240768Sdteske	setvar DIALOG_MENU_$$ "$dialog_menu"
85240768Sdteske	return $retval
86238438Sdteske}
87238438Sdteske
88238438Sdteske############################################################ MAIN
89238438Sdteske
90238438Sdteske# Incorporate rc-file if it exists
91238438Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
92238438Sdteske
93238438Sdteske#
94238438Sdteske# Process command-line arguments
95238438Sdteske#
96249746Sdteskewhile getopts dD:hSX flag; do
97238438Sdteske	case "$flag" in
98238438Sdteske	h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
99238438Sdteske	esac
100238438Sdteskedone
101238438Sdteskeshift $(( $OPTIND - 1 ))
102238438Sdteske
103238438Sdteske#
104238438Sdteske# Initialize
105238438Sdteske#
106238438Sdteskef_dialog_title "$msg_system_console_screenmap"
107238438Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
108238438Sdteskef_mustberoot_init
109238438Sdteske
110238438Sdteske#
111238438Sdteske# Launch application main menu
112238438Sdteske#
113238438Sdteskewhile :; do
114238438Sdteske	dialog_menu_main
115238438Sdteske	retval=$?
116238438Sdteske	mtag=$( f_dialog_menutag )
117238438Sdteske
118238438Sdteske	[ $retval -eq 0 ] || f_die
119238438Sdteske
120238438Sdteske	case "$mtag" in
121238438Sdteske	"1 $msg_none") # No screenmap, don't touch font
122238438Sdteske		f_sysrc_set scrnmap "NO" || f_die
123238438Sdteske		break ;;
124238438Sdteske	"2 $msg_iso_8859_1_to_ibm437") # W-Europe ISO 8859-1 to IBM 437 scrnmap
125238438Sdteske		f_sysrc_set scrnmap "iso-8859-1_to_cp437" || f_die
126238438Sdteske		break ;;
127238438Sdteske	"3 $msg_iso_8859_7_to_ibm437") # Greek ISO 8859-7 to IBM 437 screenmap
128238438Sdteske		f_sysrc_set scrnmap "iso-8859-7_to_cp437" || f_die
129238438Sdteske		break ;;
130238438Sdteske	"4 $msg_us_ascii_to_ibm327") # US-ASCII to IBM 437 screenmap
131238438Sdteske		f_sysrc_set scrnmap "us-ascii_to_cp437" || f_die
132238438Sdteske		break ;;
133238438Sdteske	"5 $msg_koi8_r_to_ibm866") # Russian KOI8-R to IBM 866 screenmap
134238438Sdteske		f_sysrc_set scrnmap "koi8-r2cp866" || f_die
135238438Sdteske		break ;;
136238438Sdteske	"6 $msg_koi8_u_to_ibm866u") # Ukrainian KOI8-U to IBM 866u screenmap
137238438Sdteske		f_sysrc_set scrnmap "koi8-u2cp866u" || f_die
138238438Sdteske		break ;;
139238438Sdteske	esac
140238438Sdteske
141238438Sdteskedone
142238438Sdteske
143238438Sdteskeexit $SUCCESS
144238438Sdteske
145238438Sdteske################################################################################
146238438Sdteske# END
147238438Sdteske################################################################################
148