XCALC(1)

๐Ÿ’– XCALC(1) ๐Ÿ’–

ok so this is the manual page for xcalc, straight out of X Version 11, section 1 of the manual. welcome bestie, let's get you calculator-pilled ๐Ÿงฎโœจ


๐ŸŒธ NAME ๐ŸŒธ

xcalc โ€” a scientific calculator for X. that's it, that's the vibe. it's literally a calculator. for X. slay. ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

xcalc [-stipple] [-rpn] [-toolkitoption...]
xcalc -version
xcalc -help

okay so you've got three whole ways to summon her ๐Ÿ‘‘ โ€” the normal "let me actually do math" invocation, the -version one, and the -help one. no cap.


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

xcalc is a scientific calculator desktop accessory โ€” yes, an accessory, like it's a handbag, and honestly? main character energy ๐ŸŒŸ.

here's the cute part: it can emulate a TI-30 or an HP-10C. two iconic calculators, one little X app. it's giving versatility. it's giving range. ๐Ÿซถ


โœจ OPTIONS โœจ

so xcalc accepts all of the standard toolkit command line options โ€” like, the whole normal X toolkit menu, no notes โ€” along with these extra ones she brings to the group chat:

  • -stipple โ€” this one says: draw the background of the calculator using a stipple</> of the foreground and background colors ๐ŸŽจ. and like, on monochrome displays it improves the appearance. so if you're out here on a black-and-white situation, this is your moment. ๐Ÿ’€
  • -rpn โ€” this flag means Reverse Polish Notation is the move ๐Ÿ”ฅ. in this mode the calculator will look and behave like an HP-10C. without this flag? she emulates a TI-30. that's the whole switch. periodt. โญ
  • -help โ€” this one indicates that xcalc should print its usage message and exit ๐Ÿšช๐Ÿ’จ. very "here's the info, bye bestie" of her.
  • -version โ€” this one indicates that xcalc should print its version and exit ๐Ÿท๏ธโœจ. short, sweet, informative. we love a queen who knows her own version number. ๐Ÿ‘‘
ngl, -help and -version are both super quick exits โ€” they print and they're out, so don't expect a calculator window from those two. ๐Ÿ™ˆ

(more coming, bestie โ€” this was just part 1 ๐Ÿ’œ)

โœจ OPERATION โœจ

okay so pointer time ๐Ÿ–ฑ๏ธ โ€” you can do operations with pointer button 1, or sometimes with the keyboard. A bunch of the common calculator moves 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. ๐Ÿ’…

๐Ÿ–ฑ๏ธ Pointer Usage

