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:
commit
18ed770fe2
@ -7,6 +7,7 @@ builds:
|
|||||||
goos:
|
goos:
|
||||||
- darwin
|
- darwin
|
||||||
- linux
|
- linux
|
||||||
|
- windows
|
||||||
goarch:
|
goarch:
|
||||||
- 386
|
- 386
|
||||||
- amd64
|
- amd64
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
### ⚡️ Added
|
### ⚡️ Added
|
||||||
|
|
||||||
* DataDog module is now scrollable and interactive, by [@Seanstoppable](https://github.com/Seanstoppable)
|
* 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
|
## v0.9.2
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ func MakeWidget(
|
|||||||
widget = weather.NewWidget(app, pages, settings)
|
widget = weather.NewWidget(app, pages, settings)
|
||||||
case "zendesk":
|
case "zendesk":
|
||||||
settings := zendesk.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig)
|
settings := zendesk.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig)
|
||||||
widget = zendesk.NewWidget(app, settings)
|
widget = zendesk.NewWidget(app, pages, settings)
|
||||||
default:
|
default:
|
||||||
settings := unknown.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig)
|
settings := unknown.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig)
|
||||||
widget = unknown.NewWidget(app, settings)
|
widget = unknown.NewWidget(app, settings)
|
||||||
|
@ -8,8 +8,23 @@ import (
|
|||||||
"github.com/wtfutil/wtf/wtf"
|
"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
|
// A Widget represents a Zendesk widget
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
|
wtf.HelpfulWidget
|
||||||
wtf.KeyboardWidget
|
wtf.KeyboardWidget
|
||||||
wtf.ScrollableWidget
|
wtf.ScrollableWidget
|
||||||
|
|
||||||
@ -18,10 +33,12 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// 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{
|
widget := Widget{
|
||||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
|
||||||
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true),
|
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,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package wtf
|
package wtf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
"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
|
return focusable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user