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

Rough draft of adding new items to Todo

This commit is contained in:
Chris Cummer
2018-04-28 21:32:06 -07:00
parent c63d92a1f7
commit 4a30de5d51
4 changed files with 73 additions and 30 deletions

View File

@@ -17,6 +17,10 @@ type FocusTracker struct {
// Next sets the focus on the next widget in the widget list. If the current widget is
// the last widget, sets focus on the first widget.
func (tracker *FocusTracker) Next() {
//if tracker.widgetHasFocus() == false {
//return
//}
tracker.blur(tracker.Idx)
tracker.increment()
tracker.focus(tracker.Idx)
@@ -30,12 +34,16 @@ func (tracker *FocusTracker) None() {
// Prev sets the focus on the previous widget in the widget list. If the current widget is
// the last widget, sets focus on the last widget.
func (tracker *FocusTracker) Prev() {
//if tracker.widgetHasFocus() == false {
//return
//}
tracker.blur(tracker.Idx)
tracker.decrement()
tracker.focus(tracker.Idx)
}
/* -------------------- Exported Functions -------------------- */
/* -------------------- Unexported Functions -------------------- */
func (tracker *FocusTracker) blur(idx int) {
view := tracker.Widgets[idx].TextView()
@@ -64,3 +72,15 @@ func (tracker *FocusTracker) increment() {
tracker.Idx = 0
}
}
// widgetHasFocus returns true if one of the widgets currently has the app's focus,
// false if none of them do (ie: perhaps a modal dialog currently has it instead)
//func (tracker *FocusTracker) widgetHasFocus() bool {
//for _, widget := range tracker.Widgets {
//if widget.TextView() == tracker.App.GetFocus() {
//return true
//}
//}
//return false
//}

View File

@@ -66,6 +66,7 @@ func NamesFromEmails(emails []string) []string {
return names
}
// OpenFile opens the file defined in `path` via the operating system
func OpenFile(path string) {
confDir, _ := ConfigDir()
filePath := fmt.Sprintf("%s/%s", confDir, path)