mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Some code improvements
* Some assignments simplified by using assignment operators * Rewrite switch statement with only one case as if. * Rewrite if-else chain as a switch statement. * go fmt `modules/todoist/project.go` file.
This commit is contained in:
@@ -11,8 +11,7 @@ const modalHeight = 22
|
||||
|
||||
func NewBillboardModal(text string, closeFunc func()) *tview.Frame {
|
||||
keyboardIntercept := func(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch string(event.Rune()) {
|
||||
case "/":
|
||||
if string(event.Rune()) == "/" {
|
||||
closeFunc()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func (tracker *FocusTracker) blur(idx int) {
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) decrement() {
|
||||
tracker.Idx = tracker.Idx - 1
|
||||
tracker.Idx--
|
||||
|
||||
if tracker.Idx < 0 {
|
||||
tracker.Idx = len(tracker.focusables()) - 1
|
||||
@@ -216,7 +216,7 @@ func (tracker *FocusTracker) focusState() FocusState {
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) increment() {
|
||||
tracker.Idx = tracker.Idx + 1
|
||||
tracker.Idx++
|
||||
|
||||
if tracker.Idx == len(tracker.focusables()) {
|
||||
tracker.Idx = 0
|
||||
|
||||
@@ -89,12 +89,12 @@ func (widget *KeyboardWidget) HelpText() string {
|
||||
str := "Keyboard commands for " + widget.settings.Module.Type + "\n\n"
|
||||
|
||||
for _, item := range widget.charHelp {
|
||||
str = str + fmt.Sprintf(" [%s]: %s\n", item.Key, item.Text)
|
||||
str += fmt.Sprintf(" [%s]: %s\n", item.Key, item.Text)
|
||||
}
|
||||
str = str + "\n\n"
|
||||
str += "\n\n"
|
||||
|
||||
for _, item := range widget.keyHelp {
|
||||
str = str + fmt.Sprintf(" [%-*s]: %s\n", widget.maxKey, item.Key, item.Text)
|
||||
str += fmt.Sprintf(" [%-*s]: %s\n", widget.maxKey, item.Key, item.Text)
|
||||
}
|
||||
|
||||
return str
|
||||
|
||||
@@ -45,7 +45,7 @@ func (widget *MultiSourceWidget) CurrentSource() string {
|
||||
// Next displays the next source in the source list. If the current source is the last
|
||||
// source it wraps around to the first source
|
||||
func (widget *MultiSourceWidget) NextSource() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
widget.Idx++
|
||||
if widget.Idx == len(widget.Sources) {
|
||||
widget.Idx = 0
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (widget *MultiSourceWidget) NextSource() {
|
||||
// Prev displays the previous source in the source list. If the current source is the first
|
||||
// source, it wraps around to the last source
|
||||
func (widget *MultiSourceWidget) PrevSource() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
widget.Idx--
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.Sources) - 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user