#!/bin/sh
#set -x

#============================================================================
#
# copyright (c) 1997    CCS Informationssysteme GmbH
#                       D-85586 Poing
#
# file:		start_cyr [l]       "l" calls xmodmap with latin/cyrill
#                                   otherwise         with cyrill/latin
#
# purpose:      script to start EUKLID Design from a cyrillic shell
#
# created:      04/96
# modified:     08/97
#
#============================================================================
# hints:      - create entries in your X resource file, e.g. $HOME/.Xdefaults:
#               Bea*fontList: cyrillic_7x13
#               Bea*menu_bar*fontList: cyrillic_7x13
#             - make sure that this X resource file is accessible:
#               on HP you need an environment variable XENVIRONMENT for
#               this purpose, e.g. add in a start-up file:
#               XENVIRONMENT=$HOME/.Xdefaults; export XENVIRONMENT
#             - set language to "russian", text fonts to "cyrillic_helvetica"
#               and save this configuration
#============================================================================

echo "---   Start cyrillic version of EUKLID Design   ---"

type=`uname`
case $type in
     HP-UX)   host=hp
              x11_dir=/usr/bin/X11     ;;
     IRIX)    host=sgi
              x11_dir=/usr/bin/X11     ;;
     SunOS)   host=sun
              x11_dir=/usr/openwin/bin ;;
     AIX)     host=ibm
              x11_dir=/usr/bin/X11     ;;
esac

d2_dir=/opt/konsys/euklid_design/v580

stty -istrip                                           # enable keys > 127 from keyboard
$x11_dir/xset  fp default                              # reset X fontpath
$x11_dir/xset +fp $d2_dir/d23bs/xfonts                 # set cyrillic font path
$x11_dir/xset  fp rehash                               # refresh font table

##$x11_dir/xset -q                                     # uncomment for test
##$x11_dir/xmodmap -pm                                 # uncomment for test
##$x11_dir/xmodmap -pk                                 # uncomment for test

if test -f /tmp/xmodmap.pke;
   then rm /tmp/xmodmap.pke;
fi

$x11_dir/xmodmap -pke > /tmp/xmodmap.pke               # save existing settings

verbose=
##verbose=-verbose                                     # uncomment for test

if [ $1 ] &&  [ $1 = l ]
  then
        $x11_dir/xmodmap $verbose $d2_dir/etc/.Xmodmap_latin_cyrill.$host  # switch keyboard mapping
        shift 1
        xterm -sb -fn cyrillic_7x13 -e $d2_dir/d2.exe $*                   # start shell with cyrillic font
  else
        $x11_dir/xmodmap $verbose $d2_dir/etc/.Xmodmap_cyrill_latin.$host  # switch keyboard mapping
        xterm -sb -fn cyrillic_7x13 -e $d2_dir/d2.exe $*                   # start shell with cyrillic font
fi

$x11_dir/xset  fp default                              # reset X fontpath
$x11_dir/xset  fp rehash                               # refresh font table

$x11_dir/xmodmap $verbose /tmp/xmodmap.pke             # restore old settings
$x11_dir/xmodmap $verbose -e "clear mod1"
$x11_dir/xmodmap $verbose -e "add mod1 = Alt_L Alt_R"  # restore mod1

if test -f /tmp/xmodmap.pke;
   then rm /tmp/xmodmap.pke;
fi

##$x11_dir/xmodmap -pk                                 # uncomment for test
##$x11_dir/xmodmap -pm                                 # uncomment for test