Pointer button 1 does the clicking, and some stuff also has keyboard shortcuts. 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 do. No cap. It should be noted that the operators obey the standard rules of precedence. So 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.

  • 1/x โ€” Replaces the number in the display with its reciprocal. The corresponding action procedure is reciprocal(). ๐Ÿ”
  • x^2 โ€” Squares the number in the display. The corresponding action procedure is square(). ๐Ÿ’ฅ
  • SQRT โ€” Takes the square root of the number in the display. The corresponding action procedure is squareRoot(). ๐ŸŒฑ
  • CE/C โ€” When pressed once, clears the number in the display without clearing the state of the machine. Allows you to re-enter a number if you make a mistake. Pressing it twice clears the state, also. The corresponding action procedure for TI mode is clear(). ๐Ÿงน
  • AC โ€” Clears the display, the state, and the memory. Pressing it with the third pointer button turns off the calculator, in that it exits the program. The action procedure to clear the state is off(); to quit, quit(). ๐Ÿ’€
  • INV โ€” Invert function. See the individual function keys for details. The corresponding action procedure is inverse(). ๐Ÿ”„
  • sin โ€” Computes the sine of the number in the display, as interpreted by the current DRG mode (see DRG, below). If inverted, it computes the arcsine. The corresponding action procedure is sine(). ๐ŸŒŠ
  • cos โ€” Computes the cosine, or arccosine when inverted. The corresponding action procedure is cosine(). ๐ŸŒ™
  • tan โ€” Computes the tangent, or arctangent when inverted. The corresponding action procedure is tangent(). โ˜€๏ธ
  • DRG โ€” Changes the DRG mode, as indicated by 'DEG', 'RAD', or 'GRAD' at the bottom of the calculator โ€œliquid crystalโ€ display. When in 'DEG' mode, numbers in the display are taken as being degrees. In 'RAD' mode, numbers are in radians, and in 'GRAD' mode, numbers are in grads. When inverted, the DRG key has a feature of converting degrees to radians to grads and vice-versa. Example: put the calculator into 'DEG' mode, and enter 45 INV DRG. The display should now show something along the lines of .785398, which is 45 degrees converted to radians. The corresponding action procedure is degree(). ๐ŸŽ€
  • e โ€” The constant 'e'. (2.7182818...). The corresponding action procedure is e(). ๐Ÿงš
  • EE โ€” Used for entering exponential numbers. For example, to get -2.3E-4 youโ€™d enter 2 . 3 +/- EE 4 +/-. The corresponding action procedure is scientific(). ๐Ÿ”ฌ
  • log โ€” Calculates the log (base 10) of the number in the display. When inverted, it raises 10.0 to the number in the display. For example, entering 3 INV log should result in 1000. The corresponding action procedure is logarithm(). ๐Ÿ“ˆ
  • ln โ€” Calculates the log (base e) of the number in the display. When inverted, it raises e to the number in the display. For example, entering e ln should result in 1. The corresponding action procedure is naturalLog(). ๐ŸŒฟ
  • y^x โ€” Raises the number on the left to the power of the number on the right. For example 2 y^x 3 = results in 8, which is 2^3. For a further example, (1+2+3) y^x (1+2) = equals 6 y^x 3 which equals 216. The corresponding action procedure is power(). โšก
  • not โ€” Performs a bitwise not. The corresponding action procedure is not(). ๐Ÿšซ
  • and โ€” Performs a bitwise and. The corresponding action procedure is and(). ๐Ÿค
  • or โ€” Performs a bitwise or. The corresponding action procedure is or(). ๐ŸŒˆ
  • xor โ€” Performs a bitwise exclusive or. The corresponding action procedure is xor(). ๐ŸŽญ
  • trunc โ€” Truncates the number in the display to an integer. The corresponding action procedure is trunc(). โœ‚๏ธ
  • PI โ€” The constant 'pi'. (3.1415927....) The corresponding action procedure is pi(). ๐Ÿฅง
  • x! โ€” Computes the factorial of the number in the display. The number in the display must be an integer in the range 0-500, though, depending on your math library, it might overflow long before that. The corresponding action procedure is factorial(). ๐Ÿ˜ญ
  • ( โ€” Left parenthesis. The corresponding action procedure for TI calculators is leftParen(). ๐Ÿซถ
  • ) โ€” Right parenthesis. The corresponding action procedure for TI calculators is rightParen(). ๐Ÿซถ
  • base โ€” Changes the number base, as indicated by 'DEC', 'HEX, or 'OCT' at the bottom of the calculator display. When in 'DEC' mode, numbers in the display are taken as being decimal (base 10). In 'HEX' mode, numbers are in hexadecimal (base 16), and in 'OCT' mode, numbers are in octal (base 8). The corresponding action procedure is base(). ๐Ÿ”ข
  • shl โ€” Performs an arithmetic bitwise shift left. For example, entering 1 shl 2 should result in 4. The corresponding action procedure is shl(). โฌ…๏ธ
  • shr โ€” Performs an arithmetic bitwise shift right. For example, entering 8 shr 1 should result in 4. The corresponding action procedure is shr(). โžก๏ธ
  • mod โ€” Performs the modulo operation, which calculates the remainder when dividing the first number by the second. For example, entering 14 mod 8 should result in 6. The corresponding action procedure is mod(). ๐Ÿฉ
  • / โ€” Division. The corresponding action procedure is divide(). โž—
  • * โ€” Multiplication. The corresponding action procedure is multiply(). โœ–๏ธ
  • - โ€” Subtraction. The corresponding action procedure is subtract(). โž–
  • + โ€” Addition. The corresponding action procedure is add(). โž•
  • = โ€” Perform calculation. The TI-specific action procedure is equal(). ๐ŸŸฐ
  • STO โ€” Copies the number in the display to the memory location. The corresponding action procedure is store(). ๐Ÿ“ฅ
  • RCL โ€” Copies the number from the memory location to the display. The corresponding action procedure is recall(). ๐Ÿ“ค
  • SUM โ€” Adds the number in the display to the number in the memory location. The corresponding action procedure is sum(). ๐Ÿงฎ
  • EXC โ€” Swaps the number in the display with the number in the memory location. The corresponding action procedure for the TI calculator is exchange(). ๐Ÿ”€
  • +/- โ€” Negate; change sign. The corresponding action procedure is negate(). ๐Ÿ”ƒ
  • . โ€” Decimal point. The corresponding action procedure is decimal(). ๐ŸŽฏ

