# User:Woozle/software/design specs/FerretCalc

I actually have a working version of this written in Gambas, but it had some bugs, I think?

If nothing else, maybe the operations (+,=) should go to the right of the numbers (ideally, that should be a user preference).

Size, color of "tape" font should be adjustable.

## Operation Spec

### Visible Components

The main window consists of two main parts:

• the operation area, shown on the left:
• ED - entry display (black rectangle at the top) - interactively shows entry of the current value to be applied
• virtual keypad (buttons below that)
• the results area, shown on the right:
• OD - operation display (black rectangle at the top) - shows the value to be operated on, and what binary operation (+,-,x, etc.) will be done on it
• OH - operation history, aka "the tape" - shows values, what operations were done on them, and what the resulting value was for each, in chronological order (newest at the bottom)

### Keyboard

The graphical keyboard acts just like any virtual keyboard: items clicked act as if they had been typed on a physical keyboard. Preferably, typing a key on the physical keyboard should cause some visible action on the virtual keyboard, but this is optional.

Digits and operations entered on either (physical or virtual) keyboard appear on the entry display (top left black box), shifting from right to left (i.e. text is entered left-to-right by stays right-aligned).

### Specialized Keys

• Operator keys (+,-,x...): when one of these is pressed, the value in the ED is moved to the OD, the operation selected is shown in the OD, and the ED is cleared.
• The `=` (equals) key causes the value in the ED to be applied to the value shown in the OD, using the operator shown in the OD. The ED value is appended to the OH, along with the operation shown in the OD. The resulting (calculated) value is appended to the OH as well (along with the "=" operation, and preferably a clear visual indicator which ultimately should be user-configurable). Each "append" means a new line in the OH.
• The physical-keyboard `[Enter]` key acts just like the `[=]` key.
• The `[C]` key clears the current number entry but not the current operation.
• Example: typing `10+20[C]` leaves you with "10 +" in the operation display
• The `[CO]` key clears the current operation but not the previous value.
• Example: typiing `10+20[CE]` clears the operation display and leaves you with "10" in the entry display
• The `[CA]` key clears all (everything) from entry and operation displays, allowing you to start a fresh operation.

### Logic

There are basically three main states, and a flag for "binary operation in progress" (OiP - meaning a first operand and a binary operator have both been entered).

• state 1: after [=] is pressed, or when the program is first loaded
• state 2: after a numeric key has been pressed
• state 3: after a binary operation key is pressed

#### in state 1

• if a numeric key is pressed:
• the result is cleared
• the ED shows the key pressed
• ...and we go to state 2.
• if a binary operator key is pressed:
• the current ED contents become the first operand for the binary operator entered
• the ED value is moved to the OD
• the operator entered is shown on the OD
• set the OiP flag
• ...and we go to state 3
• if [=] is pressed (again), nothing changes

#### in state 2

• if a numeric key is pressed, that key is appended to the ED, and we stay in state 2
• if a binary operator key is pressed, the same actions as in state 1
• if [=] is pressed...
• if a binary operation is in progress, then the calculation is done, we show the result in the ED, and we go to state 1
• if no binary operation is in progress, then nothing happens (stay in state 2)

#### in state 3

• if a numeric key is pressed, the same actions as in state 2 (and we go to state 2)
• if a binary operator key is pressed: this is sort of a "why would you", but let's say it overwrites the previous operator, and we stay in state 3
• if [=] is pressed... this is another "why would you", but let's say treat it like an operator -- so:
• remove the operator
• clear the OiP flag
• go to state 1

The above logic is a first-pass attempt; it may contain bugs.

## Future Feature Wishlist

• scientific notation support
• skinning
• results in binary fractions (halves, quarters, eighths...) for carpentry
• different entry modes (Polish notation)
• implied parentheses (requires visual stack)
• decimal rounding options