diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-07-28 19:51:09 -0230 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-07-28 19:51:09 -0230 |
| commit | 04ba853e7b9ad245865b6e9b4387d2efc144fc72 (patch) | |
| tree | 1a3b337c08e02dd76546377dc72df30882ad0c11 /ui.go | |
| parent | e89fd14004291f65998b8fa6b5febc2d2fdc52d6 (diff) | |
| download | pfc-04ba853e7b9ad245865b6e9b4387d2efc144fc72.zip | |
rename Calculator.buffer to Calculator.buf
Diffstat (limited to 'ui.go')
| -rw-r--r-- | ui.go | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -40,20 +40,20 @@ func (ui UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "+": ui.calc.add() case "backspace": - if len(ui.calc.buffer) > 0 { - ui.calc.buffer = ui.calc.buffer[:len(ui.calc.buffer)-1] + if len(ui.calc.buf) > 0 { + ui.calc.buf = ui.calc.buf[:len(ui.calc.buf)-1] } case "enter": - if fn := parseFunction(ui.calc.buffer); fn != nil { + if fn := parseFunction(ui.calc.buf); fn != nil { fn(ui.calc.stack) - } else if con := parseConstant(ui.calc.buffer); con != nil { + } else if con := parseConstant(ui.calc.buf); con != nil { ui.calc.stack = append(ui.calc.stack, *con) - } else if f, err := strconv.ParseFloat(ui.calc.buffer, 64); err == nil { + } else if f, err := strconv.ParseFloat(ui.calc.buf, 64); err == nil { ui.calc.stack = append(ui.calc.stack, f) } - ui.calc.buffer = "" + ui.calc.buf = "" default: - ui.calc.buffer += msg.String() + ui.calc.buf += msg.String() } } return ui, nil @@ -65,7 +65,7 @@ func (ui UI) View() string { s += fmt.Sprintf(" %.*g\n", sigDigs, f) } s += boxTop(ui.windowWidth) + "\n" - s += fmt.Sprintf("%[1]c%-*s%[1]c\n", boxVertical, ui.windowWidth-2, ui.calc.buffer) + s += fmt.Sprintf("%[1]c%-*s%[1]c\n", boxVertical, ui.windowWidth-2, ui.calc.buf) s += boxBottom(ui.windowWidth) return s } |