Skip to content

Commit

Permalink
effective deletion of unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
geremachek committed Nov 1, 2021
1 parent 66b0651 commit 4d6c901
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions stack/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func parseValue(v string) (float64, error) {

// parse commands...

func (s *Stack) parseCommand(c cmd.Command) (err error) {
func (s *Stack) parseCommand(c cmd.Command) {
switch c {
case cmd.Pop: s.pop()
case cmd.Swap: s.swap()
Expand Down Expand Up @@ -51,8 +51,6 @@ func (s *Stack) parseCommand(c cmd.Command) (err error) {
case cmd.Atan: s.operateSingle(s.atan)
case cmd.Fact: s.operateSingle(ari.FactW)
}

return
}

// value... command... error? Deal with them all!
Expand Down
12 changes: 6 additions & 6 deletions ui/linebuff.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (
)

type lineBuff struct {
buffer string
buffer []rune

locX int
locY int
}

func newLineBuff(x, y int) *lineBuff {
return &lineBuff { "", x, y }
return &lineBuff { nil, x, y }
}


func (lb lineBuff) text() string {
return lb.buffer
return string(lb.buffer)
}

// show our cursor
Expand All @@ -30,7 +30,7 @@ func (lb lineBuff) showPos(s tcell.Screen) {
// add a char...

func (lb *lineBuff) push(s tcell.Screen, ch rune) {
lb.buffer += string(ch)
lb.buffer = append(lb.buffer, ch)
s.SetContent(lb.locX, lb.locY, ch, []rune(""), tcell.StyleDefault)

// move and show the cursor
Expand All @@ -43,7 +43,7 @@ func (lb *lineBuff) push(s tcell.Screen, ch rune) {

func (lb *lineBuff) delete(s tcell.Screen) {
if l := len(lb.buffer); l > 0 { // buffer is not empty
lb.buffer = lb.buffer[:l-1] // remove the char
lb.buffer = lb.buffer[:l-1]
lb.locX-- // move curs back

// erase it from the screen
Expand All @@ -63,7 +63,7 @@ func (lb *lineBuff) refresh(s tcell.Screen) {
// reset and show the cursor

lb.locX = 0
lb.buffer = ""
lb.buffer = nil

lb.showPos(s)
}

0 comments on commit 4d6c901

Please sign in to comment.