From 0bca6dadb36d53f1be2c666147c6a7c413e69149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 15 Mar 2021 18:25:18 +0000 Subject: [PATCH 01/10] Fix inverted handling of KeyPgDn/KeyPgUp in List widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consider a list with 5 items, and the currentItem index is 2, and all items fit on the screen without scrolling. KeyPgDn will set currentItem to 7 which is out of bounds, and gets wrapped around to 0. KeyPgUp will set currentItem to -3 which is out of bounds, and gets wrapped around to 4. Thus PgDn selects the first item, while PgUp selects the last item, which is the opposite of expected behaviour for these keys. Fix this by clamping currentItem to the boundaries in the key handler. Fixes: https://github.com/rivo/tview/issues/580 Signed-off-by: Daniel P. Berrangé --- list.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/list.go b/list.go index 657baec..e3f088a 100644 --- a/list.go +++ b/list.go @@ -572,9 +572,15 @@ func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p Primit case tcell.KeyPgDn: _, _, _, height := l.GetInnerRect() l.currentItem += height + if l.currentItem >= len(l.items) { + l.currentItem = len(l.items) - 1 + } case tcell.KeyPgUp: _, _, _, height := l.GetInnerRect() l.currentItem -= height + if l.currentItem < 0 { + l.currentItem = 0 + } case tcell.KeyEnter: if l.currentItem >= 0 && l.currentItem < len(l.items) { item := l.items[l.currentItem] From f68e023e7c4ff43cf48db16eb01c60301573b368 Mon Sep 17 00:00:00 2001 From: Quang Ngoc Date: Sun, 4 Apr 2021 14:58:24 +0700 Subject: [PATCH 02/10] Add GoChess to README.md #Projects --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a551fcc..8e47ccd 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ For a presentation highlighting this package, compile and run the program found - [Browse your AWS ECS Clusters in the Terminal](https://github.com/swartzrock/ecsview) - [The CLI Task Manager for Geeks](https://github.com/ajaxray/geek-life) - [Fast disk usage analyzer written in Go](https://github.com/dundee/gdu) +- [Multiplayer Chess On Terminal](https://github.com/qnkhuat/gochess) ## Documentation From ef11d63b76cc523005ff172bcb82ff1a8c500022 Mon Sep 17 00:00:00 2001 From: raziman Date: Sun, 18 Apr 2021 09:04:17 +0800 Subject: [PATCH 03/10] Add gomu --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a551fcc..3b427c7 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ For a presentation highlighting this package, compile and run the program found - [Browse your AWS ECS Clusters in the Terminal](https://github.com/swartzrock/ecsview) - [The CLI Task Manager for Geeks](https://github.com/ajaxray/geek-life) - [Fast disk usage analyzer written in Go](https://github.com/dundee/gdu) +- [Scriptable TUI music player](https://github.com/issadarkthing/gomu) ## Documentation From 7df0389cccc9bb72e6806a45b9ebd784081755fc Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 26 Apr 2021 13:57:56 +0200 Subject: [PATCH 04/10] Cleaned up modules. --- go.mod | 1 - go.sum | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/go.mod b/go.mod index 733291d..c39712d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/rivo/tview go 1.12 require ( - github.com/gdamore/tcell v1.4.0 // indirect github.com/gdamore/tcell/v2 v2.2.0 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mattn/go-runewidth v0.0.10 diff --git a/go.sum b/go.sum index dd04904..218ef69 100644 --- a/go.sum +++ b/go.sum @@ -1,34 +1,21 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= -github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU= -github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0= -github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591 h1:0WWUDZ1oxq7NxVyGo8M3KI5jbkiwNAdZFFzAdC68up4= -github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= github.com/gdamore/tcell/v2 v2.2.0 h1:vSyEgKwraXPSOkvCk7IwOSyX+Pv3V2cV9CikJMXg4U4= github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= -github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10= -golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY= -golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From ea0971753caf12c3490bfacf17c7e01b4a8fe567 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 26 Apr 2021 14:01:46 +0200 Subject: [PATCH 05/10] Upgrade tcell to v2.2.1. --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c39712d..58b8360 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/rivo/tview go 1.12 require ( - github.com/gdamore/tcell/v2 v2.2.0 + github.com/gdamore/tcell/v2 v2.2.1 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mattn/go-runewidth v0.0.10 github.com/rivo/uniseg v0.2.0 diff --git a/go.sum b/go.sum index 218ef69..79ab9b7 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell/v2 v2.2.0 h1:vSyEgKwraXPSOkvCk7IwOSyX+Pv3V2cV9CikJMXg4U4= github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= +github.com/gdamore/tcell/v2 v2.2.1 h1:Gt8wk0jd5pIK2CyXNo/fqwxNWf726j1lQjEDdfbnqTc= +github.com/gdamore/tcell/v2 v2.2.1/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= From a74431711b95320200f01cf3f575c878aa72711e Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 26 Apr 2021 16:20:53 +0200 Subject: [PATCH 06/10] Minor clarification. --- pages.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages.go b/pages.go index 9dca792..32c933e 100644 --- a/pages.go +++ b/pages.go @@ -12,9 +12,9 @@ type page struct { Visible bool // Whether or not this page is visible. } -// Pages is a container for other primitives often used as the application's -// root primitive. It allows to easily switch the visibility of the contained -// primitives. +// Pages is a container for other primitives laid out on top of each other, +// overlapping or not. It is often used as the application's root primitive. It +// allows to easily switch the visibility of the contained primitives. // // See https://github.com/rivo/tview/wiki/Pages for an example. type Pages struct { From 3ac88670ddebde0df1b611fbe2cc02dbbf4eead8 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 26 Apr 2021 16:43:34 +0200 Subject: [PATCH 07/10] TreeView.process() fires the changed callback and therefore needs to remain in input handler. Fixes #579 --- treeview.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/treeview.go b/treeview.go index cb15dc5..3c5e831 100644 --- a/treeview.go +++ b/treeview.go @@ -774,6 +774,8 @@ func (t *TreeView) InputHandler() func(event *tcell.EventKey, setFocus func(p Pr case tcell.KeyEnter: selectNode() } + + t.process() }) } From ba9f3a6fa19d4eb2cebed6c256523ff90faa0bbb Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 27 Apr 2021 09:08:36 +0200 Subject: [PATCH 08/10] Fixed missed tag at EOL in TextView. Fixes #531 --- textview.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/textview.go b/textview.go index 1a445bb..fa7c662 100644 --- a/textview.go +++ b/textview.go @@ -1019,14 +1019,22 @@ func (t *TextView) Draw(screen tcell.Screen) { backgroundColor := index.BackgroundColor attributes := index.Attributes regionID := index.Region - if t.regions && regionID != "" && (len(t.regionInfos) == 0 || t.regionInfos[len(t.regionInfos)-1].ID != regionID) { - t.regionInfos = append(t.regionInfos, &textViewRegion{ - ID: regionID, - FromX: x, - FromY: y + line - t.lineOffset, - ToX: -1, - ToY: -1, - }) + if t.regions { + if len(t.regionInfos) > 0 && t.regionInfos[len(t.regionInfos)-1].ID != regionID { + // End last region. + t.regionInfos[len(t.regionInfos)-1].ToX = x + t.regionInfos[len(t.regionInfos)-1].ToY = y + line - t.lineOffset + } + if regionID != "" && (len(t.regionInfos) == 0 || t.regionInfos[len(t.regionInfos)-1].ID != regionID) { + // Start a new region. + t.regionInfos = append(t.regionInfos, &textViewRegion{ + ID: regionID, + FromX: x, + FromY: y + line - t.lineOffset, + ToX: -1, + ToY: -1, + }) + } } // Process tags. From b610d436f35918103292baa814cf74919ba78c3c Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 27 Apr 2021 13:28:32 +0200 Subject: [PATCH 09/10] Minor improvements. --- ansi.go | 8 ++++---- demos/inputfield/autocompleteasync/main.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ansi.go b/ansi.go index 49b2e92..b63b478 100644 --- a/ansi.go +++ b/ansi.go @@ -128,19 +128,19 @@ func (a *ansi) Write(text []byte) (int, error) { for index, field := range fields { switch field { case "1", "01": - if strings.IndexRune(a.attributes, 'b') < 0 { + if !strings.ContainsRune(a.attributes, 'b') { a.attributes += "b" } case "2", "02": - if strings.IndexRune(a.attributes, 'd') < 0 { + if !strings.ContainsRune(a.attributes, 'd') { a.attributes += "d" } case "4", "04": - if strings.IndexRune(a.attributes, 'u') < 0 { + if !strings.ContainsRune(a.attributes, 'u') { a.attributes += "u" } case "5", "05": - if strings.IndexRune(a.attributes, 'l') < 0 { + if !strings.ContainsRune(a.attributes, 'l') { a.attributes += "l" } case "22": diff --git a/demos/inputfield/autocompleteasync/main.go b/demos/inputfield/autocompleteasync/main.go index 0cfe75c..b724329 100644 --- a/demos/inputfield/autocompleteasync/main.go +++ b/demos/inputfield/autocompleteasync/main.go @@ -12,7 +12,7 @@ import ( ) type company struct { - Name string `json:name` + Name string `json:"name"` } func main() { From 84ec33078a43ca7817be85c7a5f585093fe3fa4d Mon Sep 17 00:00:00 2001 From: darylhjd <53652695+darylhjd@users.noreply.github.com> Date: Fri, 14 May 2021 15:53:05 +0800 Subject: [PATCH 10/10] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8593b5a..c2f5ea7 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ For a presentation highlighting this package, compile and run the program found - [Fast disk usage analyzer written in Go](https://github.com/dundee/gdu) - [Multiplayer Chess On Terminal](https://github.com/qnkhuat/gochess) - [Scriptable TUI music player](https://github.com/issadarkthing/gomu) +- [MangaDesk : TUI Client for downloading manga to your computer](https://github.com/darylhjd/mangadesk) ## Documentation