Skip to content
Myr

Minor refactoring tcell library from tui.go to tcell.go

Before adoption: this commit came in with the history the project adopted, so no landing records it.

To prevent including tcell library in non-windows builds.

authored by Vlastimil Ovčáčík · committed by Junegunn Choi · parent 0ff8854 · Browse files · 2 files+16 added−17 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−17 removed

  • other:+16 added−17 removed

2 files+16 added−17 removed

modified:src/tui/tcell.go+6 added-3 removed
118 unmodified lines
119func (a Attr) Merge(b Attr) Attr {120 return a | b121}122123// handle the following as private members of FullscreenRenderer instance124// they are declared here to prevent introducing tcell library in non-windows builds125var (124 _screen tcell.Screen126 _screen tcell.Screen127 _prevMouseButton tcell.ButtonMask128)129130func (r *FullscreenRenderer) initScreen() {131 s, e := tcell.NewScreen()
63 unmodified lines
195 x, y := ev.Position()196 mod := ev.Modifiers() != 0197198 // since we dont have mouse down events (unlike LightRenderer), we need to track state in prevButton196 prevButton, button := r.prevMouseButton, ev.Buttons()197 r.prevMouseButton = button199 prevButton, button := _prevMouseButton, ev.Buttons()200 _prevMouseButton = button201 drag := prevButton == button202203 switch {204 case button&tcell.WheelDown != 0:
517 unmodified lines
modified:src/tui/tui.go+10 added-14 removed
3 unmodified lines
4 "fmt"5 "os"6 "strconv"7 "time"89 "github.com/gdamore/tcell"8)910// Types of user action11type EventType int
384 unmodified lines
396 Erase()397}398399type FullscreenRenderer struct {402 theme *ColorTheme403 mouse bool404 forceBlack bool405 prevDownTime time.Time406 prevMouseButton tcell.ButtonMask407 clickY []int400 theme *ColorTheme401 mouse bool402 forceBlack bool403 prevDownTime time.Time404 clickY []int405}406407func NewFullscreenRenderer(theme *ColorTheme, forceBlack bool, mouse bool) Renderer {408 r := &FullscreenRenderer{412 theme: theme,413 mouse: mouse,414 forceBlack: forceBlack,415 prevDownTime: time.Unix(0, 0),416 prevMouseButton: tcell.ButtonNone,417 clickY: []int{}}409 theme: theme,410 mouse: mouse,411 forceBlack: forceBlack,412 prevDownTime: time.Unix(0, 0),413 clickY: []int{}}414 return r415}416417var (
208 unmodified lines