summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/jesseduffield/gocui
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/jesseduffield/gocui')
-rw-r--r--vendor/github.com/jesseduffield/gocui/gui.go29
-rw-r--r--vendor/github.com/jesseduffield/gocui/tcell_driver.go4
2 files changed, 23 insertions, 10 deletions
diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go
index 47590f959..d07287685 100644
--- a/vendor/github.com/jesseduffield/gocui/gui.go
+++ b/vendor/github.com/jesseduffield/gocui/gui.go
@@ -177,13 +177,26 @@ type Gui struct {
taskManager *TaskManager
}
+type NewGuiOpts struct {
+ OutputMode OutputMode
+ SupportOverlaps bool
+ PlayRecording bool
+ Headless bool
+ // only applicable when Headless is true
+ Width int
+ // only applicable when Headless is true
+ Height int
+
+ RuneReplacements map[rune]string
+}
+
// NewGui returns a new Gui object with a given output mode.
-func NewGui(mode OutputMode, supportOverlaps bool, playRecording bool, headless bool, runeReplacements map[rune]string) (*Gui, error) {
+func NewGui(opts NewGuiOpts) (*Gui, error) {
g := &Gui{}
var err error
- if headless {
- err = g.tcellInitSimulation()
+ if opts.Headless {
+ err = g.tcellInitSimulation(opts.Width, opts.Height)
} else {
err = g.tcellInit(runeReplacements)
}
@@ -191,7 +204,7 @@ func NewGui(mode OutputMode, supportOverlaps bool, playRecording bool, headless
return nil, err
}
- if headless || runtime.GOOS == "windows" {
+ if opts.Headless || runtime.GOOS == "windows" {
g.maxX, g.maxY = g.screen.Size()
} else {
// TODO: find out if we actually need this bespoke logic for linux
@@ -201,7 +214,7 @@ func NewGui(mode OutputMode, supportOverlaps bool, playRecording bool, headless
}
}
- g.outputMode = mode
+ g.outputMode = opts.OutputMode
g.stop = make(chan struct{})
@@ -209,7 +222,7 @@ func NewGui(mode OutputMode, supportOverlaps bool, playRecording bool, headless
g.userEvents = make(chan userEvent, 20)
g.taskManager = newTaskManager()
- if playRecording {
+ if opts.PlayRecording {
g.ReplayedEvents = replayedEvents{
Keys: make(chan *TcellKeyEventWrapper),
Resizes: make(chan *TcellResizeEventWrapper),
@@ -221,14 +234,14 @@ func NewGui(mode OutputMode, supportOverlaps bool, playRecording bool, headless
// SupportOverlaps is true when we allow for view edges to overlap with other
// view edges
- g.SupportOverlaps = supportOverlaps
+ g.SupportOverlaps = opts.SupportOverlaps
// default keys for when searching strings in a view
g.SearchEscapeKey = KeyEsc
g.NextSearchMatchKey = 'n'
g.PrevSearchMatchKey = 'N'
- g.playRecording = playRecording
+ g.playRecording = opts.PlayRecording
return g, nil
}
diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go
index 59238ed07..545996804 100644
--- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go
+++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go
@@ -81,7 +81,7 @@ func registerRuneFallbacks(s tcell.Screen, additional map[rune]string) {
}
// tcellInitSimulation initializes tcell screen for use.
-func (g *Gui) tcellInitSimulation() error {
+func (g *Gui) tcellInitSimulation(width int, height int) error {
s := tcell.NewSimulationScreen("")
if e := s.Init(); e != nil {
return e
@@ -90,7 +90,7 @@ func (g *Gui) tcellInitSimulation() error {
Screen = s
// setting to a larger value than the typical terminal size
// so that during a test we're more likely to see an item to select in a view.
- s.SetSize(100, 100)
+ s.SetSize(width, height)
s.Sync()
return nil
}