mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-1031 Rename WtfApp.app to WtfApp.tviewApp
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -30,10 +30,10 @@ type Bar struct {
|
||||
}
|
||||
|
||||
// NewBarGraph creates and returns an instance of BarGraph
|
||||
func NewBarGraph(app *tview.Application, name string, commonSettings *cfg.Common) BarGraph {
|
||||
func NewBarGraph(tviewApp *tview.Application, name string, commonSettings *cfg.Common) BarGraph {
|
||||
widget := BarGraph{
|
||||
Base: NewBase(app, commonSettings),
|
||||
KeyboardWidget: NewKeyboardWidget(app, nil, commonSettings),
|
||||
Base: NewBase(commonSettings),
|
||||
KeyboardWidget: NewKeyboardWidget(tviewApp, nil, commonSettings),
|
||||
|
||||
maxStars: commonSettings.Config.UInt("graphStars", 20),
|
||||
starChar: commonSettings.Config.UString("graphIcon", "|"),
|
||||
|
||||
@@ -4,32 +4,29 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
"github.com/wtfutil/wtf/utils"
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
app *tview.Application
|
||||
bordered bool
|
||||
commonSettings *cfg.Common
|
||||
enabled bool
|
||||
enabledMutex *sync.Mutex
|
||||
focusChar string
|
||||
focusable bool
|
||||
name string
|
||||
quitChan chan bool
|
||||
refreshing bool
|
||||
refreshInterval int
|
||||
enabledMutex *sync.Mutex
|
||||
refreshing bool
|
||||
}
|
||||
|
||||
// NewBase creates and returns an instance of the Base module, the lowest-level
|
||||
// primitive module from which all others are derived
|
||||
func NewBase(app *tview.Application, commonSettings *cfg.Common) *Base {
|
||||
func NewBase(commonSettings *cfg.Common) *Base {
|
||||
base := &Base{
|
||||
commonSettings: commonSettings,
|
||||
|
||||
app: app,
|
||||
bordered: commonSettings.Bordered,
|
||||
enabled: commonSettings.Enabled,
|
||||
enabledMutex: &sync.Mutex{},
|
||||
|
||||
@@ -19,10 +19,10 @@ type helpItem struct {
|
||||
|
||||
// KeyboardWidget manages keyboard control for a widget
|
||||
type KeyboardWidget struct {
|
||||
app *tview.Application
|
||||
pages *tview.Pages
|
||||
view *tview.TextView
|
||||
settings *cfg.Common
|
||||
tviewApp *tview.Application
|
||||
view *tview.TextView
|
||||
|
||||
charMap map[string]func()
|
||||
keyMap map[tcell.Key]func()
|
||||
@@ -32,9 +32,9 @@ type KeyboardWidget struct {
|
||||
}
|
||||
|
||||
// NewKeyboardWidget creates and returns a new instance of KeyboardWidget
|
||||
func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg.Common) *KeyboardWidget {
|
||||
func NewKeyboardWidget(tviewApp *tview.Application, pages *tview.Pages, settings *cfg.Common) *KeyboardWidget {
|
||||
keyWidget := &KeyboardWidget{
|
||||
app: app,
|
||||
tviewApp: tviewApp,
|
||||
pages: pages,
|
||||
settings: settings,
|
||||
charMap: make(map[string]func()),
|
||||
@@ -168,16 +168,16 @@ func (widget *KeyboardWidget) ShowHelp() {
|
||||
|
||||
closeFunc := func() {
|
||||
widget.pages.RemovePage("help")
|
||||
widget.app.SetFocus(widget.view)
|
||||
widget.tviewApp.SetFocus(widget.view)
|
||||
}
|
||||
|
||||
modal := NewBillboardModal(widget.HelpText(), closeFunc)
|
||||
|
||||
widget.pages.AddPage("help", modal, false, true)
|
||||
widget.app.SetFocus(modal)
|
||||
widget.tviewApp.SetFocus(modal)
|
||||
|
||||
widget.app.QueueUpdate(func() {
|
||||
widget.app.Draw()
|
||||
widget.tviewApp.QueueUpdate(func() {
|
||||
widget.tviewApp.Draw()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ type ScrollableWidget struct {
|
||||
RenderFunction func()
|
||||
}
|
||||
|
||||
func NewScrollableWidget(app *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) ScrollableWidget {
|
||||
func NewScrollableWidget(tviewApp *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) ScrollableWidget {
|
||||
widget := ScrollableWidget{
|
||||
TextWidget: NewTextWidget(app, pages, commonSettings),
|
||||
TextWidget: NewTextWidget(tviewApp, pages, commonSettings),
|
||||
}
|
||||
|
||||
widget.Unselect()
|
||||
@@ -84,7 +84,7 @@ func (widget *ScrollableWidget) Unselect() {
|
||||
func (widget *ScrollableWidget) Redraw(data func() (string, string, bool)) {
|
||||
widget.TextWidget.Redraw(data)
|
||||
|
||||
widget.Base.app.QueueUpdateDraw(func() {
|
||||
widget.tviewApp.QueueUpdateDraw(func() {
|
||||
widget.View.Highlight(strconv.Itoa(widget.Selected)).ScrollToHighlight()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ type TextWidget struct {
|
||||
}
|
||||
|
||||
// NewTextWidget creates and returns an instance of TextWidget
|
||||
func NewTextWidget(app *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) TextWidget {
|
||||
func NewTextWidget(tviewApp *tview.Application, pages *tview.Pages, commonSettings *cfg.Common) TextWidget {
|
||||
widget := TextWidget{
|
||||
Base: NewBase(app, commonSettings),
|
||||
KeyboardWidget: NewKeyboardWidget(app, pages, commonSettings),
|
||||
Base: NewBase(commonSettings),
|
||||
KeyboardWidget: NewKeyboardWidget(tviewApp, pages, commonSettings),
|
||||
}
|
||||
|
||||
widget.View = widget.createView(widget.bordered)
|
||||
@@ -39,7 +39,7 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Redraw(data func() (string, string, bool)) {
|
||||
widget.Base.app.QueueUpdateDraw(func() {
|
||||
widget.tviewApp.QueueUpdateDraw(func() {
|
||||
title, content, wrap := data()
|
||||
|
||||
widget.View.Clear()
|
||||
|
||||
Reference in New Issue
Block a user