Compare commits

..

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

41
main.go
View File

@ -83,17 +83,12 @@ func onPress (button stone.Button, modifiers stone.Modifiers) {
}, modifiers.Alt, false, false) }, modifiers.Alt, false, false)
redraw() redraw()
application.Draw() application.Draw()
case '\\':
insertOperation('?', false, true)
redraw()
application.Draw()
case case
'+', '-', '*', '/', 'p', 'P', '%', '|', '~', '&', '^', 'm', '+', '-', '*', '/', 'p', 'P', '%', '|', '~', '&', '^', 'm',
'l', 'r': 'l', 'r':
insertOperation(rune(button), modifiers.Alt, false) insertOperation(rune(button), modifiers.Alt)
redraw() redraw()
application.Draw() application.Draw()
@ -242,15 +237,6 @@ func onPress (button stone.Button, modifiers stone.Modifiers) {
redraw() redraw()
application.Draw() application.Draw()
case 'z':
switch selectedExpression.(type) {
case *Operation, nil:
operation := selectedExpression.(*Operation)
operation.floating = !operation.floating
}
redraw()
application.Draw()
case 'Z': case 'Z':
showFloat = !showFloat showFloat = !showFloat
redraw() 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 var opcode Opcode
switch (symbol) { switch (symbol) {
case '?': opcode = OpcodeUnknown
case '+': opcode = OpcodeAdd case '+': opcode = OpcodeAdd
case '-': opcode = OpcodeSubtract case '-': opcode = OpcodeSubtract
case '*': opcode = OpcodeMultiply case '*': opcode = OpcodeMultiply
@ -278,23 +263,6 @@ func insertOperation (symbol rune, swap, encompass bool) {
case 'm': opcode = OpcodeMean 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) operation, isOperation := selectedExpression.(*Operation)
if isOperation { if isOperation {
if operation.opcode == OpcodeUnknown || swap { if operation.opcode == OpcodeUnknown || swap {
@ -302,8 +270,9 @@ func insertOperation (symbol rune, swap, encompass bool) {
return return
} }
} }
insertGeneric(&newExpression, swap, false, true) newExpression := &Operation { opcode: opcode, floating: showFloat }
insertGeneric(newExpression, swap, false, true)
} }
func insertNumber (value int64, swap, before bool) { func insertNumber (value int64, swap, before bool) {