๐Ÿงฎ 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(). ๐Ÿ’–

  • <- โ€” This is a backspace key that can be used if you make a mistake while entering a number. It will erase digits from the display. (See BUGS). Inverse backspace will clear the X register. The corresponding action procedure is back(). โŒซ
  • ON โ€” Clears the display, the state, and the memory. Pressing it with the third pointer button turns off the calculator, in that it exits the program. To clear state, the action procedure is off; to quit, quit(). ๐Ÿ’€
  • INV โ€” Inverts the meaning of the function keys. This would be the f key on an HP calculator, but xcalc does not display multiple legends on each key. See the individual function keys for details. ๐Ÿ”„
  • 10^x โ€” Raises 10.0 to the number in the top of the stack. When inverted, it calculates the log (base 10) of the number in the display. The corresponding action procedure is tenpower(). ๐Ÿ”Ÿ
  • e^x โ€” Raises e to the number in the top of the stack. When inverted, it calculates the log (base e) of the number in the display. The action procedure is epower(). ๐Ÿงš
  • STO โ€” Copies the number in the top of the stack to a memory location. There are 10 memory locations. The desired memory is specified by following this key with a digit key. ๐Ÿ“ฅ
  • RCL โ€” Pushes the number from the specified memory location onto the stack. ๐Ÿ“ค
  • SUM โ€” Adds the number on top of the stack to the number in the specified memory location. ๐Ÿงฎ
  • x:y โ€” Exchanges the numbers in the top two stack positions, the X and Y registers. The corresponding action procedure is XexchangeY(). ๐Ÿ”€
  • R v โ€” Rolls the stack downward. When inverted, it rolls the stack upward. The corresponding action procedure is roll(). ๐ŸŒ€
  • blank โ€” These keys were used for programming functions on the HP-10C. Their functionality has not been duplicated in xcalc. ๐Ÿซฅ

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 ๐Ÿ”ฅ

