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:
@@ -2,7 +2,6 @@ package todo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/wtfutil/wtf/checklist"
|
||||
@@ -34,9 +33,7 @@ func (widget *Widget) display() {
|
||||
newList.SetSelectedByItem(widget.list.SelectedItem())
|
||||
widget.SetList(newList)
|
||||
|
||||
widget.View.Clear()
|
||||
widget.View.SetText(str)
|
||||
widget.View.Highlight(strconv.Itoa(widget.list.Selected())).ScrollToHighlight()
|
||||
widget.Redraw(widget.CommonSettings.Title, str, false)
|
||||
}
|
||||
|
||||
func (widget *Widget) formattedItemLine(idx int, item *checklist.ChecklistItem, selectedItem *checklist.ChecklistItem, maxLen int) string {
|
||||
|
||||
@@ -79,13 +79,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.load()
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
title := widget.ContextualTitle(widget.CommonSettings.Title)
|
||||
widget.View.SetTitle(title)
|
||||
widget.display()
|
||||
})
|
||||
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) SetList(list checklist.Checklist) {
|
||||
@@ -198,10 +192,9 @@ func (widget *Widget) addSaveButton(form *tview.Form, fctn func()) {
|
||||
}
|
||||
|
||||
func (widget *Widget) modalFocus(form *tview.Form) {
|
||||
frame := widget.modalFrame(form)
|
||||
widget.pages.AddPage("modal", frame, false, true)
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
frame := widget.modalFrame(form)
|
||||
widget.pages.AddPage("modal", frame, false, true)
|
||||
widget.app.SetFocus(frame)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user