mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Simplify the view loading for the keyboard widget
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
4a820dd0e5
commit
f9a06540f1
@ -40,8 +40,6 @@ func main() {
|
|||||||
|
|
||||||
generateWidgetFile(data)
|
generateWidgetFile(data)
|
||||||
generateSettingsFile(data)
|
generateSettingsFile(data)
|
||||||
|
|
||||||
fmt.Println("Done")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -23,7 +23,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.View.SetScrollable(true)
|
widget.View.SetScrollable(true)
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetDisplayFunction(widget.display)
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.Unselect()
|
widget.Unselect()
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
widget.client = cdsclient.New(cdsclient.Config{
|
widget.client = cdsclient.New(cdsclient.Config{
|
||||||
Host: settings.apiURL,
|
Host: settings.apiURL,
|
||||||
|
@ -42,8 +42,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.Unselect()
|
widget.Unselect()
|
||||||
widget.filters = []string{sdk.StatusWaiting, sdk.StatusBuilding}
|
widget.filters = []string{sdk.StatusWaiting, sdk.StatusBuilding}
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
widget.client = cdsclient.New(cdsclient.Config{
|
widget.client = cdsclient.New(cdsclient.Config{
|
||||||
Host: settings.apiURL,
|
Host: settings.apiURL,
|
||||||
BuitinConsumerAuthenticationToken: settings.token,
|
BuitinConsumerAuthenticationToken: settings.token,
|
||||||
|
@ -42,8 +42,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.Unselect()
|
widget.Unselect()
|
||||||
widget.filters = []string{sdk.StatusWaiting, sdk.StatusBuilding}
|
widget.filters = []string{sdk.StatusWaiting, sdk.StatusBuilding}
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
widget.client = cdsclient.New(cdsclient.Config{
|
widget.client = cdsclient.New(cdsclient.Config{
|
||||||
Host: settings.apiURL,
|
Host: settings.apiURL,
|
||||||
BuitinConsumerAuthenticationToken: settings.token,
|
BuitinConsumerAuthenticationToken: settings.token,
|
||||||
|
@ -27,8 +27,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetScrollable(true)
|
widget.View.SetScrollable(true)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.View.SetScrollable(true)
|
widget.View.SetScrollable(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
widget.SetRenderFunction(widget.display)
|
widget.SetRenderFunction(widget.display)
|
||||||
|
|
||||||
widget.createClient()
|
widget.createClient()
|
||||||
|
@ -75,8 +75,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
widget.unselect()
|
widget.unselect()
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -42,8 +42,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.SetDisplayFunction(widget.display)
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.GithubRepos = widget.buildRepoCollection(widget.settings.repositories)
|
widget.GithubRepos = widget.buildRepoCollection(widget.settings.repositories)
|
||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.View.SetRegions(true)
|
widget.View.SetRegions(true)
|
||||||
widget.SetDisplayFunction(widget.display)
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
@ -41,8 +42,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.Sources = widget.settings.repositories
|
widget.Sources = widget.settings.repositories
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.Unselect()
|
widget.Unselect()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Refresh)
|
widget.SetRenderFunction(widget.Refresh)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.View.SetRegions(true)
|
widget.View.SetRegions(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,8 +35,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.View.SetScrollable(true)
|
widget.View.SetScrollable(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.SetDisplayFunction(widget.Refresh)
|
widget.SetDisplayFunction(widget.Refresh)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetWordWrap(true)
|
widget.View.SetWordWrap(true)
|
||||||
widget.View.SetWrap(settings.wrapText)
|
widget.View.SetWrap(settings.wrapText)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.View.SetScrollable(true)
|
widget.View.SetScrollable(true)
|
||||||
widget.View.SetRegions(true)
|
widget.View.SetRegions(true)
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.Selected = -1
|
widget.Selected = -1
|
||||||
widget.SetItemCount(0)
|
widget.SetItemCount(0)
|
||||||
|
@ -28,8 +28,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ func firewallStateWindows() string {
|
|||||||
|
|
||||||
fwStat := utils.ExecuteCommand(cmd)
|
fwStat := utils.ExecuteCommand(cmd)
|
||||||
fwStat = strings.TrimSpace(fwStat) // Always sanitize PowerShell output: "3\r\n"
|
fwStat = strings.TrimSpace(fwStat) // Always sanitize PowerShell output: "3\r\n"
|
||||||
//fmt.Printf("%d %q\n", len(fwStat), fwStat)
|
|
||||||
|
|
||||||
switch fwStat {
|
switch fwStat {
|
||||||
case "3":
|
case "3":
|
||||||
|
@ -36,8 +36,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
widget.View.SetWordWrap(true)
|
widget.View.SetWordWrap(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +126,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
widget.View.SetWordWrap(true)
|
widget.View.SetWordWrap(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetWordWrap(true)
|
widget.View.SetWordWrap(true)
|
||||||
widget.View.SetWrap(settings.wrapText)
|
widget.View.SetWrap(settings.wrapText)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
go widget.watchForFileChanges()
|
go widget.watchForFileChanges()
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -50,7 +50,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetRegions(true)
|
widget.View.SetRegions(true)
|
||||||
widget.View.SetScrollable(true)
|
widget.View.SetScrollable(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
widget.SetRenderFunction(widget.display)
|
widget.SetRenderFunction(widget.display)
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -35,8 +35,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.SetDisplayFunction(widget.display)
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.display)
|
widget.SetRenderFunction(widget.display)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
go buildClient(&widget)
|
go buildClient(&widget)
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -27,8 +27,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
widget.View.SetWordWrap(true)
|
widget.View.SetWordWrap(true)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.SetDisplayFunction(widget.display)
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget.SetRenderFunction(widget.Render)
|
widget.SetRenderFunction(widget.Render)
|
||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ type BarGraph struct {
|
|||||||
maxStars int
|
maxStars int
|
||||||
starChar string
|
starChar string
|
||||||
|
|
||||||
Base
|
*Base
|
||||||
KeyboardWidget
|
*KeyboardWidget
|
||||||
|
|
||||||
View *tview.TextView
|
View *tview.TextView
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ type Base struct {
|
|||||||
|
|
||||||
// NewBase creates and returns an instance of the Base module, the lowest-level
|
// NewBase creates and returns an instance of the Base module, the lowest-level
|
||||||
// primitive module from which all others are derived
|
// primitive module from which all others are derived
|
||||||
func NewBase(app *tview.Application, commonSettings *cfg.Common) Base {
|
func NewBase(app *tview.Application, commonSettings *cfg.Common) *Base {
|
||||||
base := Base{
|
base := &Base{
|
||||||
commonSettings: commonSettings,
|
commonSettings: commonSettings,
|
||||||
|
|
||||||
app: app,
|
app: app,
|
||||||
|
@ -32,8 +32,8 @@ type KeyboardWidget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewKeyboardWidget creates and returns a new instance of KeyboardWidget
|
// NewKeyboardWidget creates and returns a new instance of KeyboardWidget
|
||||||
func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg.Common) KeyboardWidget {
|
func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg.Common) *KeyboardWidget {
|
||||||
keyWidget := KeyboardWidget{
|
keyWidget := &KeyboardWidget{
|
||||||
app: app,
|
app: app,
|
||||||
pages: pages,
|
pages: pages,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
@ -50,6 +50,17 @@ func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg
|
|||||||
|
|
||||||
/* -------------------- Exported Functions --------------------- */
|
/* -------------------- Exported Functions --------------------- */
|
||||||
|
|
||||||
|
// AssignedChars returns a list of all the text characters assigned to an operation
|
||||||
|
func (widget *KeyboardWidget) AssignedChars() []string {
|
||||||
|
chars := []string{}
|
||||||
|
|
||||||
|
for char := range widget.charMap {
|
||||||
|
chars = append(chars, char)
|
||||||
|
}
|
||||||
|
|
||||||
|
return chars
|
||||||
|
}
|
||||||
|
|
||||||
// HelpText returns the help text and keyboard command info for this widget
|
// HelpText returns the help text and keyboard command info for this widget
|
||||||
func (widget *KeyboardWidget) HelpText() string {
|
func (widget *KeyboardWidget) HelpText() string {
|
||||||
str := " [green::b]Keyboard commands for " + strings.Title(widget.settings.Module.Type) + "[white]\n\n"
|
str := " [green::b]Keyboard commands for " + strings.Title(widget.settings.Module.Type) + "[white]\n\n"
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func test() {}
|
func test() {}
|
||||||
|
|
||||||
func testKeyboardWidget() KeyboardWidget {
|
func testKeyboardWidget() *KeyboardWidget {
|
||||||
keyWid := NewKeyboardWidget(
|
keyWid := NewKeyboardWidget(
|
||||||
tview.NewApplication(),
|
tview.NewApplication(),
|
||||||
tview.NewPages(),
|
tview.NewPages(),
|
||||||
@ -118,25 +118,25 @@ func Test_SetKeyboardKey(t *testing.T) {
|
|||||||
func Test_InputCapture(t *testing.T) {
|
func Test_InputCapture(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
before func(keyWid KeyboardWidget) KeyboardWidget
|
before func(keyWid *KeyboardWidget) *KeyboardWidget
|
||||||
event *tcell.EventKey
|
event *tcell.EventKey
|
||||||
expected *tcell.EventKey
|
expected *tcell.EventKey
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "with nil event",
|
name: "with nil event",
|
||||||
before: func(keyWid KeyboardWidget) KeyboardWidget { return keyWid },
|
before: func(keyWid *KeyboardWidget) *KeyboardWidget { return keyWid },
|
||||||
event: nil,
|
event: nil,
|
||||||
expected: nil,
|
expected: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with undefined event",
|
name: "with undefined event",
|
||||||
before: func(keyWid KeyboardWidget) KeyboardWidget { return keyWid },
|
before: func(keyWid *KeyboardWidget) *KeyboardWidget { return keyWid },
|
||||||
event: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
|
event: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
|
||||||
expected: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
|
expected: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with defined event and char handler",
|
name: "with defined event and char handler",
|
||||||
before: func(keyWid KeyboardWidget) KeyboardWidget {
|
before: func(keyWid *KeyboardWidget) *KeyboardWidget {
|
||||||
keyWid.SetKeyboardChar("a", test, "help")
|
keyWid.SetKeyboardChar("a", test, "help")
|
||||||
return keyWid
|
return keyWid
|
||||||
},
|
},
|
||||||
@ -145,7 +145,7 @@ func Test_InputCapture(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with defined event and key handler",
|
name: "with defined event and key handler",
|
||||||
before: func(keyWid KeyboardWidget) KeyboardWidget {
|
before: func(keyWid *KeyboardWidget) *KeyboardWidget {
|
||||||
keyWid.SetKeyboardKey(tcell.KeyRune, test, "help")
|
keyWid.SetKeyboardKey(tcell.KeyRune, test, "help")
|
||||||
return keyWid
|
return keyWid
|
||||||
},
|
},
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
// TextWidget defines the data necessary to make a text widget
|
// TextWidget defines the data necessary to make a text widget
|
||||||
type TextWidget struct {
|
type TextWidget struct {
|
||||||
Base
|
*Base
|
||||||
KeyboardWidget
|
*KeyboardWidget
|
||||||
|
|
||||||
View *tview.TextView
|
View *tview.TextView
|
||||||
}
|
}
|
||||||
@ -24,7 +24,9 @@ func NewTextWidget(app *tview.Application, pages *tview.Pages, commonSettings *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
widget.View = widget.createView(widget.bordered)
|
widget.View = widget.createView(widget.bordered)
|
||||||
widget.View.SetInputCapture(widget.InputCapture)
|
widget.View.SetInputCapture(widget.KeyboardWidget.InputCapture)
|
||||||
|
|
||||||
|
widget.KeyboardWidget.SetView(widget.View)
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user