:
#	@(#) demo 23.3 91/10/24 
#
#	Copyright (C) 1990-1991 The Santa Cruz Operation, Inc.
#		All Rights Reserved.
#	The information in this file is provided for the exclusive use of
#	the licensees of The Santa Cruz Operation, Inc.  Such users have the
#	right to use, modify, and incorporate this code into other products
#	for purposes authorized by the license agreement provided they include
#	this notice and the associated copyright notice with any such product.
#	The information in this file is provided "AS IS" without warranty.
#

# return codes for functions called from menu
M_READY=0;   M_STAY=1
M_UPONE=2;   M_CONT1=3
M_CONT2=4;   M_UPTWO=5 
M_UPTHREE=6; M_TOP=7

# Windows we will use
MainWindow=1

fkey() {
        wmove $MainWindow; werase
	echo "You hit Function Key $1"
}

################
# Functions that will be called by the menu tree 
fnP() {
        wmove $MainWindow; werase
        pp *
        werase
        [ "$PP_NUM" -ge 0 ] && {
                echo "you chose >$PP_ITEM< from the pp list"
        }
        [ "$PP_NUM" -eq -1 ] && {
                echo "you hit ESC, to exit the PP list"
        }
        return $M_STAY 
}
fnI() {
        wmove $MainWindow; werase
        pp *
        [ "$PP_NUM" -ge 0 ] && {
                werase
                oaed $PP_ITEM
        }
        return $M_STAY 
}

fnT() {
        wmove 1; werase
        echo "
dateline : put up a date line
error    : display an error
form     : execute a form
menu     : run a menu tree 
oainit, oadeinit: init and clean up curses 
oaed     : editor
pp       : point and pick  
scan     : scan a file
scrollok : togle scroll flag, default FALSE 
win      : reads stdin, writes to a win  
wmopen, wmclose : window manger calls 
werase wclear wmove wrefresh wattr: more curses calls"
        return $M_STAY
}

fnE() { 
        wmove $MainWindow; werase
        echo "enter a string to go in the error win >\c"
        read gack
        error "Error String :$gack"
        return $M_STAY 
}

fnD() {
        wmove $MainWindow; werase
        echo "enter a string to go in the dateline >\c"
        read gack
        dateline $gack
        return $M_STAY 
}

fnS() { 
        wmove $MainWindow 
        scan ${OALIB}/utilbin/oash.doc
        return $M_STAY
}

fnF() {
        wmove $MainWindow; werase
        form demo_form "((demo"
        # show the contents of the form
        werase
        for i in $FIELD0 $FIELD1 $FIELD2 $FIELD3 $FIELD4 $FIELD5 
        do      
                [ "$i" != "" ] && echo "$i"
        done
        return $M_STAY
}

fnA() {
	wmove $MainWindow; werase

	wattr -so 
	echo "** standout **" 
	wattr -se

	wattr -bo 
	echo "** blink **" 
	wattr -be

	wattr -uo 
	echo "** underline **" 
	wattr -ue

	wattr -do 
	echo "** dim **" 
	wattr -de

	wattr -lo 
	echo "** boLd **" 
	wattr -le

	wattr -so -lo -uo
	echo "** IN standout, BOLD, underline **" 
	wattr -se -le -ue

	echo  normal text
	return $M_STAY 
}

fnQ() {
        return $M_READY
}


################
# Main()
P=`pwd`

# init curses
oainit

werase	    # these two calls workaround a curses bug that shows up in menu
wrefresh 

# show a dateline
dateline $P

# build main display window, 
# this window will be known as '$MainWindow', 
# when accessed by window commands
wmopen $MainWindow 18 80 4 0 

# begin menu traversal
menu demo_menu "Oash Demo "

# end main
oadeinit
