Browse Source

Allow clicking on status text to continue

master
Trevor Slocum 2 years ago
parent
commit
b6cd5669aa
  1. 2
      cardstackwidget.go
  2. 2
      cardwidget.go
  3. 11
      go.mod
  4. 37
      go.sum
  5. 11
      main.go
  6. 34
      statustextview.go

2
cardstackwidget.go

@ -4,7 +4,7 @@ import (
"math"
"sync"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
"gitlab.com/tslocum/joker"
)

2
cardwidget.go

@ -4,7 +4,7 @@ import (
"math"
"strconv"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
"gitlab.com/tslocum/joker"
)

11
go.mod

@ -3,11 +3,10 @@ module gitlab.com/tslocum/crib
go 1.15
require (
github.com/gdamore/tcell v1.3.1-0.20200608133353-cb1e5d6fa606
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200926152101-0fb77ddaa5b4
github.com/gorilla/websocket v1.4.2
gitlab.com/tslocum/cbind v0.1.1
gitlab.com/tslocum/cview v1.4.8
gitlab.com/tslocum/joker v0.1.3
gitlab.com/tslocum/joker-cribbage v0.1.1
golang.org/x/sys v0.0.0-20200819171115-d785dc25833f // indirect
gitlab.com/tslocum/cbind v0.1.2
gitlab.com/tslocum/cview v1.5.0
gitlab.com/tslocum/joker v0.1.4
gitlab.com/tslocum/joker-cribbage v0.1.2-0.20201002022536-57717781be9a
)

37
go.sum

@ -1,39 +1,30 @@
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
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.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM=
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
github.com/gdamore/tcell v1.3.1-0.20200608133353-cb1e5d6fa606 h1:Y00kKKKYVyn7InlCMRcnZbwcjHFIsgkjU0Bn1F5re4o=
github.com/gdamore/tcell v1.3.1-0.20200608133353-cb1e5d6fa606/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200926152101-0fb77ddaa5b4 h1:9WLVV5c2UI2qvgROlgzLgCuK5gi7igcU5LNsPXCSFB8=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200926152101-0fb77ddaa5b4/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
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/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
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=
gitlab.com/tslocum/cbind v0.1.1 h1:JXXtxMWHgWLvoF+QkrvcNvOQ59juy7OE1RhT7hZfdt0=
gitlab.com/tslocum/cbind v0.1.1/go.mod h1:rX7vkl0pUSg/yy427MmD1FZAf99S7WwpUlxF/qTpPqk=
gitlab.com/tslocum/cview v1.4.8 h1:xYUO+4QUGDbrqIhgqUqXWzCXB1kZDNpmoOR2MwkxNb0=
gitlab.com/tslocum/cview v1.4.8/go.mod h1:mSTNW1JUAfb9QlCB9GSaqy97Z3reIAJyUSbFSQcF8GE=
gitlab.com/tslocum/joker v0.1.2-0.20200123002530-2570d6c23aff/go.mod h1:bxTQ0FFmBP465r9z76zcm97S4Ld9eCLa3q20TyVM82A=
gitlab.com/tslocum/joker v0.1.3 h1:6AVQuc0Rt7LczppZKaAXfr5B5Yg/4sQky2SFaWaF9E4=
gitlab.com/tslocum/joker v0.1.3/go.mod h1:bxTQ0FFmBP465r9z76zcm97S4Ld9eCLa3q20TyVM82A=
gitlab.com/tslocum/joker-cribbage v0.1.1 h1:oiCKebyppYsl4x1ZJNHQZcSCcHSBHUCMqSFTGDGv1fY=
gitlab.com/tslocum/joker-cribbage v0.1.1/go.mod h1:KyNZDgGv6fFmYGpHD9txZCBFuVDgKwCq4mJ4ZAgQ0hw=
gitlab.com/tslocum/cbind v0.1.2 h1:ptDjO7WeOl1HglprsK18L8I9JeRkmtuBoBBaYw/6/Ow=
gitlab.com/tslocum/cbind v0.1.2/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6xdeeI=
gitlab.com/tslocum/cview v1.5.0 h1:oT4/1IIxxxQpswt1neIKC4WKuDSfKfmHmiCgnsdLya4=
gitlab.com/tslocum/cview v1.5.0/go.mod h1:i9NyxtwBtkiVFrwmsh3Bv3dunvipjZrKX0TTdPHbzcw=
gitlab.com/tslocum/joker v0.1.4 h1:eE/lF/m+L9gQRajPIoZnYa+7vSg2MYlzcd39TMjs0lk=
gitlab.com/tslocum/joker v0.1.4/go.mod h1:bxTQ0FFmBP465r9z76zcm97S4Ld9eCLa3q20TyVM82A=
gitlab.com/tslocum/joker-cribbage v0.1.2-0.20201002022536-57717781be9a h1:2mLtWtMTBMHIuYpARk+2wmzP6VyghsYF3sSFwC+pmJw=
gitlab.com/tslocum/joker-cribbage v0.1.2-0.20201002022536-57717781be9a/go.mod h1:f5N1g6sedmY4XhnZJGJB08ZLrqZpbW9xkBlsSH4DM7U=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed h1:WBkVNH1zd9jg/dK4HCM4lNANnmd12EHC9z+LmcCG4ns=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200819171115-d785dc25833f h1:KJuwZVtZBVzDmEDtB2zro9CXkD9O0dpCv4o2LHbQIAw=
golang.org/x/sys v0.0.0-20200819171115-d785dc25833f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

11
main.go

@ -4,14 +4,11 @@ import (
"flag"
"fmt"
"log"
"strings"
"time"
"sync"
"time"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cbind"
"gitlab.com/tslocum/cview"
"gitlab.com/tslocum/joker"
@ -29,7 +26,7 @@ var (
app *cview.Application
inputConfig *cbind.Configuration
statusText *cview.TextView
statusText *StatusTextView
gameText *cview.TextView
inputField *cview.InputField
@ -277,7 +274,7 @@ func main() {
statusGrid.AddItem(cview.NewTextView(), 1, 0, 1, 1, 0, 0, false)
statusGrid.AddItem(gameText, 2, 1, 1, 1, 0, 0, false)
statusText = cview.NewTextView()
statusText = NewStatusTextView()
inputField = cview.NewInputField().
SetText("").

34
statustextview.go

@ -0,0 +1,34 @@
package main
import (
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
type StatusTextView struct {
*cview.TextView
}
func NewStatusTextView() *StatusTextView {
return &StatusTextView{cview.NewTextView()}
}
// MouseHandler returns the mouse handler for this primitive.
func (t *StatusTextView) MouseHandler() func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive) {
return t.WrapMouseHandler(func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive) {
x, y := event.Position()
if !t.InRect(x, y) {
return false, nil
}
switch action {
case cview.MouseLeftClick:
doAction()
consumed = true
setFocus(t)
}
return
})
}
Loading…
Cancel
Save