mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add a global Redraw method for TextWidget
Partially addresses #429, by centralizing widget drawing
This commit is contained in:
@@ -13,6 +13,7 @@ type TextWidget struct {
|
||||
focusChar string
|
||||
name string
|
||||
refreshInterval int
|
||||
app *tview.Application
|
||||
|
||||
View *tview.TextView
|
||||
|
||||
@@ -24,6 +25,7 @@ func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable
|
||||
widget := TextWidget{
|
||||
CommonSettings: commonSettings,
|
||||
|
||||
app: app,
|
||||
enabled: commonSettings.Enabled,
|
||||
focusable: focusable,
|
||||
focusChar: commonSettings.FocusChar(),
|
||||
@@ -107,6 +109,16 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
||||
return widget.View
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Redraw(title, text string, wrap bool) {
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.Clear()
|
||||
widget.View.SetWrap(wrap)
|
||||
widget.View.SetTitle(widget.ContextualTitle(title))
|
||||
widget.View.SetText(text)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *TextWidget) addView() *tview.TextView {
|
||||
|
||||
Reference in New Issue
Block a user