1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'master' into abstractscrollable

This commit is contained in:
Chris Cummer 2019-05-10 23:26:14 -07:00 committed by GitHub
commit 18ed770fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 3 deletions

View File

@ -7,6 +7,7 @@ builds:
goos:
- darwin
- linux
- windows
goarch:
- 386
- amd64

View File

@ -5,6 +5,8 @@
### ⚡️ Added
* DataDog module is now scrollable and interactive, by [@Seanstoppable](https://github.com/Seanstoppable)
* Focusable hot key numbers are now assigned in a stable order, [#435](https://github.com/wtfutil/wtf/issues/435) by [@Seanstoppable](https://github.com/Seanstoppable)
* Zendesk widget now has help text, by [@Seanstoppable](https://github.com/Seanstoppable)
## v0.9.2

View File

@ -198,7 +198,7 @@ func MakeWidget(
widget = weather.NewWidget(app, pages, settings)
case "zendesk":
settings := zendesk.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig)
widget = zendesk.NewWidget(app, settings)
widget = zendesk.NewWidget(app, pages, settings)
default:
settings := unknown.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig)
widget = unknown.NewWidget(app, settings)

View File

@ -8,8 +8,23 @@ import (
"github.com/wtfutil/wtf/wtf"
)
const HelpText = `
Keyboard commands for Zendesk:
/: Show/hide this help window
j: Select the next item in the list
k: Select the previous item in the list
o: Open the selected item in a browser
arrow down: Select the next item in the list
arrow up: Select the previous item in the list
return: Open the selected item in a browser
`
// A Widget represents a Zendesk widget
type Widget struct {
wtf.HelpfulWidget
wtf.KeyboardWidget
wtf.ScrollableWidget
@ -18,10 +33,12 @@ type Widget struct {
}
// NewWidget creates a new instance of a widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
settings: settings,
}

View File

@ -1,6 +1,8 @@
package wtf
import (
"sort"
"github.com/olebedev/config"
"github.com/rivo/tview"
)
@ -177,6 +179,17 @@ func (tracker *FocusTracker) focusables() []Wtfable {
}
}
// Sort for deterministic ordering
sort.SliceStable(focusable[:], func(i, j int) bool {
if focusable[i].Top() < focusable[j].Top() {
return true
}
if focusable[i].Top() == focusable[j].Top() {
return focusable[i].Left() < focusable[j].Left()
}
return false
})
return focusable
}