xcalc accepts all of the standard toolkit command line options along with two additional options:
Pointer Usage: Operations may be performed with pointer button 1, or in some cases, with the keyboard. Many common calculator operations have keyboard accelerators. To quit, press pointer button 3 on the AC key of the TI calculator, or the ON key of the HP calculator.
Calculator Key Usage (TI mode): The numbered keys, the +/- key, and the +, -, *, /, and = keys all do exactly what you would expect them to. It should be noted that the operators obey the standard rules of precedence. Thus, entering "3+4*5=" results in "23", not "35". The parentheses can be used to override this. For example, "(1+2+3)*(4+5+6)=" results in "6*15=90".
The entire number in the calculator display can be selected, in order to paste the result of a calculation into text.
The action procedures associated with each function are given below. These are useful if you are interested in defining a custom calculator. The action used for all digit keys is digit(n) , where n is the corresponding digit, 0..9.
Calculator Key Usage (RPN mode): The number keys, CHS (change sign), +, -, *, /, and ENTR keys all do exactly what you would expect them to do. Many of the remaining keys are the same as in TI mode. The differences are detailed below. The action procedure for the ENTR key is enter().
Finally, there are two additional action procedures: bell(), which rings the bell; and selection(), which performs a cut on the entire number in the calculator's ``liquid crystal'' display.
Accelerators are shortcuts for entering commands. xcalc provides some sample keyboard accelerators; also users can customize accelerators. The numeric keypad accelerators provided by xcalc should be intuitively correct. The accelerators defined by xcalc on the main keyboard are given below:
TI Key HP Key Keyboard Accelerator TI Function HP Function SQRT SQRT r squareRoot() squareRoot() AC ON space clear() clear() AC <- Delete clear() back() AC <- Backspace clear() back() AC <- Control-H clear() back() AC Clear clear() AC ON q quit() quit() AC ON Control-C quit() quit() INV i i inverse() inverse() sin s s sine() sine() cos c c cosine() cosine() tan t t tangent() tangent() DRG DRG d degree() degree() e e e() ln ln l naturalLog() naturalLog() y^x y^x ^ power() power() PI PI p pi() pi() x! x! ! factorial() factorial() ( ( leftParen() ) ) rightParen() / / / divide() divide() * * * multiply() multiply() - - - subtract() subtract() + + + add() add() = = equal() 0..9 0..9 0..9 digit() digit() . . . decimal() decimal() +/- CHS n negate() negate() x:y x XexchangeY() ENTR Return enter() ENTR Linefeed enter()
xcalc has an enormous application defaults file which specifies the position, label, and function of each key on the calculator. It also gives translations to serve as keyboard accelerators. Because these resources are not specified in the source code, you can create a customized calculator by writing a private application defaults file, using the Athena Command and Form widget resources to specify the size and position of buttons, the label for each button, and the function of each button.
The foreground and background colors of each calculator key can be individually specified. For the TI calculator, a classical color resource specification might be:
For each of buttons 20, 25, 30, 35, and
For each of buttons 22, 23, 24, 27, 28,
29, 32, 33, 34, 37, 38, and 39:
XCalc xcalc Form ti or hp (the name depends on the mode) Form bevel Form screen Label M Toggle LCD Label INV Label DEG Label RAD Label GRAD Label P Command button1 Command button2 Command button3 and so on, ... Command button38 Command button39 Command button40
This will cause xcalc to pick up the colors in the app-defaults color customization file: /usr/X11R6/lib/X11/app-defaults/XCalc-color.
HP mode is not completely debugged. In particular, the stack is not handled properly after errors.
Table of Contents