Get operations working with the calculator interface
This commit is contained in:
parent
e05b0726f1
commit
53891274f1
1425
src/calc.rs
1425
src/calc.rs
File diff suppressed because it is too large
Load Diff
1466
src/calc/entries.rs
1466
src/calc/entries.rs
File diff suppressed because it is too large
Load Diff
@ -3,61 +3,64 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum ArithmeticOperation {
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide,
|
||||
Negate,
|
||||
AbsoluteValue,
|
||||
Inverse,
|
||||
Modulo,
|
||||
IntegerDivide,
|
||||
Sin,
|
||||
Cos,
|
||||
Tan,
|
||||
ASin,
|
||||
ACos,
|
||||
ATan,
|
||||
Sqrt,
|
||||
Pow,
|
||||
Log,
|
||||
Ln,
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide,
|
||||
Negate,
|
||||
AbsoluteValue,
|
||||
Inverse,
|
||||
Modulo,
|
||||
IntegerDivide,
|
||||
Sin,
|
||||
Cos,
|
||||
Tan,
|
||||
ASin,
|
||||
ACos,
|
||||
ATan,
|
||||
Sqrt,
|
||||
Pow,
|
||||
Log,
|
||||
Ln,
|
||||
}
|
||||
/// Operations that can be sent to the calculator such as +, -, or undo
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum CalculatorOperation {
|
||||
ArithmeticOperation(ArithmeticOperation),
|
||||
Undo,
|
||||
Redo,
|
||||
Drop,
|
||||
Dup,
|
||||
Swap,
|
||||
Macro(MacroState),
|
||||
ArithmeticOperation(ArithmeticOperation),
|
||||
BuildVector,
|
||||
Undo,
|
||||
Redo,
|
||||
Drop,
|
||||
Dup,
|
||||
Swap,
|
||||
Macro(MacroState),
|
||||
}
|
||||
|
||||
/// Macro bundary; defined by the start or end of a macro invocation
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum MacroState {
|
||||
Start,
|
||||
End,
|
||||
Start,
|
||||
End,
|
||||
}
|
||||
|
||||
/// Arguments for a given operation
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum OpArgs {
|
||||
/// This is a macro start and end noop
|
||||
Macro(MacroState),
|
||||
/// Operation takes 1 argument, ex: sqrt or negate
|
||||
Unary(Entry),
|
||||
/// Operation takes 2 arguments, ex: + or -
|
||||
Binary([Entry; 2]),
|
||||
/// Operation takes no arguments, ex: push
|
||||
None,
|
||||
/// This is a macro start and end noop
|
||||
Macro(MacroState),
|
||||
/// Operation takes 1 argument, ex: sqrt or negate
|
||||
Unary(Entry),
|
||||
/// Operation takes 2 arguments, ex: + or -
|
||||
Binary([Entry; 2]),
|
||||
/// Some variable number of changes
|
||||
Variable(Vec<Entry>),
|
||||
/// Operation takes no arguments, ex: push
|
||||
None,
|
||||
}
|
||||
|
||||
/// Record of what to pop and push. Used for undo and redo buffers
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub struct CalculatorStateChange {
|
||||
pub pop: OpArgs,
|
||||
pub push: OpArgs,
|
||||
pub pop: OpArgs,
|
||||
pub push: OpArgs,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user