mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Remove the app.Draw() gorountine
Prefer to have widgets force a draw when their data changes. This should reduce draws (unless the user has a module installed that updates >= 1/sec, the old draw default). This should also remove a source of some of the race conditions that users were experiencing (though not all, there are still many).
This commit is contained in:
@@ -40,7 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget("textfile", "filePath", "filePaths"),
|
||||
TextWidget: wtf.NewTextWidget("TextFile", "textfile", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "TextFile", "textfile", true),
|
||||
}
|
||||
|
||||
// Don't use a timer for this widget, watch for filesystem changes instead
|
||||
@@ -54,9 +54,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetWordWrap(true)
|
||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||
widget.View.SetChangedFunc(func() {
|
||||
app.Draw()
|
||||
})
|
||||
|
||||
go widget.watchForFileChanges()
|
||||
|
||||
@@ -85,8 +82,10 @@ func (widget *Widget) display() {
|
||||
text = text + widget.plainText()
|
||||
}
|
||||
|
||||
widget.View.SetTitle(title)
|
||||
widget.View.SetText(text)
|
||||
//widget.View.Lock()
|
||||
widget.View.SetTitle(title) // <- Writes to TextView's title
|
||||
widget.View.SetText(text) // <- Writes to TextView's text
|
||||
//widget.View.Unlock()
|
||||
}
|
||||
|
||||
func (widget *Widget) fileName() string {
|
||||
|
||||
Reference in New Issue
Block a user