Compare commits

..

No commits in common. "afe0ed33cabccfefd84066c17070df35b06d1837" and "17c455b73d90673d4171bad14db58c07ee476f74" have entirely different histories.

39
main.go
View File

@ -84,16 +84,11 @@ func onPress (button stone.Button, modifiers stone.Modifiers) {
redraw()
application.Draw()
case '\\':
insertOperation('?', false, true)
redraw()
application.Draw()
case
'+', '-', '*', '/', 'p', 'P', '%', '|', '~', '&', '^', 'm',
'l', 'r':
insertOperation(rune(button), modifiers.Alt, false)
insertOperation(rune(button), modifiers.Alt)
redraw()
application.Draw()
@ -242,15 +237,6 @@ func onPress (button stone.Button, modifiers stone.Modifiers) {
redraw()
application.Draw()
case 'z':
switch selectedExpression.(type) {
case *Operation, nil:
operation := selectedExpression.(*Operation)
operation.floating = !operation.floating
}
redraw()
application.Draw()
case 'Z':
showFloat = !showFloat
redraw()
@ -258,10 +244,9 @@ func onPress (button stone.Button, modifiers stone.Modifiers) {
}
}
func insertOperation (symbol rune, swap, encompass bool) {
func insertOperation (symbol rune, swap bool) {
var opcode Opcode
switch (symbol) {
case '?': opcode = OpcodeUnknown
case '+': opcode = OpcodeAdd
case '-': opcode = OpcodeSubtract
case '*': opcode = OpcodeMultiply
@ -278,23 +263,6 @@ func insertOperation (symbol rune, swap, encompass bool) {
case 'm': opcode = OpcodeMean
}
newExpression := Operation { opcode: opcode, floating: showFloat }
if encompass {
if selectedExpression == nil { return }
parent := selectedExpression.Parent()
newExpression.Adopt(selectedExpression)
if parent == nil {
expressionRoot = &newExpression
} else {
parent.Swap(selectedExpression, &newExpression)
}
selectedExpression = &newExpression
return
}
operation, isOperation := selectedExpression.(*Operation)
if isOperation {
if operation.opcode == OpcodeUnknown || swap {
@ -303,7 +271,8 @@ func insertOperation (symbol rune, swap, encompass bool) {
}
}
insertGeneric(&newExpression, swap, false, true)
newExpression := &Operation { opcode: opcode, floating: showFloat }
insertGeneric(newExpression, swap, false, true)
}
func insertNumber (value int64, swap, before bool) {