1
0
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:
Sean Smith
2019-05-07 20:49:46 -04:00
committed by Chris Cummer
parent aedcf9dd51
commit 018d2af3ae
48 changed files with 194 additions and 412 deletions

View File

@@ -9,12 +9,11 @@ import (
func (widget *Widget) display() {
repoData := widget.currentData()
if repoData == nil {
widget.View.SetText(" Mercurial repo data is unavailable ")
widget.Redraw(widget.CommonSettings.Title, " Mercurial repo data is unavailable ", false)
return
}
title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings.Title, repoData.Repository)
widget.View.SetTitle(widget.ContextualTitle(title))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
@@ -25,7 +24,7 @@ func (widget *Widget) display() {
str = str + "\n"
str = str + widget.formatCommits(repoData.Commits)
widget.View.SetText(str)
widget.Redraw(title, str, false)
}
func (widget *Widget) formatChanges(data []string) string {

View File

@@ -71,9 +71,7 @@ func (widget *Widget) Checkout() {
widget.pages.RemovePage("modal")
widget.app.SetFocus(widget.View)
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
widget.Refresh()
}
@@ -86,7 +84,6 @@ func (widget *Widget) Pull() {
repoToPull := widget.Data[widget.Idx]
repoToPull.pull()
widget.Refresh()
}
func (widget *Widget) Refresh() {
@@ -94,9 +91,7 @@ func (widget *Widget) Refresh() {
widget.Data = widget.mercurialRepos(repoPaths)
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@@ -122,9 +117,11 @@ func (widget *Widget) addCancelButton(form *tview.Form) {
}
func (widget *Widget) modalFocus(form *tview.Form) {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
widget.app.QueueUpdateDraw(func() {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
})
}
func (widget *Widget) modalForm(lbl, text string) *tview.Form {