richb@Aus.Sun.COM (Rich Burridge) (01/16/90)
Posting-number: Volume 10, Issue 6 Submitted-by: richb@Aus.Sun.COM (Rich Burridge) Archive-name: calctool24/part01 This is V2.4 of a desktop calculator for the Sun workstation. This version works under SunView, XView, X11, NeWS, MGR and for dumb tty terminals. It is almost visually identical to V2.1 which was released in August 1988, but internally most of the code has been reworked to include a level of graphics abstraction, to make porting this code to other window systems a trivial task. V2.4 includes display in scientific notation, color icons, a correct factorial function and fixes for a few minor bugs. It introduces the new versions for XView, X11, MGR and dumb terminals. New functions include hyperbolic and inverse hyperbolic trigonometrical functions, register exchange, constants and the input of numbers in exponential notation. You can also have a .calctoolrc file in your home directory, which can define upto ten new values for constants, and ten function definitions which are used in conjunction with the FUN key. **IMPORTANT NOTE** Several of the keyboard equivalents for various calctool functions have been changed to allow for the new functionality and to be more intuitive. See the online help, the README file or the manual pages for more details. Suggestions for furthur improvement would be most welcome, plus bugs, comments and flames. Rich Burridge, DOMAIN: richb@sunaus.oz.au PHONE: +61 2 413 2666 UUCP: {uunet,mcvax,ukc}!munnari!sunaus.oz!richb ---- Cut Here and unpack ---- #!/bin/sh # shar: Shell Archiver (v1.22) # Packed Tue Jan 9 12:17:18 EST 1990 by stard!richb # from directory /extra/richb/rich_stuff/calctool # # This is part 1 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # # Run the following text with /bin/sh to create: # README # Makefile # TODO # calctool.help # calctool.1 # calctool.ps # patchlevel.h # .calctoolrc # graphics.c # display.c # functions.c # get.c # calctool.c # mgr.c # news.c # sunview.c # tty.c # x11.c # xview.c # calctool.h # color.h # extern.h # calctool.icon # calctool.color.icon # help.cursor # if test -r s2_seq_.tmp then echo "Must unpack archives in sequence!" next=`cat s2_seq_.tmp`; echo "Please unpack part $next next" exit 1; fi echo "x - extracting README (Text)" sed 's/^X//' << 'SHAR_EOF' > README && X Xcalctool - README - November 1989. X XThis is V2.4 of a desktop calculator for the Sun workstation. XThis version works under SunView, XView, X11, NeWS, MGR and for Xdumb tty terminals. X XIt is almost visually identical to V2.1 which was released in August X1988, but internally most of the code has been reworked to include a Xlevel of graphics abstraction, to make porting this code to other Xwindow systems a trivial task. X XV2.4 includes display in scientific notation, color icons, a correct Xfactorial function and fixes for a few minor bugs. It introduces the Xnew versions for XView, X11, MGR and dumb terminals. New functions Xinclude hyperbolic and inverse hyperbolic trigonometrical functions, Xregister exchange, constants and the input of numbers in exponential Xnotation. You can also have a .calctoolrc file in your home directory, Xwhich can define upto ten new values for constants, and ten function Xdefinitions which are used in conjunction with the FUN key. X X**IMPORTANT NOTE** X XSeveral of the keyboard equivalents for various calctool functions Xhave been changed to allow for the new functionality and to be more Xintuitive. X XSee the online help or the manual pages for more details. X XThis code has been tested on a range of different Sun machines under a Xvariety of O/Ss. See the beginning of the Makefile for details of what Xyou might have to tweak in order to get it working under different O/Ss Xor on other machines, and also how to compile and link for the different Xversions. Note that calctool creates a library before generating the Xappropriate calctool binary. By default, this is a normal 'ar' type Xlibrary, but with SunOS v4.x it is possible to create a shared library. XIn order to do this, you should type 'make shared' before making the Xcalctool of your choice. It will install this library in the directory Xdefined by the Makefile macro definition LIBDIR, so you might need root Xpermission to successfully do this. X XThere is a TODO file included, which lists the current known bugs, and Xa set of possible enhancements, some relatively trivial, others that Xare fairly major enhancements which would make interesting future Xprojects. X X XAcknowledgements. X XThanks to Ed Falk at Sun Microsystems (Mountain View) for most of the Xbasic arithmetical algorithms used, to Andrew Nicholson for revising the Xprevious version of the NeWS code, to Sriram Ramachandran for fixing up Xthe XView code, and Hala Abdalla for the original implementation of the Xpopup menu and function keyboard support. X XThanks go also to James Buster, David Weaver, Steve Damron, Mike Bender, XCharles Tierney, Trevor Watson and Marla Berg for bug reports and sugggested Xenhancements. X XSuggestions for furthur improvement would be most welcome, plus bugs, Xcomments and flames. X XRich Burridge, DOMAIN: richb@sunaus.oz.au XPHONE: +61 2 413 2666 UUCP: {uunet,mcvax,ukc}!munnari!sunaus.oz!richb SHAR_EOF chmod 0444 README || echo "restore of README fails" set `wc -c README`;Sum=$1 if test "$Sum" != "2888" then echo original size 2888, current size $Sum;fi echo "x - extracting Makefile (Text)" sed 's/^X//' << 'SHAR_EOF' > Makefile && X# X# Makefile for calctool, a calculator program. X# X# @(#)Makefile 1.16 89/12/21 X# X# Copyright (c) Rich Burridge. X# Sun Microsystems, Australia - All rights reserved. X# X# Permission is given to distribute these sources, as long as the X# copyright messages are not removed, and no monies are exchanged. X# X# No responsibility is taken for any errors inherent either in the comments X# or the code of this program, but if reported to me then an attempt will X# be made to fix them. X# X#====================================================================== X# X# There are various small changes needed when compiling calctool on X# different systems. These have been isolated here, and should X# be uncommented if needed. X# X#====================================================================== X# X# Calctool uses an helpfile to supply online help for each key. X# By default this file is called "calctool.help", and is looked X# for in every directory on the users search path. You can also X# override it's location and name at runtime with the -h option. X# It can also be specified here by uncommenting the following X# macro definition and setting appropriately. X# X#HELPNAME = -DHELPGIVEN -DHELPNAME=\"$(LIBDIR)/calctool.help\" X# X# If you are compiling the MGR version, then the following three X# definitions should be uncommented. X# X#MGRHOME = /usr/mgr X#MGRPARAM = -DMGRHOME=\"$(MGRHOME)\" X#MGRINCDIR = -I$(MGRHOME)/include X# X# If you are compiling the NeWS version, then the following definition X# should be uncommented and set to the default location for the calctool X# PostScript file, which is downloaded to the NeWS server. X# X#NEWSFILE = -DNEWSGIVEN -DNEWSFILE=\"$(LIBDIR)/calctool.ps\" X# X# Calctool loads a run control file when it starts. By default X# this file is called ".calctoolrc", and is taken from the users X# home directory. If there is a similar file in the current directory, X# then these values override the default ones. Its name and location X# can also be specified here by uncommenting the following macro X# definition and setting appropriately. X# X#RCNAME = -DRCGIVEN -DRCNAME=\".calctoolrc\" X# X# If you not running under a BSD4.3 derived system, the parameters X# to the select call are different, and this definition should be X# uncommented. You need to uncomment this for SunOS v3.x. X# X#SELTYPE = -DNO_4.3SELECT X# X# Note that with SunOS v4.x it is possible to create a shared library X# for the calctool routines. If you wish to do this, then you should X# change LIBNAME below to libcalctool.so.1.1, and uncomment the SHLIB X# line. X# XLIBNAME = libcalctool.a X# X#LIBNAME = libcalctool.so.1.1 X#SHLIB = -pic X# X# If you are not running under a BSD4.3 derived system, then the X# second parameter to a select call is a pointer to an integer function, X# and this definition needs to be uncommented. You need to uncomment this X# for SunOS v3.x. X# X#SIGRET = -DNO_4.3SIGNAL X# X# Calctool endevours to provide a numeric keypad using the right function X# keypad. The Sun3 keyboard has a different pad setup to the Sun4 keyboard. X# If you wish to use these function keys with a Sun4 keyboard, then you X# need to uncomment the following definition. X# X#SUN4_KEYBOARD = -DSUN4_KEYBOARD X# X# If you are running SunOS v3.x, then pr_ttext doesn't exist, and X# you must uncomment this definition. X# X#TTEXT = -DNO_PR_TTEXT X# X# If you are compiling the X11 version and the X11 include and X# library files are not in a standard place, then the following X# two lines should be uncommented, and set appropriately. X# X#X11INCDIR = -I$(XNEWSHOME)/include X#X11LIBDIR = -L$(XNEWSHOME)/lib X# X# If you are compiling the XView version, then the following two lines X# should be uncommented. X# X#XVIEWINCDIR = -I$(XNEWSHOME)/include X#XVIEWLIBDIR = -L$(XNEWSHOME)/lib X# X#========================================================================= X# X# Default locations where calctool files will be installed. X# You might wish to alter these values. X# XBINDIR = /usr/local/bin XLIBDIR = /usr/local/lib XMANDIR = /usr/man/man$(MANSECT) XMANSECT = l X# X# Compilation flags and standard macro definitions. X# XCFLAGS = -g $(HELPNAME) $(NEWSFILE) $(RCNAME) $(SELTYPE) $(SHLIB) \ X $(SIGRET) $(SUN4_KEYBOARD) $(TTEXT) \ X $(MGRPARAM) $(MGRINCDIR) $(X11INCDIR) $(XVIEWINCDIR) X# X#========================================================================= X XBINARIES = mgr_calctool ps_calctool sv_calctool \ X tty_calctool xcalctool xv_calctool X XLIBSRCS = graphics.c display.c functions.c get.c XLIBOBJS = graphics.o display.o functions.o get.o XSTDSRCS = calctool.c XSTDOBJS = calctool.o XOBJS = $(STDOBJS) $(LIBNAME) X XGSRCS = mgr.c news.c sunview.c tty.c x11.c xview.c XHDRS = calctool.h color.h extern.h XIMAGES = calctool.icon calctool.color.icon help.cursor XOTHERS = Makefile README TODO calctool.help calctool.1 \ X calctool.ps patchlevel.h .calctoolrc X XSFILES1 = $(LIBSRCS) $(STDSRCS) XSFILES2 = $(GSRCS) XSFILES3 = $(HDRS) $(IMAGES) XSFILES4 = $(OTHERS) X XCALCLIB = -L. -lcalctool XMGRLIBS = $(CALCLIB) $(MGRHOME)/lib/libmgr.a -lm XNEWSLIBS = $(CALCLIB) $$NEWSHOME/lib/libcps.a -lm XSVIEWLIBS = $(CALCLIB) -lsuntool -lsunwindow -lpixrect -lm XTTYLIBS = $(CALCLIB) -ltermcap -lm XX11LIBS = $(CALCLIB) -lX11 -lm XXVIEWLIBS = $(CALCLIB) -lxview -lX11 -lm X X.PRECIOUS: $(LIBNAME) X Xhelp: X @echo X @echo "You need to specify one of the following options:" X @echo X @echo " make mgr - to make the MGR version." X @echo " make news - to make the NeWS version." X @echo " make sunview - to make the SunView version." X @echo " make tty - to make the dumb tty version." X @echo " make x11 - to make the X11 version." X @echo " make xview - to make the XView version." X @echo X @echo "This should be followed by:" X @echo X @echo " make install" X @echo " make clean" X @echo X Xall: $(BINARIES) X Xmgr: $(OBJS) mgr.o X cc -o mgr_calctool $(CFLAGS) $(STDOBJS) mgr.o $(MGRLIBS) X -cp mgr_calctool calctool X Xnews: $(OBJS) news.o X cc -o ps_calctool $(CFLAGS) $(STDOBJS) news.o $(NEWSLIBS) X -cp ps_calctool calctool X Xsunview: $(OBJS) sunview.o X cc -o sv_calctool $(CFLAGS) $(STDOBJS) sunview.o $(SVIEWLIBS) X -cp sv_calctool calctool X Xtty: $(OBJS) tty.o X cc -o tty_calctool $(CFLAGS) $(STDOBJS) tty.o $(TTYLIBS) X -cp tty_calctool calctool X Xx11: $(OBJS) x11.o X cc -o xcalctool $(X11LIBDIR) $(CFLAGS) $(STDOBJS) x11.o \ X $(X11LIBS) X -cp xcalctool calctool X Xxview: $(OBJS) xview.o X cc -o xv_calctool $(XVIEWLIBDIR) $(CFLAGS) $(STDOBJS) xview.o \ X $(XVIEWLIBS) X -cp xv_calctool calctool X Xlibcalctool.a: $(LIBOBJS) X ar rv $@ $? X ranlib $@ X X# These are the library creation rules for making the shared calctool X# library (available with SunOS v4.x). X Xlibcalctool.so.1.1: $(LIBOBJS) X ld -o libcalctool.so.1.1 -assert pure-text $? X Xinstall: X install -c -m 644 $(LIBNAME) $(LIBDIR) X install -s -m 751 calctool $(BINDIR) X install -c -m 644 calctool.help $(LIBDIR) X install -c -m 644 calctool.ps $(LIBDIR) X install -c -m 644 calctool.1 $(MANDIR)/calctool.$(MANSECT) X Xclean:; rm -f *.o archive.* *~ *.a $(BINARIES) core X Xlint:; lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) tty.c $(TTYLIBS) X lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) sunview.c $(SVIEWLIBS) X lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) xview.c $(XVIEWLIBS) X lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) x11.c $(X11LIBS) X lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) news.c $(NEWSLIBS) X lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) mgr.c $(MGRLIBS) X Xshar:; shar.script $(SFILES1) > archive.1 X shar.script $(SFILES2) > archive.2 X shar.script $(SFILES3) > archive.3 X shar.script $(SFILES4) > archive.4 X Xcreate: SCCS X -sccs create $(STDSRCS) $(GSRCS) $(HDRS) $(IMAGES) $(OTHERS) XSCCS: X -mkdir SCCS X chmod 755 SCCS SHAR_EOF chmod 0444 Makefile || echo "restore of Makefile fails" set `wc -c Makefile`;Sum=$1 if test "$Sum" != "8158" then echo original size 8158, current size $Sum;fi echo "x - extracting TODO (Text)" sed 's/^X//' << 'SHAR_EOF' > TODO && XBugs: X X1/ The following problems exist for the NeWS v1.1 version: X X a) The calctool icon (color and mono) is not being displayed correctly. X X b) The initial position of the icon should be settable via the X -WP flag. X X c) It should be possible for calctool to start iconically. X X d) Popup menu support needs to be fully implemented. X X e) The NeWS code should be commented. X X X2/ The following problems exist with the mgr version: X X a) The fonts aren't being loaded correctly. X X b) After a reshape, the "panel items" are not being redisplayed. X X c) The right button popup menu support is not correctly working. X X X3/ The following problem exists with the SunView version: X X a) The ENTER key (Right function keypad) is not recognised. X X X4/ The following problems exist with the XView version: X X a) The memory register window is coming up in the wrong place. X This is because of bug 1022495 (xview/library). X X b) The following right keypad function keys are currently not recognised: X 0 . - + ENTER X X X5/ The following problems exist with the X11 version. X X a) The size of the calctool icon on the monochrome version is incorrect. X X XEnhancements: X X1/ Incorporate a multi-precision arithmetic package as the basis of all X calculations. The display could then include two little arrow icons, X one at each side of the numeric display, which would shift the contents X to the left or the right. X X2/ Add some more functions. Some suggested functions are: X X a) Common antilogarithm and natural antilogarithm. X X b) Cube root key. X X c) Root key. The y root of x. X X d) Rectangular to polar and polar to rectangular keys. X X e) Random number key. Return a random number between 0.0 and < 1.0. X X3/ Add Reverse Polish notation. X X4/ Support multiple graphics version in the same binary or write a front-end X shell script that with select the appropriate binary depending on the X environment [MGR/NeWS/SunView/tty/X11] [Sun3/Sun4/Sun386i] etc.. X X5/ See if it's possible to get the GET and PUT function keys working with X the NeWS and the X11 versions. SHAR_EOF chmod 0444 TODO || echo "restore of TODO fails" set `wc -c TODO`;Sum=$1 if test "$Sum" != "2100" then echo original size 2100, current size $Sum;fi echo "x - extracting calctool.help (Text)" sed 's/^X//' << 'SHAR_EOF' > calctool.help && X_calctool.help_ X_EXCH_ XRegister exchange n ( ^e ). X XThis must be followed by a digit Xin the range 0 - 9 to indicate Xwhich register should be inter- Xchanged with the current display. X_CON _ XConstant n ( # ). X XThis must be followed by a digit Xin the range 0 - 9 to indicate Xwhich constant should be shown. X XThe ten default constants are: X X0 - kms per hour / miles per hour. X1 - square root of 2. X2 - e. X3 - pi. X4 - cms / inches. X5 - degrees in a radian. X4 - 2 ^ 20. X6 - gms / oz. X8 - kilojoules / British thermals. X9 - cubic cms / cubic inches. X_BIN _ XChange base to binary ( B ). X XThe display value is shown in Xbinary. A maximum of 32 digits Xare allowed. X_MEM _ XToggle register window ( M ). X XDisplay popup window with the Xvalues of the ten memory Xregisters given in the current Xbase, to the current accuracy. X_OCT _ XChange base to octal ( O ). X XThe display value is shown in Xoctal. A maximum of 15 digits Xare allowed. X_D _ XHex D (decimal 13) ( d ). X XThis selection is valid only if Xthe current base is hexidecimal. X_DEC _ XChange base to decimal ( D ). X XThe display value is shown in Xdecimal. This is the default Xbase. A maximum of 12 digits Xare allowed. X_E _ XHex E (decimal 14) ( e ). X XThis selection is valid only if Xthe current base is hexidecimal. X_HEX _ XChange base to hexidecimal ( H ). X XThe display value is shown in Xhexidecimal. A maximum of 12 Xdigits are allowed. X_F _ XHex F (decimal 15) ( f ). X XThis selection is valid only if Xthe current base is hexidecimal. X_FIX _ XFixed Notation ( ^n ). X XNumerical values will be Xdisplayed in fixed point Xnotation. This button toggles Xbetween fixed and scientific Xnotation. X_SCI _ XScientific notation ( ^n ). X XNumerical values will be Xdisplayed in scientific notation. XThis button toggles between Xscientific and fixed point Xnotation. X_FUN _ XFunction key n ( ^f ). X XThis must be followed by a digit Xin the range 0 - 9, to indicate Xwhich user defined function is Xto be performed. X XThese functions are defined in a X.calctoolrc file, in your home Xdirectory. See the calctool Xmanual page for the format of Xthis file. X_&32 _ XGet 32 bit unsigned int ( [ ). X XThis is a logical function, that Xwill truncate the given number to Xreturn a 32 bit unsigned integer. X_STO _ XStore memory register n ( s ). X XThis must be followed by an Xarithmetic operation (addition, Xsubtraction, multiplication or Xdivision), then a digit in the Xrange 0 to 9 to indicate the Xmemory register in which to Xstore the current display value. XThe arithmetic operator is Xoptional in which case the Xcurrent display is stored in the Xmemory register. X_&16 _ XGet 16 bit unsigned int ( ] ). X XThis is a logical function, that Xwill truncate the given number to Xreturn a 16 bit unsigned integer. X_RCL _ XRetrieve memory register n ( r ). X XThis must be followed by a digit Xin the range 0 to 9 to indicate Xthe memory register from which Xdata is to be to retrieved. X_< _ XLeft shift n ( < ). X XThis must be followed by a digit Xin the range 0 to 9 to indicate Xhow many places to shift. X_A _ XHex A (decimal 10) ( a ). X XThis selection is valid only if Xthe current base is hexidecimal. X_> _ XRight shift n ( > ). X XThis must be followed by a digit Xin the range 0 to 9 to indicate Xhow many places to shift. X_B _ XHex B (decimal 11) ( b ). X XThis selection is valid only if Xthe current base is hexidecimal. X_% _ XPercentage ( % ). X XThis calculation takes the last Xnumber enter and the next number Xgiven, and performs a percentage Xcalculation on them. X_C _ XHex C (decimal 12) ( c ). X XThis selection is valid only if Xthe current base is hexidecimal. X_clr _ XClear display ( Delete ). X XThis will clear the value of the Xcalculators display. X_bsp _ XErase character ( BackSpace ). X XThe right most character of the Xcurrent calculator display value Xis removed, and the value of the Xdisplay is recalculated. (Note: Xinternal accuracy is lost with Xthis operation.) X_OR _ XLogical OR ( | ). X XThis operation takes the last Xnumber and the next number Xentered, and performs a logical XOR operation on them, treating Xboth numbers as unsigned long Xintegers. X_AND _ XLogical AND ( & ). X XThis operation takes the last Xnumber and the next number Xentered, and performs a logical XAND operation on them, treating Xboth numbers as unsigned long Xintegers. X_HYP _ XHyperbolic flag. ( h ). X XThis button is a toggle for Xsetting or unsetting the Xhyperbolic function flag. This Xflag affects SIN, COS and TAN Xtrigonometrical functions. X_SIN _ XSine function ( ^s ). X XReturns the trigonometric sine, Xarc sine, hyperbolic sine or Xinverse hyperbolic sine of Xthe current value, depending Xupon the settings of the XHYP and INV flags. The result Xis displayed in the current Xunits (degrees, radians or Xgradients). X_e^x _ Xe to the x power ( { ). X XReturn e raised to the power of Xthe current display value. X_7 _ XNumeric 7 ( 7 ). X XThis selection is ignored if Xthe current base is binary. X_10^x_ X10 to the x power ( } ). X XReturn 10 raised to the power of Xthe current display value. X_8 _ XNumeric 8 ( 8 ). X XThis selection is ignored if Xthe current base is octal or Xbinary. X_y^x _ Xy to the power of x ( Y ). X XThe operation takes the last Xnumber and raises it to the power Xof the next number given. X_9 _ XNumeric 9 ( 9 ). X XThis selection is ignored if Xthe current base is octal or Xbinary. X_INT _ XInteger portion ( I ). X XReturn the integer portion of the Xcurrent displayed value. X_X _ XMultiplication ( * or x or X ). X XThis operation takes the last Xnumber and the next number Xentered, and performs an Xarithmetic multiplication on Xthem. X_XNOR_ XLogical XNOR ( n or N ). X XThis operation takes the last Xnumber and the next number Xentered, and performs a logical XXNOR operation on them, treating Xboth numbers as unsigned long Xintegers. X_XOR _ XLogical XOR ( ^ ). X XThis operation takes the last Xnumber and the next number Xentered, and performs a logical XXOR operation on them, treating Xboth numbers as unsigned long Xintegers. X_INV _ XInverse function flag ( i ). X XThis button is a toggle for Xsetting or unsetting the Xinverse function flag. This Xflag affects SIN, COS and TAN Xtrigonometrical functions. X_COS _ XCosine function ( ^c ). X XReturns the trigonometric cosine, Xarc cosine, hyperbolic cosine or Xinverse hyperbolic cosine of Xthe current value, depending Xupon the settings of the XHYP and INV flags. The result Xis displayed in the current Xunits (degrees, radians or Xgradients). X_ln _ XNatural log ( N ). X XThis operation returns the Xnatural logarithm of the current Xdisplayed value. X_4 _ XNumeric 4 ( 4 ). X XThis selection is ignored if Xthe current base is binary. X_log _ XBase 10 log ( G ). X XThis operation returns the base X10 logarithm of the current Xdisplayed value. X_5 _ XNumeric 5 ( 5 ). X XThis selection is ignored if Xthe current base is binary. X_SQRT_ XSquare root ( S ). X XThis operation will perform a Xsquare root operation on the Xcurrent value of the calculator Xdisplay. X_6 _ XNumeric 6 ( 6 ). X XThis selection is ignored if Xthe current base is binary. X_FRAC_ XFractional portion ( F ). X XReturn the fractional portion of Xthe current displayed value. X_/ _ XDivision ( / ). X XThis operation takes the last Xnumber and performs an Xarithemetic division by the Xnext number entered. X_NOT _ XLogical NOT ( ~ ). X XThis operation will perform the Xlogical NOT operation of the Xcurrent value of the calculators Xdisplay. X_ACC _ XAccuracy n ( A ). X XThis must be followed by a digit Xin the range 0 to 9 to indicate Xhow many digits of precision are Xto be displayed. X_EXP _ XEnter exponental number ( E ). X XThis operation starts exponential Xinput. Any numbers typed from now Xon are the exponent. If no Xnumerical input had occured upto Xthis point, then a mantissa of X1.0 is assumed. X_TAN _ XTangent function ( ^t ). X XReturns the trigonometric tangent, Xarc tangent, hyperbolic tangent or Xinverse hyperbolic tangent of Xthe current value, depending Xupon the settings of the XHYP and INV flags. The result Xis displayed in the current Xunits (degrees, radians or Xgradients). X_1/x _ XReciprocal ( R ). X XThe will return the current the Xvalue of 1 divided by the current Xdisplay value. X_1 _ XNumeric 1 ( 1 ). X_x! _ XFactorial ( ! ). X XThis will return the factorial of Xthe current displayed value. X_2 _ XNumeric 2 ( 2 ). X XThis selection is ignored if Xthe current base is binary. X_x^2 _ XSquare ( @ ). X XThis will reurn the square of the Xcurrent displayed value. X_3 _ XNumeric 3 ( 3 ). X XThis selection is ignored if Xthe current base is binary. X_CHS _ XChange sign ( C ). X XChange the arithmetic sign of the Xcurrent displayed value or the Xexponent being entered. X_- _ XSubtraction ( - ). X XThis operation takes the last Xnumber and performs an Xarithemetic subtraction of the Xnext number entered. X_QUIT_ XQuit calctool ( q or Q ). X XThe calctool program is exited, Xwithout user verification. X_OFF _ XTurn calctool iconic ( o ). X_KEYS_ XToggle button labels ( K ). X XToggle the labels on the calctool Xbuttons between the mouse and Xkeyboard equivalents. X_? _ XCalctool Help v2.4. ( ? ). X XAll calculations are in double Xprecision. The display can be Xused with the [Get] and [Put] Xfunction keys with other Sunview Xwindows. For every mouse Xselection, there is an equivalent Xkeystroke. These can be found by Xselecting the KEYS button. X XIf an error condition occurs, you Xmust clear the calculator. X XAfter this, when you select [?] Xyou will get help on the next Xselection you make. X_DEG _ XTrig base to degrees ( ^d ). X XChange the current trigonometrical Xbase to degrees. X_0 _ XNumeric 0 ( 0 ). X_RAD _ XTrig base to radians ( ^r ). X XChange the current trigonometrical Xbase to radians. X_. _ XNumeric point ( . ). X XSelecting this starts the Xfractional part of numeric entry. X_GRAD_ XTrig base to gradients ( ^g ). X XChange the current trigonometrical Xbase to gradients. X_= _ XCalculate result ( = or Return ). X XThe result of the current Xcalculation is displayed in Xthe current base. X_ABS _ XAbsolute value. ( U ). X XReturn the absolute value of the Xcurrent displayed value. X_+ _ XAddition ( + ). X XThis operation takes the last Xnumber and the next number Xentered, and performs an Xarithmetic addition on them. X______ SHAR_EOF chmod 0444 calctool.help || echo "restore of calctool.help fails" set `wc -c calctool.help`;Sum=$1 if test "$Sum" != "10856" then echo original size 10856, current size $Sum;fi echo "x - extracting calctool.1 (Text)" sed 's/^X//' << 'SHAR_EOF' > calctool.1 && X.\" @(#)calctool.1 1.8 89/12/13 X.TH CALCTOOL 1L "13 December 1989" X.SH NAME Xcalctool \- a simple calculator X.SH SYNOPSIS X.B "calctool X[ X.B -a X.I accuracy X] X[ X.B -d X.I display X] X[ X.B -g X.I geometry X] X[ X.B -h X.I helpfile X] X[ X.B -i X] X[ X.B -v X] X[ X.B \-Wi X] X[ X.B \-Wp X.I x y X] X[ X.B \-WP X.I x y X] X.SH DESCRIPTION X.I Calctool Xis a simple calculator. It contains graphical interfaces for MGR, NeWS, XSunView, X11 and XView, as well as being able to function on normal display Xterminals using a termcap interface. It can receive input via the keyboard, Xor the mouse where applicable. Each calculator button has two functions Xassociated with it. X.LP XInternal arithmetic is done with double precision floating point numbers. XAccuracy can be adjusted from zero to nine numeric places in fixed notation, Xbut numbers can be displayed in scientific notation as well. The calculator Xreverts to scientific notation when the number is larger than the display Xwould allow in fixed notation. The base of operation can be changed between Xbinary, octal, decimal and hexidecimal. Numbers are initially displayed in Xfixed notation to two numeric places, in the decimal base. X.LP XYou can use the SunView / XView X.I Put Xand X.I Get Xfunction keys in conjunction with the numeric display to store or retrieve Xcharacters from the text shelf. The previous digit entered can be removed Xand the whole display cleared. X.LP XThere are ten memory registers; numbers can be retrieved or stored in Xthese locations, and arithmetic can be performed upon register contents. X.LP XThe display windows contains the current numerical value plus the current Xbase and trigonometric type. There are also indicators which show if the Xhyperbolic and inverse function switches are set, and which numerical mode Xis currently in operation. If an operation needing more than one numerical Xinput is partially complete, the operation is also displayed in this window Xas a reminder. X.LP XThe calculator has arithmetical, logical and trigonometrical functions. XThese are grouped together and color coded on color workstations. X.LP XWith the SunView and XView versions, there is support for popup menus with Xthe right mouse button. Only certain buttons which have multiple options Xhave this ability. These are the ACC, CON, EXCH, FUN, <, >, RCL and STO keys. X.LP XOnline help is provided via a help button. Select this button, and then Xthe function you wish to be described. The calctool windows can be redrawn Xby typing ^L (control-l). This is very useful with the tty version after Xsomebody has written system messages all over your screen. X.LP XOn startup, X.I calctool Xwill look for a X.I .calctoolrc Xfile in the users' home directory. This file allows the user to define Xtheir own constants and function definitions. It then looks for a X.I .calctoolrc Xfile in the current directory. With the X.I .calctoolrc Xfile, there are currently four valid record types; comments, constants, Xfunction definitions and initial memory register values. X.LP XLines starting with a '#' are treated as comments and ignored. X.LP XLines starting with 'c' or 'C' in the first column are definitions for Xconstants. The cC is followed by a digit in the range 0-9, then a space. XThis is followed by a number in fixed or scientific notation. Following Xthis is an optional comment, which if found, will be used in the popup Xmenu for the constants. If the comment is present, then there must be at Xleast one space between this and the preceding number. X.LP XLines starting with 'f' or 'F' in the first column are definitions Xfor functions. The fF is followed by a digit in the range 0-9, then a Xspace. This is followed by a function definition. Following this is an Xoptional comment, which if found, will be used in the popup menu for the Xfunctions. If the comment is present, then there must be at least one Xspace between this and the preceding function definition. X.LP XLines starting with 'r' or 'R' in the first column are definitions Xfor the initial contents of the memory registers. The rR is followed Xby a digit in the range 0-9, then a space. This is followed by a number Xin fixed or scientific notation. The rest of the line is ignored. X.LP XAll other lines are ignored. There should be no embedded spaces in the Xfunction definitions. Whenever a backslash is found, this and the following Xcharacter signify a control character, for example \\g would be ASCII 7. X.SH OPTIONS X.TP X.BI \-a " accuracy" XInitial number of significant digits displayed. This value must be in Xthe range 0 to 9. If not specified, this value defaults to 2. X.TP X.BI \-d " display" XUsed with the X11 variant of calctool to give a display type. X.TP X.BI \-g " geometry" XUsed with the X11 variant of calctool to give geometry information. X.TP X.BI \-h " helpfile" XUse an alternate helpfile. X.TP X.B \-i XInvert the calctool window before displaying it. For use by people who Xstarted their graphics environment in inverse mode. X.TP X.B \-v XPrint the version number of this release of the X.B calctool Xprogram. X.TP X.B \-Wi XStart the X.B calctool Xprogram up in iconic form. SunView automatically uses this flag, but the XNeWS version will also. X.TP X.BI \-Wp " x y" XStart the open window position at X.I x y X.TP X.BI \-WP " x y" XStart the icon position at X.I x y X.SH CALCULATOR BUTTONS X[Keyboard equivalents appear in brackets] X.SS "Numerical Keys [ 0-9 a-f . = <RETURN> ]." X.LP XEnter a digit (decimal digits 0-9 or hexidecimal digits A-F) in the display. XThe . acts as the decimal point and = is used for completion of numerical Xentry (<RETURN> can be also be used from the keyboard to terminate numerical Xentry). X.SS "Arithmetical Operations [ + - x X * / ]." X.LP XPerform an arithmetical operation using the previous entry and the next entry Xas operands. Addition, subtraction, multiplication and division are denoted Xby the buttons +, \-, x and / respectively (the keyboard keys * and X are Xsynonymous with x for multiplication). X.SS Base Changes. X.LP X.IP "\fBBIN [ B ]\fP" 18 XChange display base to binary (maximum: 32 digits). X.IP "\fBOCT [ O ]\fP" 18 XChange display base to octal (maximum: 15 digits). are allowed. X.IP "\fBDEC [ D ]\fP" 18 XChange display base to decimal (default; maximum: 12 digits). X.IP "\fBHEX [ H ]\fP" 18 XChange display base to hexidecimal (maximum: 12 digits). X.SS Trigonometric Unit Changes. X.LP X.IP "\fBDEG [ ^d ]\fP" 18 XChange current trigonometrical base to degrees. X.IP "\fBRAD [ ^r ]\fP" 18 XChange the current trigonometrical base to radians. X.IP "\fBGRAD [ ^g ]\fP" 18 XChange the current trigonometrical base to gradients. X.SS Logical Operations. X.LP X.IP "\fBAND [ & ]\fP" 18 XPerform a logical AND operation on the current entry and the next entry, Xtreating both numbers as unsigned long integers. X.IP "\fBNOT [ ~ ]\fP" 18 XPerform the logical NOT operation of the current entry. X.IP "\fBOR [ | ]\fP" 18 XPerform a logical OR operation on the current entry and the next entry, Xtreating both numbers as unsigned long integers. X.IP "\fBXNOR [ n or N ]\fP" 18 XPerform a logical XNOR operation on the current entry and the next entry, Xtreating both numbers as unsigned long integers. X.IP "\fBXOR [ ^ ]\fP" 18 XPerform a logical XOR operation on the current entry and the next entry, Xtreating both numbers as unsigned long integers. X.SS Trigonometrical Operators. X.LP X.IP "\fBSIN [ ^s ]\fP" 18 XReturn the trigonometric sine, arc sine hyperbolic sine or inverse Xhyperbolic sine of the current display, depending upon the current Xsettings of the hyperbolic and inverse function switches. The result Xis displayed in the current trigonometric units (degrees, radians or Xgradients). X.IP "\fBCOS [ ^c ]\fP" 18 XReturn the trigonometric cosine, arc cosine hyperbolic cosine or inverse Xhyperbolic cosine of the current display, depending upon the current Xsettings of the hyperbolic and inverse function switches. The result Xis displayed in the current trigonometric units (degrees, radians or Xgradients). X.IP "\fBTAN [ ^t ]\fP" 18 XReturn the trigonometric tangent, arc tangent hyperbolic tangent or inverse Xhyperbolic tangent of the current display, depending upon the current Xsettings of the hyperbolic and inverse function switches. The result Xis displayed in the current trigonometric units (degrees, radians or Xgradients). X.SS Memory Register Operators. X.LP X.IP "\fBRCL [ r ]\fP" 18 XRetrieve memory register n. This selection must be followed by a digit Xin the range 0 to 9 to indicate a memory register. X.IP "\fBSTO [ s ]\fP" 18 XStore memory register n. This must be followed by a digit in the range X0 to 9 to indicate a memory register. The register number may be preceded Xby an arithmetic operation (addition, subtraction, multiplication or division), Xin which case the specifed operation is carred out between the Xdisplayed entry and the value currently in register n, and the result is placed Xin register n. X.IP "\fBEXCH [ ^e ]\fP" 18 XExchange the current display with the contents of memory register n. XThis selection must be followed by a digit in the range 0 to 9, to Xindicate a memory register. X.SS Mathematical Operators. X.LP X.IP "\fB% [ % ]\fP" 18 XPerform a percentage calculation using the last entry and the next entry. X.IP "\fBe^x [ { ]\fP" 18 XReturn e raised to the power of the current entry. X.IP "\fB10^x [ } ]\fP" 18 XReturn 10 raised to the power of the current entry. X.IP "\fBy^x [ Y ]\fP" 18 XTake the last entry and raise it to the power of the next entry. X.IP "\fBln [ N ]\fP" 18 XReturn the natural logarithm of the current entry. X.IP "\fBlog [ G ]\fP" 18 XReturns the base 10 logarithm of the current entry. X.IP "\fBSQRT [ S ]\fP" 18 XPerform a square root operation on the current entry. X.IP "\fB1/x [ R ]\fP" 18 XReturn the value of 1 divided by the current entry. X.IP "\fBx! [ ! ]\fP" 18 XReturn the factorial of the current entry. X.IP "\fBx^2 [ @ ]\fP" 18 XReturn the square of the current entry. X.SS Number Manipulation Operators. X.LP X.IP "\fB< [ < ]\fP" 18 XLeft shift n places. This must be followed by a digit Xin the range 0 to 9 to indicate the number of places to shift. X.IP "\fB> [ > ]\fP" 18 XRight shift n places. This must be followed by a digit Xin the range 0 to 9 to indicate the number of places to shift. X.IP "\fB&32 [ [ ]\fP" 18 XTruncate the current entry to a 32 bit unsigned integer X(logical function). X.IP "\fB&16 [ ] ]\fP" 18 XTruncate the given number to a 16 bit unsigned integer X(logical function). X.IP "\fBclr [ Delete ]\fP" 18 XClear the calculator display. X.IP "\fBbsp [ BackSpace ]\fP" 18 XRemove the rightmost character of the current entry Xand recalculate the the displayed value (note: internal accuracy is Xlost with this operation). X.IP "\fBINT [ I ]\fP" 18 XReturn the integer portion of the current entry. X.IP "\fBFRAC [ F ]\fP" 18 XReturn the fractional portion of the current entry. X.IP "\fBACC [ A ]\fP" 18 XSet accuracy. This must be followed by a digit in the range 0 to 9 to Xindicate how many digits are to be displayed. X.IP "\fBCHS [ C ]\fP" 18 XChange the arithmetic sign of the current entry. X.IP "\fBABS [ U ]\fP" 18 XReturn the absolute value of the current entry. X.SS Other keys. X.LP X.IP "\fBMEM [ M ]\fP" 18 XToggle the display of the popup register window. XValues of the ten memory registers are displayed in the current Xbase, to the current accuracy. X.IP "\fBFIX / SCI [ ^n ]\fP" 18 XToggles the numerical display mode between fixed point and scientific Xnotation. This affects the current display and the contents of the Xmemory registers. X.IP "\fBCON [ # ]\fP" 18 XRetrieve and display constant value n. This selection must be followed Xby a digit in the range 0 to 9. X.br XThe ten default constants are: X.sp X0 - kms per hour / miles per hour. X.br X1 - square root of 2. X.br X2 - e. X.br X3 - pi. X.br X4 - cms / inches. X.br X5 - degrees in a radian. X.br X4 - 2 ^ 20. X.br X6 - gms / oz. X.br X8 - kilojoules / British thermals. X.br X9 - cubic cms / cubic inches. X.IP "\fBHYP [ h ]\fP" 18 XSet or unset the hyperbolic function indicator. This switch affects the Xtype of sine, cosine and tangent trigonometric functions performed. X.IP "\fBINV [ i ]\fP" 18 XSet or unset the inverse function indicator. This switch affects the Xtype of sine, cosine and tangent trigonometric functions performed. X.IP "\fBKEYS [ K ]\fP" 18 XToggle the labels on the calctool buttons between mouse and Xkeyboard equivalents. X.IP "\fB? [ ? ]\fP" 18 XDisplay a help message for a particular button. First select this key, then Xthe key to be described. X.IP "\fBQUIT [q or Q]\fP" 18 XExit (without user verification). X.IP "\fBOFF [ o ]\fP" 18 XChange \fIcalctool\fP to an icon. X.SH FILES X.TP X/usr/local/lib/calctool.help X.TP X/usr/local/lib/calctool.ps X.TP X~/.calctoolrc X.SH BUGS XHandling of errors generated by the mathematical routines is poorly Xdone. X.SH AUTHOR XRich Burridge, Domain: richb@sunaus.oz.au X.nf XPHONE: +61 2 413 2666 Path: {uunet,mcvax,ukc}!munnari!sunaus.oz!richb X.fi X.br XOriginal manual page modified by R. P. C. Rodgers, UCSF School of Pharmacy, San XFrancisco, CA 94143. SHAR_EOF chmod 0444 calctool.1 || echo "restore of calctool.1 fails" set `wc -c calctool.1`;Sum=$1 if test "$Sum" != "12952" then echo original size 12952, current size $Sum;fi echo "x - extracting calctool.ps (Text)" sed 's/^X//' << 'SHAR_EOF' > calctool.ps && X X% These are the NeWS dependent graphics routines used by calctool. X% They make use of the tnt toolkit distributed with OpenWindows. X% X% Copyright (c) Rich Burridge - Sun Microsystems, Australia. X% All rights reserved. X% X% @(#)calctool.ps 1.5 89/12/21 X% X% Permission is given to distribute these sources, as long as the X% copyright messages are not removed, and no monies are exchanged. X% X% No responsibility is taken for any errors or inaccuracies inherent X% either to the comments or the code of this program, but if X% reported to me then an attempt will be made to fix them. X% X X% Define a class for the main calctool window. The following events X% are handled: X% X% Left mouse button (down and up). X% Middle mouse button (down and up). X% Right mouse button (down and up). X% Keyboard press. X% Window damage. X% X% For each of these events, an appropriate tag is sent back to the C code. X X/KeyClass ClassCanvas [] Xclassbegin X /PaintCanvas X { X CFRAME_REPAINT typedprint X } def X X /MakeInterests X { X /MakeInterests super send X LeftMouseButton {LEFT_DOWN SendEvent} /DownTransition self MakeInterest X MiddleMouseButton {MIDDLE_DOWN SendEvent} /DownTransition self MakeInterest X LeftMouseButton {LEFT_UP SendEvent} /UpTransition self MakeInterest X MiddleMouseButton {MIDDLE_UP SendEvent} /UpTransition self MakeInterest X {KbdEvent} Canvas /defaultkeys ClassKeysInterest send X } def Xclassend def X X X% Define a class for the memory register window. X% Handle window damage in the same way as the main calctool window. X X/RegClass ClassCanvas [] Xclassbegin X /PaintCanvas X { X RFRAME_REPAINT typedprint X } def Xclassend def X X X% Clear the whole of either the main calctool canvas or the memory X% register canvas to a specific color. X X/PSClearCanvas % color canvas => - X{ X dup setcanvas X ColorTable 3 -1 roll get X /fillcanvas 3 -1 roll send X} def X X X% Close the main calctool window and unmap the memory register window. X X/PSCloseFrame % - => - X{ X /flipiconic KFrame send X /unmap RFrame send X} def X X X% Color a rectangular area in the main calctool window. X X/PSColorArea % color x width height y => - X{ X KC setcanvas X KCHeight exch sub exch dup 3 1 roll sub 3 1 roll rectpath X ColorTable exch get setcolor X fill X} def X X X% Draw a line in the main calctool window. X X/PSDrawLine % x1 x2 y1 y2 => - X{ X KCHeight exch sub X exch KCHeight exch sub 3 1 roll X KC setcanvas X newpath X moveto lineto X 0 setgray X stroke X} def X X X% Draw (map) the memory register window. X X/PSDrawRegs X{ X /map RFrame send X} def X X X% Load the small, normal and bold fonts used by calctool. X X/PSInitFonts % - => - X{ X /SFont /Courier findfont 10 scalefont def X /NFont /Courier-Bold findfont 14 scalefont def X /BFont /Courier-Bold findfont 18 scalefont def X} def X X X% Set up the various tags that are passed back to the C code. X% Note that at present, some of these tags are not used. X X/PSInitialise % - => - X{ X /CFRAME_REPAINT 100 def X /RFRAME_REPAINT 101 def X /ENTER_WINDOW 102 def X /EXIT_WINDOW 103 def X /KEYBOARD 104 def X /LEFT_DOWN 105 def X /LEFT_UP 106 def X /MIDDLE_DOWN 107 def X /MIDDLE_UP 108 def X /RIGHT_DOWN 109 def X /RIGHT_UP 110 def X /TAKE_FROM_SHELF 111 def X /PUT_ON_SHELF 112 def X} def X X X% Test if calctool is running on a color framebuffer. X X/PSIsColor % - => iscolorscreen X{ X /Color? framebuffer /Color get def X Color? {1} {0} ifelse typedprint X} def X X X% Load a red green blue triplet into the appropriate entry in the colortable. X X/PSLoadColor % index blue green red => - X{ X 255 div X exch 255 div X 3 -1 roll 255 div X rgbcolor X ColorTable 3 1 roll put X} def X X X% Create an array big enough for all the colors used by calctool. X X/PSMakeColorTable % size => - X{ X /ColorTable exch array def X} def X X X/KbdEvent X{ X begin X Action /DownTransition eq X { X KEYBOARD typedprint Name SendEvent X } if X end X} def X X X/SendEvent X{ X KC setcanvas X typedprint X currentcursorlocation KCHeight exch sub exch X typedprint typedprint X} def X X X/PaintIcon X{ X clippath pathbbox X scale pop pop X 0 setgray X false calctoolIcon imagemaskcanvas X} def X X X% Create the main calctool frame and the memory registers property sheet. X% Set the size of these items, and place the open frame and icon at the SHAR_EOF echo "End of part 1" echo "File calctool.ps is continued in part 2" echo "2" > s2_seq_.tmp exit 0