2006-11-25 13:07:29 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 1989 X Consortium
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of the X Consortium shall
|
|
|
|
not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
other dealings in this Software without prior written authorization
|
|
|
|
from the X Consortium.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* actions.c - externally available procedures for xcalc
|
|
|
|
*
|
|
|
|
* Author: Donna Converse, MIT X Consortium
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/Intrinsic.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include "xcalc.h"
|
|
|
|
|
|
|
|
#ifndef IEEE
|
|
|
|
#define XCALC_PRE_OP(keynum) { if (pre_op(keynum)) return; \
|
|
|
|
if (setjmp (env)) {fail_op(); return;}}
|
|
|
|
#else
|
|
|
|
#define XCALC_PRE_OP(keynum) if (pre_op(keynum)) return;
|
|
|
|
#endif
|
|
|
|
|
2015-01-25 04:34:27 -07:00
|
|
|
static void add(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void and(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void back(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void base(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void bell(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void clearit(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void cosine(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void decimal(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void degree(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void digit(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void divide(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void e(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void enter(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void epower(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void equal(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void exchange(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void factorial(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void inverse(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void leftParen(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void logarithm(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void mod(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void multiply(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void naturalLog(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void negate(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void nop(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void not(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void off(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void or(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void pi(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void power(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void quit(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void recall(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void reciprocal(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void rightParen(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void roll(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void scientific(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void selection(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void shl(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void shr(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void sine(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void square(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void squareRoot(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void store(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void subtract(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void sum(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void tangent(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void tenpower(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2019-08-15 11:13:47 -06:00
|
|
|
static void xtrunc(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
|
|
|
static void xor(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2015-01-25 04:34:27 -07:00
|
|
|
static void XexchangeY(Widget w, XEvent *ev, String *vector, Cardinal *count);
|
2010-03-28 02:02:57 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* calculator action table
|
|
|
|
*/
|
|
|
|
|
|
|
|
XtActionsRec Actions[] = {
|
|
|
|
{"add", add}, /* addition */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"and", and}, /* bitwise and */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"back", back}, /* HP-specific backspace */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"base", base}, /* base conversion */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"bell", bell}, /* ring bell */
|
|
|
|
{"clear", clearit}, /* TI-specific clear calculator state */
|
|
|
|
{"cosine", cosine}, /* trigonometric function cosine */
|
|
|
|
{"decimal", decimal}, /* decimal point */
|
|
|
|
{"degree", degree}, /* degree, radian, grad switch */
|
|
|
|
{"digit", digit}, /* numeric key */
|
|
|
|
{"divide", divide}, /* division */
|
|
|
|
{"e", e}, /* the natural number e */
|
|
|
|
{"enter", enter}, /* HP-specific enter */
|
|
|
|
{"epower", epower}, /* e raised to a power */
|
|
|
|
{"equal", equal}, /* TI-specific = */
|
|
|
|
{"exchange", exchange}, /* TI-specific exchange memory and display */
|
|
|
|
{"factorial", factorial}, /* factorial function */
|
|
|
|
{"inverse", inverse}, /* inverse */
|
|
|
|
{"leftParen", leftParen}, /* TI-specific left parenthesis */
|
|
|
|
{"logarithm", logarithm}, /* logarithm base 10 */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"mod", mod}, /* modulus */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"multiply", multiply}, /* multiplication */
|
|
|
|
{"naturalLog", naturalLog}, /* natural logarithm base e */
|
|
|
|
{"negate", negate}, /* change sign */
|
|
|
|
{"nop", nop}, /* no operation, rings bell */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"not", not}, /* bitwise not */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"off", off}, /* clear state */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"or", or}, /* bitwise or */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"pi", pi}, /* the number pi */
|
|
|
|
{"power", power}, /* raise to an arbitrary power */
|
|
|
|
{"quit", quit}, /* quit */
|
|
|
|
{"recall", recall}, /* memory recall */
|
|
|
|
{"reciprocal", reciprocal}, /* reciprocal function */
|
|
|
|
{"rightParen", rightParen}, /* TI-specific left parenthesis */
|
|
|
|
{"roll", roll}, /* HP-specific roll stack */
|
|
|
|
{"scientific", scientific}, /* scientfic notation (EE) */
|
|
|
|
{"selection", selection}, /* copy selection */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"shl", shl}, /* arithmetic shift left */
|
|
|
|
{"shr", shr}, /* arithmetic shift right */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"sine", sine}, /* trigonometric function sine */
|
|
|
|
{"square", square}, /* square */
|
|
|
|
{"squareRoot", squareRoot}, /* square root */
|
|
|
|
{"store", store}, /* memory store */
|
|
|
|
{"subtract", subtract}, /* subtraction */
|
|
|
|
{"sum", sum}, /* memory summation */
|
|
|
|
{"tangent", tangent}, /* trigonometric function tangent */
|
|
|
|
{"tenpower", tenpower}, /* 10 raised to to an arbitrary power */
|
2019-08-15 11:13:47 -06:00
|
|
|
{"trunc", xtrunc}, /* truncate to integer */
|
|
|
|
{"xor", xor}, /* bitwise xor */
|
2010-03-28 02:02:57 -06:00
|
|
|
{"XexchangeY", XexchangeY} /* HP-specific exchange X and Y registers */
|
|
|
|
};
|
|
|
|
|
|
|
|
int ActionsCount = XtNumber(Actions);
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void add(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kADD);
|
|
|
|
rpn ? twof(kADD) : twoop(kADD);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void and(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kAND);
|
|
|
|
rpn ? twof(kAND) : twoop(kAND);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void back(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kBKSP);
|
|
|
|
bkspf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void base(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kBASE);
|
|
|
|
change_base();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void bell(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
ringbell();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void clearit(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kCLR);
|
|
|
|
clearf();
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void cosine(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kCOS);
|
|
|
|
oneop(kCOS);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void decimal(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kDEC);
|
|
|
|
decf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void degree(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kDRG);
|
|
|
|
drgf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void digit(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
switch (vector[0][0])
|
|
|
|
{
|
2019-08-15 11:13:47 -06:00
|
|
|
case '0': XCALC_PRE_OP(kZERO); numeric(kZERO); break;
|
2006-11-25 13:07:29 -07:00
|
|
|
case '1': XCALC_PRE_OP(kONE); numeric(kONE); break;
|
|
|
|
case '2': XCALC_PRE_OP(kTWO); numeric(kTWO); break;
|
|
|
|
case '3': XCALC_PRE_OP(kTHREE); numeric(kTHREE); break;
|
|
|
|
case '4': XCALC_PRE_OP(kFOUR); numeric(kFOUR); break;
|
|
|
|
case '5': XCALC_PRE_OP(kFIVE); numeric(kFIVE); break;
|
|
|
|
case '6': XCALC_PRE_OP(kSIX); numeric(kSIX); break;
|
|
|
|
case '7': XCALC_PRE_OP(kSEVEN); numeric(kSEVEN); break;
|
|
|
|
case '8': XCALC_PRE_OP(kEIGHT); numeric(kEIGHT); break;
|
|
|
|
case '9': XCALC_PRE_OP(kNINE); numeric(kNINE); break;
|
2019-08-15 11:13:47 -06:00
|
|
|
case 'A': XCALC_PRE_OP(kxA); numeric(kxA); break;
|
|
|
|
case 'B': XCALC_PRE_OP(kxB); numeric(kxB); break;
|
|
|
|
case 'C': XCALC_PRE_OP(kxC); numeric(kxC); break;
|
|
|
|
case 'D': XCALC_PRE_OP(kxD); numeric(kxD); break;
|
|
|
|
case 'E': XCALC_PRE_OP(kxE); numeric(kxE); break;
|
|
|
|
case 'F': XCALC_PRE_OP(kxF); numeric(kxF); break;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void divide(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kDIV);
|
|
|
|
rpn ? twof(kDIV) : twoop(kDIV);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void e(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kE);
|
|
|
|
oneop(kE);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void enter(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kENTR);
|
|
|
|
entrf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void epower(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kEXP);
|
|
|
|
oneop(kEXP);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void equal(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kEQU);
|
|
|
|
equf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void exchange(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kEXC);
|
|
|
|
oneop(kEXC);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void factorial(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kFACT);
|
|
|
|
oneop(kFACT);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void inverse(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kINV);
|
|
|
|
invf();
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void leftParen(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kLPAR);
|
|
|
|
lparf();
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void logarithm(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kLOG);
|
|
|
|
oneop(kLOG);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void mod(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kMOD);
|
|
|
|
rpn ? twof(kMOD) : twoop(kMOD);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void multiply(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kMUL);
|
|
|
|
rpn ? twof(kMUL) : twoop(kMUL);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void naturalLog(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kLN);
|
|
|
|
oneop(kLN);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void negate(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kNEG);
|
|
|
|
negf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void nop(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
ringbell();
|
|
|
|
}
|
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void not(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kNOT);
|
|
|
|
oneop(kNOT);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void off(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kOFF);
|
|
|
|
offf();
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void or(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kOR);
|
|
|
|
rpn ? twof(kOR) : twoop(kOR);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void pi(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kPI);
|
|
|
|
oneop(kPI);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void power(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kPOW);
|
|
|
|
rpn ? twof(kPOW) : twoop(kPOW);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void quit(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2019-08-15 11:13:47 -06:00
|
|
|
if (ev->type == ClientMessage &&
|
|
|
|
((Atom) ev->xclient.data.l[0]) != wm_delete_window)
|
2006-11-25 13:07:29 -07:00
|
|
|
ringbell();
|
|
|
|
else
|
|
|
|
Quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void recall(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kRCL);
|
|
|
|
rpn ? memf(kRCL) : oneop(kRCL);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void reciprocal(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kRECIP);
|
|
|
|
oneop(kRECIP);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void rightParen(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kRPAR);
|
|
|
|
rparf();
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void roll(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kROLL);
|
|
|
|
rollf();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void scientific(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kEE);
|
|
|
|
eef();
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void selection(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2015-01-25 04:34:27 -07:00
|
|
|
do_select(((XButtonReleasedEvent *)ev)->time);
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void shl(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSHL);
|
|
|
|
rpn ? twof(kSHL) : twoop(kSHL);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
static void shr(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSHR);
|
|
|
|
rpn ? twof(kSHR) : twoop(kSHR);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void sine(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSIN);
|
|
|
|
oneop(kSIN);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void square(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSQR);
|
|
|
|
oneop(kSQR);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void squareRoot(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSQRT);
|
|
|
|
oneop(kSQRT);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void store(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSTO);
|
|
|
|
rpn ? memf(kSTO) : oneop(kSTO);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void subtract(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSUB);
|
|
|
|
rpn ? twof(kSUB) : twoop(kSUB);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void sum(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kSUM);
|
|
|
|
rpn ? memf(kSUM) : oneop(kSUM);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void tangent(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kTAN);
|
|
|
|
oneop(kTAN);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void tenpower(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(k10X);
|
|
|
|
oneop(k10X);
|
|
|
|
post_op();
|
|
|
|
}
|
2013-03-09 08:04:53 -07:00
|
|
|
|
2019-08-15 11:13:47 -06:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void xtrunc(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kTRUNC);
|
|
|
|
oneop(kTRUNC);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
static void xor(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kXOR);
|
|
|
|
rpn ? twof(kXOR) : twoop(kXOR);
|
|
|
|
post_op();
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:29 -07:00
|
|
|
/*ARGSUSED*/
|
2015-01-25 04:34:27 -07:00
|
|
|
static void XexchangeY(Widget w, XEvent *ev, String *vector, Cardinal *count)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
|
|
|
XCALC_PRE_OP(kXXY);
|
|
|
|
twof(kXXY);
|
|
|
|
post_op();
|
|
|
|
}
|