aboutsummaryrefslogtreecommitdiff
path: root/apps/xcalc/actions.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-12-26 20:18:03 +0000
committermarha <marha@users.sourceforge.net>2010-12-26 20:18:03 +0000
commitf28d4c94798d88757227b8c517a05a6ca354dc6f (patch)
tree41ef20b85d86516051d7cac98c77a13a58a227ff /apps/xcalc/actions.c
parent98a38f8fe605b90577b7a07f68b8a0866dd18a15 (diff)
downloadvcxsrv-f28d4c94798d88757227b8c517a05a6ca354dc6f.tar.gz
vcxsrv-f28d4c94798d88757227b8c517a05a6ca354dc6f.tar.bz2
vcxsrv-f28d4c94798d88757227b8c517a05a6ca354dc6f.zip
Update to xcalc-1.0.4.1
Diffstat (limited to 'apps/xcalc/actions.c')
-rw-r--r--apps/xcalc/actions.c348
1 files changed, 135 insertions, 213 deletions
diff --git a/apps/xcalc/actions.c b/apps/xcalc/actions.c
index 37c57361e..5968feba3 100644
--- a/apps/xcalc/actions.c
+++ b/apps/xcalc/actions.c
@@ -1,4 +1,3 @@
-/* $XConsortium: actions.c,v 1.9 94/04/17 20:43:30 converse Exp $ */
/*
Copyright (c) 1989 X Consortium
@@ -38,26 +37,109 @@ from the X Consortium.
#include <X11/Intrinsic.h>
#include <setjmp.h>
#include "xcalc.h"
-extern int rpn;
-extern Atom wm_delete_window;
-extern int pre_op();
-extern void post_op(), Quit(), ringbell(), do_select();
#ifndef IEEE
-extern jmp_buf env;
-extern void fail_op();
#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
-/*ARGSUSED*/
-void add(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void add(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void back(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void bell(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void clearit(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void cosine(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void decimal(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void degree(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void digit(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void divide(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void e(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void enter(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void epower(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void equal(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void exchange(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void factorial(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void inverse(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void leftParen(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void logarithm(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void multiply(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void naturalLog(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void factorial(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void negate(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void nop(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void off(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void pi(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void power(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void quit(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void recall(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void reciprocal(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void rightParen(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void roll(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void scientific(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void selection(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void sine(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void square(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void squareRoot(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void store(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void subtract(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void sum(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void tangent(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void tenpower(Widget w, XEvent *e, String *vector, Cardinal *count);
+static void XexchangeY(Widget w, XEvent *e, String *vector, Cardinal *count);
+
+/*
+ * calculator action table
+ */
+
+XtActionsRec Actions[] = {
+{"add", add}, /* addition */
+{"back", back}, /* HP-specific backspace */
+{"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 */
+{"multiply", multiply}, /* multiplication */
+{"naturalLog", naturalLog}, /* natural logarithm base e */
+{"negate", negate}, /* change sign */
+{"nop", nop}, /* no operation, rings bell */
+{"off", off}, /* clear state */
+{"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 */
+{"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 */
+{"XexchangeY", XexchangeY} /* HP-specific exchange X and Y registers */
+};
+
+int ActionsCount = XtNumber(Actions);
+
+/*ARGSUSED*/
+static void add(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kADD);
rpn ? twof(kADD) : twoop(kADD);
@@ -65,11 +147,7 @@ void add(w, e, vector, count)
}
/*ARGSUSED*/
-void back(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void back(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kBKSP);
bkspf();
@@ -77,21 +155,13 @@ void back(w, e, vector, count)
}
/*ARGSUSED*/
-void bell(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void bell(Widget w, XEvent *e, String *vector, Cardinal *count)
{
ringbell();
}
/*ARGSUSED*/
-void clearit(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void clearit(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kCLR);
clearf();
@@ -99,11 +169,7 @@ void clearit(w, e, vector, count)
}
/*ARGSUSED*/
-void cosine(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void cosine(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kCOS);
oneop(kCOS);
@@ -111,11 +177,7 @@ void cosine(w, e, vector, count)
}
/*ARGSUSED*/
-void decimal(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void decimal(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kDEC);
decf();
@@ -123,11 +185,7 @@ void decimal(w, e, vector, count)
}
/*ARGSUSED*/
-void degree(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void degree(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kDRG);
drgf();
@@ -135,11 +193,7 @@ void degree(w, e, vector, count)
}
/*ARGSUSED*/
-void digit(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void digit(Widget w, XEvent *e, String *vector, Cardinal *count)
{
switch (vector[0][0])
{
@@ -158,11 +212,7 @@ void digit(w, e, vector, count)
}
/*ARGSUSED*/
-void divide(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void divide(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kDIV);
rpn ? twof(kDIV) : twoop(kDIV);
@@ -170,11 +220,7 @@ void divide(w, e, vector, count)
}
/*ARGSUSED*/
-void e(w, ev, vector, count)
- Widget w;
- XEvent *ev;
- String *vector;
- Cardinal *count;
+static void e(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kE);
oneop(kE);
@@ -182,11 +228,7 @@ void e(w, ev, vector, count)
}
/*ARGSUSED*/
-void enter(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void enter(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kENTR);
entrf();
@@ -194,11 +236,7 @@ void enter(w, e, vector, count)
}
/*ARGSUSED*/
-void epower(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void epower(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kEXP);
oneop(kEXP);
@@ -206,11 +244,7 @@ void epower(w, e, vector, count)
}
/*ARGSUSED*/
-void equal(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void equal(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kEQU);
equf();
@@ -218,11 +252,7 @@ void equal(w, e, vector, count)
}
/*ARGSUSED*/
-void exchange(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void exchange(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kEXC);
oneop(kEXC);
@@ -230,11 +260,7 @@ void exchange(w, e, vector, count)
}
/*ARGSUSED*/
-void factorial(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void factorial(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kFACT);
oneop(kFACT);
@@ -242,11 +268,7 @@ void factorial(w, e, vector, count)
}
/*ARGSUSED*/
-void inverse(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void inverse(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kINV);
invf();
@@ -254,11 +276,7 @@ void inverse(w, e, vector, count)
}
/*ARGSUSED*/
-void leftParen(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void leftParen(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kLPAR);
lparf();
@@ -266,11 +284,7 @@ void leftParen(w, e, vector, count)
}
/*ARGSUSED*/
-void logarithm(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void logarithm(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kLOG);
oneop(kLOG);
@@ -278,11 +292,7 @@ void logarithm(w, e, vector, count)
}
/*ARGSUSED*/
-void multiply(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void multiply(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kMUL);
rpn ? twof(kMUL) : twoop(kMUL);
@@ -290,11 +300,7 @@ void multiply(w, e, vector, count)
}
/*ARGSUSED*/
-void naturalLog(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void naturalLog(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kLN);
oneop(kLN);
@@ -302,11 +308,7 @@ void naturalLog(w, e, vector, count)
}
/*ARGSUSED*/
-void negate(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void negate(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kNEG);
negf();
@@ -314,21 +316,13 @@ void negate(w, e, vector, count)
}
/*ARGSUSED*/
-void nop(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void nop(Widget w, XEvent *e, String *vector, Cardinal *count)
{
ringbell();
}
/*ARGSUSED*/
-void off(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void off(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kOFF);
offf();
@@ -336,11 +330,7 @@ void off(w, e, vector, count)
}
/*ARGSUSED*/
-void pi(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void pi(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kPI);
oneop(kPI);
@@ -348,11 +338,7 @@ void pi(w, e, vector, count)
}
/*ARGSUSED*/
-void power(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void power(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kPOW);
rpn ? twof(kPOW) : twoop(kPOW);
@@ -360,11 +346,7 @@ void power(w, e, vector, count)
}
/*ARGSUSED*/
-void quit(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void quit(Widget w, XEvent *e, String *vector, Cardinal *count)
{
if (e->type == ClientMessage && e->xclient.data.l[0] != wm_delete_window)
ringbell();
@@ -373,11 +355,7 @@ void quit(w, e, vector, count)
}
/*ARGSUSED*/
-void recall(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void recall(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kRCL);
rpn ? memf(kRCL) : oneop(kRCL);
@@ -385,11 +363,7 @@ void recall(w, e, vector, count)
}
/*ARGSUSED*/
-void reciprocal(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void reciprocal(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kRECIP);
oneop(kRECIP);
@@ -397,11 +371,7 @@ void reciprocal(w, e, vector, count)
}
/*ARGSUSED*/
-void rightParen(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void rightParen(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kRPAR);
rparf();
@@ -409,11 +379,7 @@ void rightParen(w, e, vector, count)
}
/*ARGSUSED*/
-void roll(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void roll(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kROLL);
rollf();
@@ -421,11 +387,7 @@ void roll(w, e, vector, count)
}
/*ARGSUSED*/
-void scientific(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void scientific(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kEE);
eef();
@@ -433,21 +395,13 @@ void scientific(w, e, vector, count)
}
/*ARGSUSED*/
-void selection(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void selection(Widget w, XEvent *e, String *vector, Cardinal *count)
{
do_select(((XButtonReleasedEvent *)e)->time);
}
/*ARGSUSED*/
-void sine(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void sine(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kSIN);
oneop(kSIN);
@@ -455,11 +409,7 @@ void sine(w, e, vector, count)
}
/*ARGSUSED*/
-void square(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void square(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kSQR);
oneop(kSQR);
@@ -467,11 +417,7 @@ void square(w, e, vector, count)
}
/*ARGSUSED*/
-void squareRoot(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void squareRoot(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kSQRT);
oneop(kSQRT);
@@ -479,11 +425,7 @@ void squareRoot(w, e, vector, count)
}
/*ARGSUSED*/
-void store(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void store(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kSTO);
rpn ? memf(kSTO) : oneop(kSTO);
@@ -491,11 +433,7 @@ void store(w, e, vector, count)
}
/*ARGSUSED*/
-void subtract(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void subtract(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kSUB);
rpn ? twof(kSUB) : twoop(kSUB);
@@ -503,11 +441,7 @@ void subtract(w, e, vector, count)
}
/*ARGSUSED*/
-void sum(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void sum(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kSUM);
rpn ? memf(kSUM) : oneop(kSUM);
@@ -515,11 +449,7 @@ void sum(w, e, vector, count)
}
/*ARGSUSED*/
-void tangent(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void tangent(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kTAN);
oneop(kTAN);
@@ -527,11 +457,7 @@ void tangent(w, e, vector, count)
}
/*ARGSUSED*/
-void tenpower(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void tenpower(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(k10X);
oneop(k10X);
@@ -539,11 +465,7 @@ void tenpower(w, e, vector, count)
}
/*ARGSUSED*/
-void XexchangeY(w, e, vector, count)
- Widget w;
- XEvent *e;
- String *vector;
- Cardinal *count;
+static void XexchangeY(Widget w, XEvent *e, String *vector, Cardinal *count)
{
XCALC_PRE_OP(kXXY);
twof(kXXY);