From 9eb9b369ffc7c99854e2565da9996c3dcc6116c8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 23 Jun 2024 11:54:01 +0200 Subject: [PATCH] Bump gocui --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/jesseduffield/gocui/view.go | 66 +++++++++++++------ vendor/modules.txt | 2 +- 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index e994a67b1..4e189992b 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d - github.com/jesseduffield/gocui v0.3.1-0.20240623092910-a42926c14fc9 + github.com/jesseduffield/gocui v0.3.1-0.20240623095254-05e1204c2454 github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e diff --git a/go.sum b/go.sum index 4a9156784..19c698189 100644 --- a/go.sum +++ b/go.sum @@ -188,8 +188,8 @@ github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8T github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk= github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE= github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o= -github.com/jesseduffield/gocui v0.3.1-0.20240623092910-a42926c14fc9 h1:JJ0DrXgAUpGBGV5w8nzrQLMWTgcTvf745IKAk08qjcM= -github.com/jesseduffield/gocui v0.3.1-0.20240623092910-a42926c14fc9/go.mod h1:XtEbqCbn45keRXEu+OMZkjN5gw6AEob59afsgHjokZ8= +github.com/jesseduffield/gocui v0.3.1-0.20240623095254-05e1204c2454 h1:rTPA5WiPM1SPUA3r2kSb3RiILC93am6irMvOLjO7JNA= +github.com/jesseduffield/gocui v0.3.1-0.20240623095254-05e1204c2454/go.mod h1:XtEbqCbn45keRXEu+OMZkjN5gw6AEob59afsgHjokZ8= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY= diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go index 68b0f49c6..a32519b80 100644 --- a/vendor/github.com/jesseduffield/gocui/view.go +++ b/vendor/github.com/jesseduffield/gocui/view.go @@ -771,13 +771,14 @@ func (v *View) writeRunes(p []rune) { } v.wx = 0 default: - moveCursor, cells := v.parseInput(r, v.wx, v.wy) + truncateLine, cells := v.parseInput(r, v.wx, v.wy) if cells == nil { continue } v.writeCells(v.wx, v.wy, cells) - if moveCursor { - v.wx += len(cells) + v.wx += len(cells) + if truncateLine { + v.lines[v.wy] = v.lines[v.wy][:v.wx] } } } @@ -800,7 +801,7 @@ func (v *View) writeString(s string) { // contains the processed data. func (v *View) parseInput(ch rune, x int, _ int) (bool, []cell) { cells := []cell{} - moveCursor := true + truncateLine := false isEscape, err := v.ei.parseOne(ch) if err != nil { @@ -816,18 +817,13 @@ func (v *View) parseInput(ch rune, x int, _ int) (bool, []cell) { } else { repeatCount := 1 if _, ok := v.ei.instruction.(eraseInLineFromCursor); ok { - // fill rest of line + // truncate line v.ei.instructionRead() - cx := 0 - for _, cell := range v.lines[v.wy] { - cx += runewidth.RuneWidth(cell.chr) - } - repeatCount = v.InnerWidth() - cx - ch = ' ' - moveCursor = false + repeatCount = 0 + truncateLine = true } else if isEscape { // do not output anything - return moveCursor, nil + return truncateLine, nil } else if ch == '\t' { // fill tab-sized space const tabStop = 4 @@ -844,7 +840,7 @@ func (v *View) parseInput(ch rune, x int, _ int) (bool, []cell) { } } - return moveCursor, cells + return truncateLine, cells } // Read reads data into p from the current reading position set by SetReadPos. @@ -1590,19 +1586,51 @@ func (v *View) ClearTextArea() { _ = v.SetCursor(0, 0) } -// only call this function if you don't care where v.wx and v.wy end up -func (v *View) OverwriteLines(y int, content string) { - v.writeMutex.Lock() - defer v.writeMutex.Unlock() - +func (v *View) overwriteLines(y int, content string) { // break by newline, then for each line, write it, then add that erase command v.wx = 0 v.wy = y lines := strings.Replace(content, "\n", "\x1b[K\n", -1) + // If the last line doesn't end with a linefeed, add the erase command at + // the end too + if !strings.HasSuffix(lines, "\n") { + lines += "\x1b[K" + } v.writeString(lines) } +// only call this function if you don't care where v.wx and v.wy end up +func (v *View) OverwriteLines(y int, content string) { + v.writeMutex.Lock() + defer v.writeMutex.Unlock() + + v.overwriteLines(y, content) +} + +// only call this function if you don't care where v.wx and v.wy end up +func (v *View) OverwriteLinesAndClearEverythingElse(y int, content string) { + v.writeMutex.Lock() + defer v.writeMutex.Unlock() + + v.overwriteLines(y, content) + + for i := 0; i < y; i += 1 { + v.lines[i] = nil + } + + for i := v.wy + 1; i < len(v.lines); i += 1 { + v.lines[i] = nil + } +} + +func (v *View) SetContentLineCount(lineCount int) { + if lineCount > 0 { + v.makeWriteable(0, lineCount-1) + } + v.lines = v.lines[:lineCount] +} + func (v *View) ScrollUp(amount int) { if amount > v.oy { amount = v.oy diff --git a/vendor/modules.txt b/vendor/modules.txt index 47793de1e..62d47eea4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -172,7 +172,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/noder -# github.com/jesseduffield/gocui v0.3.1-0.20240623092910-a42926c14fc9 +# github.com/jesseduffield/gocui v0.3.1-0.20240623095254-05e1204c2454 ## explicit; go 1.12 github.com/jesseduffield/gocui # github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10