From 3516ab494570f077df967bfe1222acc0dfcdf5da Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Fri, 28 Jul 2023 20:46:24 -0230 Subject: arithmetic operators --- ui.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ui.go') diff --git a/ui.go b/ui.go index 931e8a5..5996a9c 100644 --- a/ui.go +++ b/ui.go @@ -37,8 +37,10 @@ func (ui UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg.String() { case "ctrl+c", "Q": return ui, tea.Quit - case "+": - ui.calc.add() + case "+", "-", "*", "/", "%": + if err := ui.calc.performOp(msg.String()[0]); err != nil { + panic(err) + } case "backspace": if len(ui.calc.buf) > 0 { ui.calc.buf = ui.calc.buf[:len(ui.calc.buf)-1] -- cgit v1.2.3