From 4c0efdcb4148c3da7d1ec49ac02aa27709f2aaf5 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sun, 21 Feb 2021 17:34:38 +0300 Subject: [PATCH] use suspend/resume api in tcell v2.2.0 cc #480 --- app.go | 2 +- go.mod | 4 ++-- go.sum | 17 ++++++++++------- ui.go | 21 +++------------------ 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/app.go b/app.go index 7f4aece..a66b3f9 100644 --- a/app.go +++ b/app.go @@ -405,7 +405,7 @@ func (app *app) runShell(s string, args []string, prefix string) { cmd.Stderr = os.Stderr app.nav.previewChan <- "" - app.ui.pause() + app.ui.suspend() defer app.ui.resume() defer app.nav.renew() diff --git a/go.mod b/go.mod index 68bce9a..dbd424c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/gokcehan/lf go 1.12 require ( - github.com/gdamore/tcell/v2 v2.0.0 - github.com/mattn/go-runewidth v0.0.9 + github.com/gdamore/tcell/v2 v2.2.0 + github.com/mattn/go-runewidth v0.0.10 gopkg.in/djherbis/times.v1 v1.2.0 ) diff --git a/go.sum b/go.sum index e13fac5..6f26e72 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,17 @@ 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/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs= -github.com/gdamore/tcell/v2 v2.0.0/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/mattn/go-runewidth v0.0.7/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= -golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10= -golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +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= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/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/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/djherbis/times.v1 v1.2.0 h1:UCvDKl1L/fmBygl2Y7hubXCnY7t4Yj46ZrBFNUipFbM= diff --git a/ui.go b/ui.go index 797a739..eabb100 100644 --- a/ui.go +++ b/ui.go @@ -1143,27 +1143,12 @@ func (ui *ui) readExpr() { }() } -func (ui *ui) pause() { - ui.screen.Fini() +func (ui *ui) suspend() { + ui.screen.Suspend() } func (ui *ui) resume() { - var screen tcell.Screen - var err error - if screen, err = tcell.NewScreen(); err != nil { - log.Fatalf("creating screen: %s", err) - } else if err = screen.Init(); err != nil { - log.Fatalf("initializing screen: %s", err) - } - if gOpts.mouse { - screen.EnableMouse() - } - - ui.screen = screen - - go ui.pollEvents() - - ui.renew() + ui.screen.Resume() } func listMatches(screen tcell.Screen, matches []string) (*bytes.Buffer, error) {