1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Todo modal shows up much faster now, looks better

This commit is contained in:
Chris Cummer 2018-10-01 16:44:51 -07:00
parent ad86b24da1
commit 15968718af
6 changed files with 18 additions and 16 deletions

View File

@ -196,7 +196,7 @@ func (widget *Widget) load() {
} }
func (widget *Widget) newItem() { func (widget *Widget) newItem() {
form := widget.modalForm("New:", "") form := widget.modalForm("New Todo:", "")
saveFctn := func() { saveFctn := func() {
text := form.GetFormItem(0).(*tview.InputField).GetText() text := form.GetFormItem(0).(*tview.InputField).GetText()
@ -252,12 +252,15 @@ func (widget *Widget) modalFocus(form *tview.Form) {
frame := widget.modalFrame(form) frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true) widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame) widget.app.SetFocus(frame)
widget.app.Draw()
} }
func (widget *Widget) modalForm(lbl, text string) *tview.Form { func (widget *Widget) modalForm(lbl, text string) *tview.Form {
form := tview.NewForm(). form := tview.NewForm().
SetButtonsAlign(tview.AlignCenter). SetFieldBackgroundColor(wtf.ColorFor(wtf.Config.UString("wtf.colors.background", "black")))
SetButtonTextColor(tview.Styles.PrimaryTextColor)
form.SetButtonsAlign(tview.AlignCenter).
SetButtonTextColor(wtf.ColorFor(wtf.Config.UString("wtf.colors.text", "white")))
form.AddInputField(lbl, text, 60, nil, nil) form.AddInputField(lbl, text, 60, nil, nil)

View File

@ -97,9 +97,9 @@ func (widget *BarGraph) UpdateRefreshedAt() {
func (widget *BarGraph) addView() { func (widget *BarGraph) addView() {
view := tview.NewTextView() view := tview.NewTextView()
view.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black"))) view.SetBackgroundColor(ColorFor(Config.UString("wtf.colors.background", "black")))
view.SetBorder(true) view.SetBorder(true)
view.SetBorderColor(colorFor(widget.BorderColor())) view.SetBorderColor(ColorFor(widget.BorderColor()))
view.SetDynamicColors(true) view.SetDynamicColors(true)
view.SetTitle(widget.Name) view.SetTitle(widget.Name)
view.SetWrap(false) view.SetWrap(false)

View File

@ -421,9 +421,7 @@ func ASCIItoTviewColors(text string) string {
text, replaceWithHexColorString), `[::b]`), `[-]`) text, replaceWithHexColorString), `[::b]`), `[-]`)
} }
/* -------------------- Unexported Functions -------------------- */ func ColorFor(label string) tcell.Color {
func colorFor(label string) tcell.Color {
if _, ok := colors[label]; ok { if _, ok := colors[label]; ok {
return colors[label] return colors[label]
} }
@ -431,6 +429,8 @@ func colorFor(label string) tcell.Color {
return tcell.ColorGreen return tcell.ColorGreen
} }
/* -------------------- Unexported Functions -------------------- */
func replaceWithHexColorString(substring string) string { func replaceWithHexColorString(substring string) string {
colorID, err := strconv.Atoi(strings.Trim( colorID, err := strconv.Atoi(strings.Trim(
strings.Split(substring, ";")[2], "m")) strings.Split(substring, ";")[2], "m"))

View File

@ -14,7 +14,7 @@ func NewDisplay(widgets []Wtfable) *Display {
} }
display.build(widgets) display.build(widgets)
display.Grid.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black"))) display.Grid.SetBackgroundColor(ColorFor(Config.UString("wtf.colors.background", "black")))
return &display return &display
} }

View File

@ -115,7 +115,7 @@ func (tracker *FocusTracker) blur(idx int) {
view := widget.TextView() view := widget.TextView()
view.Blur() view.Blur()
view.SetBorderColor(colorFor(widget.BorderColor())) view.SetBorderColor(ColorFor(widget.BorderColor()))
} }
func (tracker *FocusTracker) decrement() { func (tracker *FocusTracker) decrement() {
@ -133,7 +133,7 @@ func (tracker *FocusTracker) focus(idx int) {
} }
view := widget.TextView() view := widget.TextView()
view.SetBorderColor(colorFor(Config.UString("wtf.colors.border.focused", "gray"))) view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.focused", "gray")))
tracker.App.SetFocus(view) tracker.App.SetFocus(view)
tracker.App.Draw() tracker.App.Draw()

View File

@ -96,24 +96,23 @@ func (widget *TextWidget) TextView() *tview.TextView {
/* -------------------- Unexported Functions -------------------- */ /* -------------------- Unexported Functions -------------------- */
func (widget *TextWidget) addView(app *tview.Application, configKey string) { func (widget *TextWidget) addView(app *tview.Application, configKey string) {
view := tview.NewTextView() view := tview.NewTextView()
view.SetBackgroundColor(colorFor( view.SetBackgroundColor(ColorFor(
Config.UString(fmt.Sprintf("wtf.mods.%s.colors.background", configKey), Config.UString(fmt.Sprintf("wtf.mods.%s.colors.background", configKey),
Config.UString("wtf.colors.background", "black"), Config.UString("wtf.colors.background", "black"),
), ),
)) ))
view.SetTextColor(colorFor( view.SetTextColor(ColorFor(
Config.UString( Config.UString(
fmt.Sprintf("wtf.mods.%s.colors.text", configKey), fmt.Sprintf("wtf.mods.%s.colors.text", configKey),
Config.UString("wtf.colors.text", "white"), Config.UString("wtf.colors.text", "white"),
), ),
)) ))
view.SetTitleColor(colorFor( view.SetTitleColor(ColorFor(
Config.UString( Config.UString(
fmt.Sprintf("wtf.mods.%s.colors.title", configKey), fmt.Sprintf("wtf.mods.%s.colors.title", configKey),
Config.UString("wtf.colors.title", "white"), Config.UString("wtf.colors.title", "white"),
@ -121,7 +120,7 @@ func (widget *TextWidget) addView(app *tview.Application, configKey string) {
)) ))
view.SetBorder(true) view.SetBorder(true)
view.SetBorderColor(colorFor(widget.BorderColor())) view.SetBorderColor(ColorFor(widget.BorderColor()))
view.SetChangedFunc(func() { view.SetChangedFunc(func() {
app.Draw() app.Draw()
}) })