diff options
| author | citrons <citrons@mondecitronne.com> | 2025-05-30 16:45:11 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-05-30 17:46:50 -0500 |
| commit | ecd389a710f6a311bbeaaa36d3437a427c645bd9 (patch) | |
| tree | e7de18bb27f91f29d9aa1643905a6df673ec3e8a /tui | |
| parent | b63957abd9f7c215c944e2478f4b7196e82cc56c (diff) | |
fix redundant cursor control sequences
Diffstat (limited to 'tui')
| -rw-r--r-- | tui/draw.go | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/tui/draw.go b/tui/draw.go index 2584171..3772aa0 100644 --- a/tui/draw.go +++ b/tui/draw.go @@ -149,12 +149,6 @@ func Present() error { var p pos for p.y = 0; p.y < s.Height; p.y++ { for p.x = 0; p.x < s.Width; { - if reset { - err := writeCursor(p.x, p.y) - if err != nil { - return err - } - } c := scr.front[p] if c.c == "" { c.c = " " @@ -164,17 +158,14 @@ func Present() error { c.c = " " } if c != scr.back[p] || scr.prevSize != s { + if reset { + writeCursor(p.x, p.y) + } if style != c.style { style = c.style - err := writeStyle(style) - if err != nil { - return err - } - } - _, err := scr.writer.WriteString(c.c) - if err != nil { - return err + writeStyle(style) } + scr.writer.WriteString(c.c) // make sure that the cursor position remains synced even if // the terminal mangles a wide char or grapheme if cw == 1 && len([]rune(c.c)) == 1 { @@ -188,10 +179,7 @@ func Present() error { p.x += cw } } - err := writeCursor(scr.cursor.x, scr.cursor.y) - if err != nil { - return err - } + writeCursor(scr.cursor.x, scr.cursor.y) scr.prevSize = s f := scr.front |