okay so accelerators are literally shortcuts for entering commands ๐Ÿ’…. xcalc provides some sample keyboard accelerators; users can customize accelerators too. The numeric keypad accelerators provided by xcalc should be intuitively correct (yes, they ate that ๐Ÿ“). The accelerators defined by xcalc on the main keyboard are given below โ€” labels are TI key, HP key, keyboard accelerator, TI function, HP function, bestie:

  • r โ€” TI key: SQRT; HP key: SQRT; TI function: squareRoot(); HP function: squareRoot().
  • space โ€” TI key: AC; HP key: ON; TI function: clear(); HP function: clear().
  • Delete โ€” TI key: AC; HP key: <-; TI function: clear(); HP function: back().
  • Backspace โ€” TI key: AC; HP key: <-; TI function: clear(); HP function: back().
  • Control-H โ€” TI key: AC; HP key: <-; TI function: clear(); HP function: back().
  • Clear โ€” TI key: AC; HP key: (blank); TI function: clear(); HP function: (blank).
  • q โ€” TI key: AC; HP key: ON; TI function: quit(); HP function: quit().
  • Control-C โ€” TI key: AC; HP key: ON; TI function: quit(); HP function: quit().
  • i โ€” TI key: INV; HP key: i; TI function: inverse(); HP function: inverse().
  • s โ€” TI key: sin; HP key: s; TI function: sine(); HP function: sine().
  • c โ€” TI key: cos; HP key: c; TI function: cosine(); HP function: cosine().
  • t โ€” TI key: tan; HP key: t; TI function: tangent(); HP function: tangent().
  • d โ€” TI key: DRG; HP key: DRG; TI function: degree(); HP function: degree().
  • e โ€” TI key: e; HP key: (blank); TI function: e(); HP function: (blank).
  • l โ€” TI key: ln; HP key: ln; TI function: naturalLog(); HP function: naturalLog().
  • ^ โ€” TI key: y^x; HP key: y^x; TI function: power(); HP function: power().
  • p โ€” TI key: PI; HP key: PI; TI function: pi(); HP function: pi().
  • ! โ€” TI key: x!; HP key: x!; TI function: factorial(); HP function: factorial().
  • ( โ€” TI key: (; HP key: (blank); TI function: leftParen(); HP function: (blank).
  • ) โ€” TI key: ); HP key: (blank); TI function: rightParen(); HP function: (blank).
  • / โ€” TI key: /; HP key: /; TI function: divide(); HP function: divide().
  • * โ€” TI key: *; HP key: *; TI function: multiply(); HP function: multiply().
  • - โ€” TI key: -; HP key: -; TI function: subtract(); HP function: subtract().
  • + โ€” TI key: +; HP key: +; TI function: add(); HP function: add().
  • = โ€” TI key: =; HP key: (blank); TI function: equal(); HP function: (blank).
  • 0..9 โ€” TI key: 0..9; HP key: 0..9; TI function: digit(); HP function: digit().
  • . โ€” TI key: .; HP key: .; TI function: decimal(); HP function: decimal().
  • n โ€” TI key: +/-; HP key: CHS; TI function: negate(); HP function: negate().
  • x โ€” TI key: (blank); HP key: x:y; TI function: (blank); HP function: XexchangeY().
  • Return โ€” TI key: (blank); HP key: ENTR; TI function: (blank); HP function: enter().
  • Linefeed โ€” TI key: (blank); HP key: ENTR; TI function: (blank); HP function: enter().

๐Ÿ’– CUSTOMIZATION ๐Ÿ’–

the application class name is XCalc โœจ.

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. slay.

The foreground and background colors of each calculator key can be individually specified. For the TI calculator, a classical color resource specification might be:

XCalc.ti.Command.background:  gray50
XCalc.ti.Command.foreground:  white

For each of buttons 20, 25, 30, 35, and 40, specify:

XCalc.ti.button20.background: black
XCalc.ti.button20.foreground: white

For each of buttons 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, and 39:

XCalc.ti.button22.background: white
XCalc.ti.button22.foreground: black

๐Ÿฆ‹ WIDGET HIERARCHY ๐Ÿฆ‹

In order to specify resources, it is useful to know the hierarchy of the widgets which compose xcalc. In the notation below, indentation indicates hierarchical structure. The widget class name is given first, followed by the widget instance name. iykyk ๐Ÿ’…:

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

๐ŸŒˆ APPLICATION RESOURCES ๐ŸŒˆ

  • rpn (Class Rpn) โ€” specifies that the rpn mode should be used. The default is TI mode. no cap.
  • stipple (Class Stipple) โ€” indicates that the background should be stippled. The default is on for monochrome displays, and off for color displays.
  • cursor (Class Cursor) โ€” the name of the symbol used to represent the pointer. The default is hand2.

๐ŸŽ€ COLORS ๐ŸŽ€

If you would like xcalc to use its TI colors, include the following in the #ifdef COLOR section of the file you read with xrdb:

*customization:                 -color

This will cause xcalc to pick up the colors in the app-defaults color customization file: /usr/share/X11/app-defaults/XCalc-color. periodt ๐Ÿ’….


๐Ÿ” SEE ALSO ๐Ÿ”

Go peek at X(7), xrdb(1), and the Athena Widget Set ๐Ÿ’œ.


๐Ÿ’€ BUGS ๐Ÿ’€

โš ๏ธ HP mode is not completely debugged. In particular, the stack is not handled properly after errors. not me finding out like this ๐Ÿ˜ญ.

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

  • John Bradley, University of Pennsylvania
  • Mark Rosenstein, MIT Project Athena
  • Donna Converse, MIT X Consortium

๐Ÿ’– that's the whole thing: xcalc version 1.1.3, dated 2023-02-05, and you've been reading XCALC(1). go calculate something iconic, bestie ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from