mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Flip todoist over to multiview widget
This can also probably be made scrollable in the future as well
This commit is contained in:
parent
cbb147f41e
commit
6a41935e61
@ -19,7 +19,7 @@ func (widget *Widget) display() {
|
|||||||
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
|
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
|
||||||
|
|
||||||
_, _, width, _ := widget.View.GetRect()
|
_, _, width, _ := widget.View.GetRect()
|
||||||
str := widget.settings.common.SigilStr(len(widget.projects), widget.idx, width) + "\n"
|
str := widget.settings.common.SigilStr(len(widget.projects), widget.Idx, width) + "\n"
|
||||||
|
|
||||||
maxLen := proj.LongestLine()
|
maxLen := proj.LongestLine()
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ func (widget *Widget) initializeKeyboardControls() {
|
|||||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||||
widget.SetKeyboardChar("c", widget.Close, "Close item")
|
widget.SetKeyboardChar("c", widget.Close, "Close item")
|
||||||
widget.SetKeyboardChar("d", widget.Delete, "Delete item")
|
widget.SetKeyboardChar("d", widget.Delete, "Delete item")
|
||||||
widget.SetKeyboardChar("h", widget.PreviousProject, "Select previous project")
|
widget.SetKeyboardChar("h", widget.Prev, "Select previous project")
|
||||||
widget.SetKeyboardChar("j", widget.Up, "Select previous item")
|
widget.SetKeyboardChar("j", widget.Up, "Select previous item")
|
||||||
widget.SetKeyboardChar("k", widget.Down, "Select next item")
|
widget.SetKeyboardChar("k", widget.Down, "Select next item")
|
||||||
widget.SetKeyboardChar("l", widget.NextProject, "Select next project")
|
widget.SetKeyboardChar("l", widget.Next, "Select next project")
|
||||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
||||||
|
|
||||||
widget.SetKeyboardKey(tcell.KeyDown, widget.Down, "Select next item")
|
widget.SetKeyboardKey(tcell.KeyDown, widget.Down, "Select next item")
|
||||||
widget.SetKeyboardKey(tcell.KeyLeft, widget.PreviousProject, "Select previous project")
|
widget.SetKeyboardKey(tcell.KeyLeft, widget.Prev, "Select previous project")
|
||||||
widget.SetKeyboardKey(tcell.KeyRight, widget.NextProject, "Select next project")
|
widget.SetKeyboardKey(tcell.KeyRight, widget.Next, "Select next project")
|
||||||
widget.SetKeyboardKey(tcell.KeyUp, widget.Up, "Select previous item")
|
widget.SetKeyboardKey(tcell.KeyUp, widget.Up, "Select previous item")
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.KeyboardWidget
|
wtf.KeyboardWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
wtf.MultiSourceWidget
|
||||||
|
|
||||||
idx int
|
|
||||||
projects []*Project
|
projects []*Project
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
@ -22,6 +22,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
widget := Widget{
|
widget := Widget{
|
||||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "project", "projects"),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
@ -31,6 +32,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
widget.initializeKeyboardControls()
|
widget.initializeKeyboardControls()
|
||||||
widget.View.SetInputCapture(widget.InputCapture)
|
widget.View.SetInputCapture(widget.InputCapture)
|
||||||
|
widget.SetDisplayFunction(widget.display)
|
||||||
|
|
||||||
widget.KeyboardWidget.SetView(widget.View)
|
widget.KeyboardWidget.SetView(widget.View)
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) CurrentProject() *Project {
|
func (widget *Widget) CurrentProject() *Project {
|
||||||
return widget.ProjectAt(widget.idx)
|
return widget.ProjectAt(widget.Idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) ProjectAt(idx int) *Project {
|
func (widget *Widget) ProjectAt(idx int) *Project {
|
||||||
@ -51,24 +53,6 @@ func (widget *Widget) ProjectAt(idx int) *Project {
|
|||||||
return widget.projects[idx]
|
return widget.projects[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Widget) NextProject() {
|
|
||||||
w.idx = w.idx + 1
|
|
||||||
if w.idx == len(w.projects) {
|
|
||||||
w.idx = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
w.display()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Widget) PreviousProject() {
|
|
||||||
w.idx = w.idx - 1
|
|
||||||
if w.idx < 0 {
|
|
||||||
w.idx = len(w.projects) - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
w.display()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Widget) Refresh() {
|
func (w *Widget) Refresh() {
|
||||||
if w.Disabled() || w.CurrentProject() == nil {
|
if w.Disabled() || w.CurrentProject() == nil {
|
||||||
return
|
return
|
||||||
|
@ -149,7 +149,7 @@ func ToStrs(slice []interface{}) []string {
|
|||||||
results := []string{}
|
results := []string{}
|
||||||
|
|
||||||
for _, val := range slice {
|
for _, val := range slice {
|
||||||
results = append(results, val.(string))
|
results = append(results, fmt.Sprintf("%v", val))
|
||||||
}
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user