Skip to content

Commit

Permalink
Merge branch 'master' into abstractscrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer committed May 11, 2019
2 parents 210723c + 04fae35 commit 18ed770
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Expand Up @@ -7,6 +7,7 @@ builds:
goos:
- darwin
- linux
- windows
goarch:
- 386
- amd64
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion maker/widget_maker.go
Expand Up @@ -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)
Expand Down
21 changes: 19 additions & 2 deletions modules/zendesk/widget.go
Expand Up @@ -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

Expand All @@ -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,
}
Expand Down
13 changes: 13 additions & 0 deletions wtf/focus_tracker.go
@@ -1,6 +1,8 @@
package wtf

import (
"sort"

"github.com/olebedev/config"
"github.com/rivo/tview"
)
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 18ed770

Please sign in to comment.