diff options
-rw-r--r-- | Gopkg.lock | 18 | ||||
-rw-r--r-- | bug/clocks.go | 2 | ||||
-rw-r--r-- | repository/git.go | 2 | ||||
-rw-r--r-- | repository/repo.go | 4 | ||||
-rw-r--r-- | termui/bug_table.go | 38 | ||||
-rw-r--r-- | util/text/text.go | 10 | ||||
-rw-r--r-- | util/text/text_test.go | 22 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/.gitignore (renamed from vendor/github.com/jroimartin/gocui/.gitignore) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/AUTHORS (renamed from vendor/github.com/jroimartin/gocui/AUTHORS) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/LICENSE (renamed from vendor/github.com/jroimartin/gocui/LICENSE) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/README.md (renamed from vendor/github.com/jroimartin/gocui/README.md) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/attribute.go (renamed from vendor/github.com/jroimartin/gocui/attribute.go) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/doc.go (renamed from vendor/github.com/jroimartin/gocui/doc.go) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/edit.go (renamed from vendor/github.com/jroimartin/gocui/edit.go) | 27 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/escape.go (renamed from vendor/github.com/jroimartin/gocui/escape.go) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/gui.go (renamed from vendor/github.com/jroimartin/gocui/gui.go) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/keybinding.go (renamed from vendor/github.com/jroimartin/gocui/keybinding.go) | 0 | ||||
-rw-r--r-- | vendor/github.com/MichaelMure/gocui/view.go (renamed from vendor/github.com/jroimartin/gocui/view.go) | 3 |
18 files changed, 87 insertions, 39 deletions
@@ -20,6 +20,14 @@ version = "v0.7.1" [[projects]] + branch = "master" + digest = "1:38a84d9b4cf50b3e8eb2b54f218413ac163076e3a7763afe5fa15a4eb15fbda6" + name = "github.com/MichaelMure/gocui" + packages = ["."] + pruneopts = "UT" + revision = "d753c235dd8582d55e99bbb7f7fe453fb3fd3a19" + +[[projects]] digest = "1:897d91c431ce469d35a5e6030e60e617dccd9a0e95bdffa6a80594f5c5800d29" name = "github.com/agnivade/levenshtein" packages = ["."] @@ -156,14 +164,6 @@ version = "v1.0" [[projects]] - branch = "master" - digest = "1:114ecad51af93a73ae6781fd0d0bc28e52b433c852b84ab4b4c109c15e6c6b6d" - name = "github.com/jroimartin/gocui" - packages = ["."] - pruneopts = "UT" - revision = "c055c87ae801372cd74a0839b972db4f7697ae5f" - -[[projects]] digest = "1:c658e84ad3916da105a761660dcaeb01e63416c8ec7bc62256a9b411a05fcd67" name = "github.com/mattn/go-colorable" packages = ["."] @@ -462,13 +462,13 @@ "github.com/99designs/gqlgen/graphql", "github.com/99designs/gqlgen/graphql/introspection", "github.com/99designs/gqlgen/handler", + "github.com/MichaelMure/gocui", "github.com/cheekybits/genny/generic", "github.com/dustin/go-humanize", "github.com/fatih/color", "github.com/go-test/deep", "github.com/gorilla/mux", "github.com/icrowley/fake", - "github.com/jroimartin/gocui", "github.com/phayes/freeport", "github.com/pkg/errors", "github.com/shurcooL/githubv4", diff --git a/bug/clocks.go b/bug/clocks.go index 47cd1509..bb3d81f0 100644 --- a/bug/clocks.go +++ b/bug/clocks.go @@ -6,7 +6,7 @@ import ( // Witnesser will read all the available Bug to recreate the different logical // clocks -func Witnesser(repo *repository.GitRepo) error { +func Witnesser(repo repository.ClockedRepo) error { for b := range ReadAllLocalBugs(repo) { if b.Err != nil { return b.Err diff --git a/repository/git.go b/repository/git.go index af251aa2..c2f0da0a 100644 --- a/repository/git.go +++ b/repository/git.go @@ -67,7 +67,7 @@ func (repo *GitRepo) runGitCommand(args ...string) (string, error) { // NewGitRepo determines if the given working directory is inside of a git repository, // and returns the corresponding GitRepo instance if it is. -func NewGitRepo(path string, witnesser func(repo *GitRepo) error) (*GitRepo, error) { +func NewGitRepo(path string, witnesser Witnesser) (*GitRepo, error) { repo := &GitRepo{Path: path} // Check the repo and retrieve the root path diff --git a/repository/repo.go b/repository/repo.go index d0004c8b..3ae09057 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -107,6 +107,10 @@ type ClockedRepo interface { EditWitness(time lamport.Time) error } +// Witnesser is a function that will initialize the clocks of a repo +// from scratch +type Witnesser func(repo ClockedRepo) error + func prepareTreeEntries(entries []TreeEntry) bytes.Buffer { var buffer bytes.Buffer diff --git a/termui/bug_table.go b/termui/bug_table.go index fb281d74..31e38d08 100644 --- a/termui/bug_table.go +++ b/termui/bug_table.go @@ -340,8 +340,23 @@ func (bt *bugTable) renderFooter(v *gocui.View, maxX int) { func (bt *bugTable) cursorDown(g *gocui.Gui, v *gocui.View) error { _, y := v.Cursor() - y = minInt(y+1, bt.getTableLength()-1) + // If we are at the bottom of the page, switch to the next one. + if y+1 > bt.getTableLength()-1 { + _, max := v.Size() + + if bt.pageCursor+max >= len(bt.allIds) { + return nil + } + + bt.pageCursor += max + bt.selectCursor = 0 + _ = v.SetCursor(0, bt.selectCursor) + + return bt.doPaginate(max) + } + + y = minInt(y+1, bt.getTableLength()-1) // window is too small to set the cursor properly, ignoring the error _ = v.SetCursor(0, y) bt.selectCursor = y @@ -351,8 +366,23 @@ func (bt *bugTable) cursorDown(g *gocui.Gui, v *gocui.View) error { func (bt *bugTable) cursorUp(g *gocui.Gui, v *gocui.View) error { _, y := v.Cursor() - y = maxInt(y-1, 0) + // If we are at the top of the page, switch to the previous one. + if y-1 < 0 { + _, max := v.Size() + + if bt.pageCursor == 0 { + return nil + } + + bt.pageCursor = maxInt(0, bt.pageCursor-max) + bt.selectCursor = max - 1 + _ = v.SetCursor(0, bt.selectCursor) + + return bt.doPaginate(max) + } + + y = maxInt(y-1, 0) // window is too small to set the cursor properly, ignoring the error _ = v.SetCursor(0, y) bt.selectCursor = y @@ -388,6 +418,10 @@ func (bt *bugTable) nextPage(g *gocui.Gui, v *gocui.View) error { func (bt *bugTable) previousPage(g *gocui.Gui, v *gocui.View) error { _, max := v.Size() + if bt.pageCursor == 0 { + return nil + } + bt.pageCursor = maxInt(0, bt.pageCursor-max) return bt.doPaginate(max) diff --git a/util/text/text.go b/util/text/text.go index f8910c2e..ee9d278c 100644 --- a/util/text/text.go +++ b/util/text/text.go @@ -100,9 +100,9 @@ func wrapText(s string, w int) string { word += string(r) } } - // The text may end without newlines, ensure flushing it or we can lose the - // last word. - flushWord() + // The text may end without newlines, ensure flushing it or we can lose the + // last word. + flushWord() return out } @@ -113,12 +113,12 @@ func wordLen(word string) int { length := 0 escape := false - for _, char := range []rune(word) { + for _, char := range word { if char == '\x1b' { escape = true } if !escape { - length += runewidth.RuneWidth(char) + length += runewidth.RuneWidth(rune(char)) } if char == 'm' { escape = false diff --git a/util/text/text_test.go b/util/text/text_test.go index 38e747df..c70d2ccd 100644 --- a/util/text/text_test.go +++ b/util/text/text_test.go @@ -89,16 +89,16 @@ func TestWrap(t *testing.T) { " This\nis a\nlist:\n\n\n *\nfoo\n *\nbar\n\n\n *\nbaz\nBAM\n", 6, }, - // Handle chinese + // Handle chinese (wide characters) { "婞一枳郲逴靲屮蜧曀殳,掫乇峔掮傎溒兀緉冘仜。", - "婞一枳郲逴靲屮蜧曀殳,掫\n乇峔掮傎溒兀緉冘仜。", + "婞一枳郲逴靲\n屮蜧曀殳,掫\n乇峔掮傎溒兀\n緉冘仜。", 12, }, // Handle chinese with colors { "婞一枳郲逴\x1b[31m靲屮蜧曀殳,掫乇峔掮傎溒\x1b[0m兀緉冘仜。", - "婞一枳郲逴\x1b[31m靲屮蜧曀殳,掫\n乇峔掮傎溒\x1b[0m兀緉冘仜。", + "婞一枳郲逴\x1b[31m靲\n屮蜧曀殳,掫\n乇峔掮傎溒\x1b[0m兀\n緉冘仜。", 12, }, } @@ -134,10 +134,14 @@ func TestWrapLeftPadded(t *testing.T) { // Handle Chinese { "婞一枳郲逴靲屮蜧曀殳,掫乇峔掮傎溒兀緉冘仜。郼牪艽螗媷錵朸一詅掜豗怙刉笀丌,楀棶乇矹迡搦囷圣亍昄漚粁仈祂。覂一洳袶揙楱亍滻瘯毌,掗屮柅軡菵腩乜榵毌夯。勼哻怌婇怤灟葠雺奷朾恦扰衪岨坋誁乇芚誙腞。冇笉妺悆浂鱦賌廌灱灱觓坋佫呬耴跣兀枔蓔輈。嵅咍犴膰痭瘰机一靬涽捊矷尒玶乇,煚塈丌岰陊鉖怞戉兀甿跾觓夬侄。棩岧汌橩僁螗玎一逭舴圂衪扐衲兀,嵲媕亍衩衿溽昃夯丌侄蒰扂丱呤。毰侘妅錣廇螉仴一暀淖蚗佶庂咺丌,輀鈁乇彽洢溦洰氶乇构碨洐巿阹。", - ` 婞一枳郲逴靲屮蜧曀殳,掫乇峔掮傎溒兀緉冘仜。郼牪艽螗媷錵朸一詅掜豗怙刉笀丌,楀棶乇矹迡搦囷圣亍昄漚粁仈祂。覂一 - 洳袶揙楱亍滻瘯毌,掗屮柅軡菵腩乜榵毌夯。勼哻怌婇怤灟葠雺奷朾恦扰衪岨坋誁乇芚誙腞。冇笉妺悆浂鱦賌廌灱灱觓坋佫呬 - 耴跣兀枔蓔輈。嵅咍犴膰痭瘰机一靬涽捊矷尒玶乇,煚塈丌岰陊鉖怞戉兀甿跾觓夬侄。棩岧汌橩僁螗玎一逭舴圂衪扐衲兀,嵲 - 媕亍衩衿溽昃夯丌侄蒰扂丱呤。毰侘妅錣廇螉仴一暀淖蚗佶庂咺丌,輀鈁乇彽洢溦洰氶乇构碨洐巿阹。`, + ` 婞一枳郲逴靲屮蜧曀殳,掫乇峔掮傎溒兀緉冘仜。郼牪艽螗媷 + 錵朸一詅掜豗怙刉笀丌,楀棶乇矹迡搦囷圣亍昄漚粁仈祂。覂 + 一洳袶揙楱亍滻瘯毌,掗屮柅軡菵腩乜榵毌夯。勼哻怌婇怤灟 + 葠雺奷朾恦扰衪岨坋誁乇芚誙腞。冇笉妺悆浂鱦賌廌灱灱觓坋 + 佫呬耴跣兀枔蓔輈。嵅咍犴膰痭瘰机一靬涽捊矷尒玶乇,煚塈 + 丌岰陊鉖怞戉兀甿跾觓夬侄。棩岧汌橩僁螗玎一逭舴圂衪扐衲 + 兀,嵲媕亍衩衿溽昃夯丌侄蒰扂丱呤。毰侘妅錣廇螉仴一暀淖 + 蚗佶庂咺丌,輀鈁乇彽洢溦洰氶乇构碨洐巿阹。`, 59, 4, }, } @@ -182,12 +186,12 @@ func TestWordLen(t *testing.T) { // Handle chinese { "快檢什麼望對", - 6, + 12, }, // Handle chinese with colors { "快\x1b[31m檢什麼\x1b[0m望對", - 6, + 12, }, } diff --git a/vendor/github.com/jroimartin/gocui/.gitignore b/vendor/github.com/MichaelMure/gocui/.gitignore index 1377554e..1377554e 100644 --- a/vendor/github.com/jroimartin/gocui/.gitignore +++ b/vendor/github.com/MichaelMure/gocui/.gitignore diff --git a/vendor/github.com/jroimartin/gocui/AUTHORS b/vendor/github.com/MichaelMure/gocui/AUTHORS index 43ec4cec..43ec4cec 100644 --- a/vendor/github.com/jroimartin/gocui/AUTHORS +++ b/vendor/github.com/MichaelMure/gocui/AUTHORS diff --git a/vendor/github.com/jroimartin/gocui/LICENSE b/vendor/github.com/MichaelMure/gocui/LICENSE index 8cb28215..8cb28215 100644 --- a/vendor/github.com/jroimartin/gocui/LICENSE +++ b/vendor/github.com/MichaelMure/gocui/LICENSE diff --git a/vendor/github.com/jroimartin/gocui/README.md b/vendor/github.com/MichaelMure/gocui/README.md index d7b55a3b..d7b55a3b 100644 --- a/vendor/github.com/jroimartin/gocui/README.md +++ b/vendor/github.com/MichaelMure/gocui/README.md diff --git a/vendor/github.com/jroimartin/gocui/attribute.go b/vendor/github.com/MichaelMure/gocui/attribute.go index bad758a1..bad758a1 100644 --- a/vendor/github.com/jroimartin/gocui/attribute.go +++ b/vendor/github.com/MichaelMure/gocui/attribute.go diff --git a/vendor/github.com/jroimartin/gocui/doc.go b/vendor/github.com/MichaelMure/gocui/doc.go index fe128afb..fe128afb 100644 --- a/vendor/github.com/jroimartin/gocui/doc.go +++ b/vendor/github.com/MichaelMure/gocui/doc.go diff --git a/vendor/github.com/jroimartin/gocui/edit.go b/vendor/github.com/MichaelMure/gocui/edit.go index e1b19c20..de86580f 100644 --- a/vendor/github.com/jroimartin/gocui/edit.go +++ b/vendor/github.com/MichaelMure/gocui/edit.go @@ -4,7 +4,11 @@ package gocui -import "errors" +import ( + "errors" + + "github.com/mattn/go-runewidth" +) const maxInt = int(^uint(0) >> 1) @@ -55,7 +59,7 @@ func simpleEditor(v *View, key Key, ch rune, mod Modifier) { // EditWrite writes a rune at the cursor position. func (v *View) EditWrite(ch rune) { v.writeRune(v.cx, v.cy, ch) - v.MoveCursor(1, 0, true) + v.MoveCursor(runewidth.RuneWidth(ch), 0, true) } // EditDelete deletes a rune at the cursor position. back determines the @@ -89,12 +93,12 @@ func (v *View) EditDelete(back bool) { v.MoveCursor(-1, 0, true) } } else { // wrapped line - v.deleteRune(len(v.viewLines[y-1].line)-1, v.cy-1) - v.MoveCursor(-1, 0, true) + ch, _ := v.deleteRune(len(v.viewLines[y-1].line)-1, v.cy-1) + v.MoveCursor(0-runewidth.RuneWidth(ch), 0, true) } } else { // middle/end of the line - v.deleteRune(v.cx-1, v.cy) - v.MoveCursor(-1, 0, true) + ch, _ := v.deleteRune(v.cx-1, v.cy) + v.MoveCursor(0-runewidth.RuneWidth(ch), 0, true) } } else { if x == len(v.viewLines[y].line) { // end of the line @@ -275,19 +279,20 @@ func (v *View) writeRune(x, y int, ch rune) error { // deleteRune removes a rune from the view's internal buffer, at the // position corresponding to the point (x, y). -func (v *View) deleteRune(x, y int) error { +func (v *View) deleteRune(x, y int) (ch rune, err error) { v.tainted = true - x, y, err := v.realPosition(x, y) + x, y, err = v.realPosition(x, y) if err != nil { - return err + return 0, err } if x < 0 || y < 0 || y >= len(v.lines) || x >= len(v.lines[y]) { - return errors.New("invalid point") + return 0, errors.New("invalid point") } + chx := v.lines[y][x] v.lines[y] = append(v.lines[y][:x], v.lines[y][x+1:]...) - return nil + return chx.chr, nil } // mergeLines merges the lines "y" and "y+1" if possible. diff --git a/vendor/github.com/jroimartin/gocui/escape.go b/vendor/github.com/MichaelMure/gocui/escape.go index ec31bbe0..ec31bbe0 100644 --- a/vendor/github.com/jroimartin/gocui/escape.go +++ b/vendor/github.com/MichaelMure/gocui/escape.go diff --git a/vendor/github.com/jroimartin/gocui/gui.go b/vendor/github.com/MichaelMure/gocui/gui.go index 9499d3c3..9499d3c3 100644 --- a/vendor/github.com/jroimartin/gocui/gui.go +++ b/vendor/github.com/MichaelMure/gocui/gui.go diff --git a/vendor/github.com/jroimartin/gocui/keybinding.go b/vendor/github.com/MichaelMure/gocui/keybinding.go index 03fe677c..03fe677c 100644 --- a/vendor/github.com/jroimartin/gocui/keybinding.go +++ b/vendor/github.com/MichaelMure/gocui/keybinding.go diff --git a/vendor/github.com/jroimartin/gocui/view.go b/vendor/github.com/MichaelMure/gocui/view.go index 42082f8c..d7943497 100644 --- a/vendor/github.com/jroimartin/gocui/view.go +++ b/vendor/github.com/MichaelMure/gocui/view.go @@ -10,6 +10,7 @@ import ( "io" "strings" + "github.com/mattn/go-runewidth" "github.com/nsf/termbox-go" ) @@ -353,7 +354,7 @@ func (v *View) draw() error { if err := v.setRune(x, y, c.chr, fgColor, bgColor); err != nil { return err } - x++ + x += runewidth.RuneWidth(c.chr) } y++ } |