diff options
Diffstat (limited to 'actions.c')
-rw-r--r-- | actions.c | 98 |
1 files changed, 97 insertions, 1 deletions
@@ -46,7 +46,9 @@ from the X Consortium. #endif static void add(Widget w, XEvent *ev, String *vector, Cardinal *count); +static void and(Widget w, XEvent *ev, String *vector, Cardinal *count); static void back(Widget w, XEvent *ev, String *vector, Cardinal *count); +static void base(Widget w, XEvent *ev, String *vector, Cardinal *count); 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); @@ -63,11 +65,14 @@ 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); +static void mod(Widget w, XEvent *ev, String *vector, Cardinal *count); 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); +static void not(Widget w, XEvent *ev, String *vector, Cardinal *count); static void off(Widget w, XEvent *ev, String *vector, Cardinal *count); +static void or(Widget w, XEvent *ev, String *vector, Cardinal *count); 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); @@ -77,6 +82,8 @@ 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); +static void shl(Widget w, XEvent *ev, String *vector, Cardinal *count); +static void shr(Widget w, XEvent *ev, String *vector, Cardinal *count); 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); @@ -85,6 +92,8 @@ 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); +static void xtrunc(Widget w, XEvent *ev, String *vector, Cardinal *count); +static void xor(Widget w, XEvent *ev, String *vector, Cardinal *count); static void XexchangeY(Widget w, XEvent *ev, String *vector, Cardinal *count); /* @@ -93,7 +102,9 @@ static void XexchangeY(Widget w, XEvent *ev, String *vector, Cardinal *count); XtActionsRec Actions[] = { {"add", add}, /* addition */ +{"and", and}, /* bitwise and */ {"back", back}, /* HP-specific backspace */ +{"base", base}, /* base conversion */ {"bell", bell}, /* ring bell */ {"clear", clearit}, /* TI-specific clear calculator state */ {"cosine", cosine}, /* trigonometric function cosine */ @@ -110,11 +121,14 @@ XtActionsRec Actions[] = { {"inverse", inverse}, /* inverse */ {"leftParen", leftParen}, /* TI-specific left parenthesis */ {"logarithm", logarithm}, /* logarithm base 10 */ +{"mod", mod}, /* modulus */ {"multiply", multiply}, /* multiplication */ {"naturalLog", naturalLog}, /* natural logarithm base e */ {"negate", negate}, /* change sign */ {"nop", nop}, /* no operation, rings bell */ +{"not", not}, /* bitwise not */ {"off", off}, /* clear state */ +{"or", or}, /* bitwise or */ {"pi", pi}, /* the number pi */ {"power", power}, /* raise to an arbitrary power */ {"quit", quit}, /* quit */ @@ -124,6 +138,8 @@ XtActionsRec Actions[] = { {"roll", roll}, /* HP-specific roll stack */ {"scientific", scientific}, /* scientfic notation (EE) */ {"selection", selection}, /* copy selection */ +{"shl", shl}, /* arithmetic shift left */ +{"shr", shr}, /* arithmetic shift right */ {"sine", sine}, /* trigonometric function sine */ {"square", square}, /* square */ {"squareRoot", squareRoot}, /* square root */ @@ -132,6 +148,8 @@ XtActionsRec Actions[] = { {"sum", sum}, /* memory summation */ {"tangent", tangent}, /* trigonometric function tangent */ {"tenpower", tenpower}, /* 10 raised to to an arbitrary power */ +{"trunc", xtrunc}, /* truncate to integer */ +{"xor", xor}, /* bitwise xor */ {"XexchangeY", XexchangeY} /* HP-specific exchange X and Y registers */ }; @@ -146,6 +164,14 @@ static void add(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*ARGSUSED*/ +static void and(Widget w, XEvent *ev, String *vector, Cardinal *count) +{ + XCALC_PRE_OP(kAND); + rpn ? twof(kAND) : twoop(kAND); + post_op(); +} + +/*ARGSUSED*/ static void back(Widget w, XEvent *ev, String *vector, Cardinal *count) { XCALC_PRE_OP(kBKSP); @@ -154,6 +180,14 @@ static void back(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*ARGSUSED*/ +static void base(Widget w, XEvent *ev, String *vector, Cardinal *count) +{ + XCALC_PRE_OP(kBASE); + change_base(); + post_op(); +} + +/*ARGSUSED*/ static void bell(Widget w, XEvent *ev, String *vector, Cardinal *count) { ringbell(); @@ -196,6 +230,7 @@ static void digit(Widget w, XEvent *ev, String *vector, Cardinal *count) { switch (vector[0][0]) { + case '0': XCALC_PRE_OP(kZERO); numeric(kZERO); break; 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; @@ -205,7 +240,12 @@ static void digit(Widget w, XEvent *ev, String *vector, Cardinal *count) 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; - case '0': XCALC_PRE_OP(kZERO); numeric(kZERO); break; + 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; } post_op(); } @@ -291,6 +331,14 @@ static void logarithm(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*ARGSUSED*/ +static void mod(Widget w, XEvent *ev, String *vector, Cardinal *count) +{ + XCALC_PRE_OP(kMOD); + rpn ? twof(kMOD) : twoop(kMOD); + post_op(); +} + +/*ARGSUSED*/ static void multiply(Widget w, XEvent *ev, String *vector, Cardinal *count) { XCALC_PRE_OP(kMUL); @@ -321,6 +369,14 @@ static void nop(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*ARGSUSED*/ +static void not(Widget w, XEvent *ev, String *vector, Cardinal *count) +{ + XCALC_PRE_OP(kNOT); + oneop(kNOT); + post_op(); +} + +/*ARGSUSED*/ static void off(Widget w, XEvent *ev, String *vector, Cardinal *count) { XCALC_PRE_OP(kOFF); @@ -329,6 +385,14 @@ static void off(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*ARGSUSED*/ +static void or(Widget w, XEvent *ev, String *vector, Cardinal *count) +{ + XCALC_PRE_OP(kOR); + rpn ? twof(kOR) : twoop(kOR); + post_op(); +} + +/*ARGSUSED*/ static void pi(Widget w, XEvent *ev, String *vector, Cardinal *count) { XCALC_PRE_OP(kPI); @@ -400,6 +464,22 @@ static void selection(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*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(); +} + +/*ARGSUSED*/ static void sine(Widget w, XEvent *ev, String *vector, Cardinal *count) { XCALC_PRE_OP(kSIN); @@ -464,6 +544,22 @@ static void tenpower(Widget w, XEvent *ev, String *vector, Cardinal *count) } /*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(); +} + +/*ARGSUSED*/ static void XexchangeY(Widget w, XEvent *ev, String *vector, Cardinal *count) { XCALC_PRE_OP(kXXY); |