Skip to content

Commit

Permalink
Merge branch 'master' into todoistmulti
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer authored May 13, 2019
2 parents 6a41935 + 6bdb0ce commit 5620db2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 69 deletions.
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ builds:
goos:
- darwin
- linux
- windows
goarch:
- 386
- amd64
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

## v0.10.0

### ⚡️ Added

* DataDog module is now scrollable and interactive, by [@Seanstoppable](https://github.com/Seanstoppable)
Expand Down
94 changes: 48 additions & 46 deletions checklist/checklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@ func (list *Checklist) Delete() {
list.Prev()
}

// Demote moves the selected item down in the checklist
func (list *Checklist) Demote() {
if list.IsUnselectable() {
return
}

j := list.selected + 1
if j >= len(list.Items) {
j = 0
}

list.Swap(list.selected, j)
list.selected = j
}

// IsSelectable returns true if the checklist has selectable items, false if it does not
func (list *Checklist) IsSelectable() bool {
return list.selected >= 0 && list.selected < len(list.Items)
Expand All @@ -78,14 +63,6 @@ func (list *Checklist) IsUnselectable() bool {
return !list.IsSelectable()
}

// Next selects the next item in the checklist
func (list *Checklist) Next() {
list.selected = list.selected + 1
if list.selected >= len(list.Items) {
list.selected = 0
}
}

// LongestLine returns the length of the longest checklist item's text
func (list *Checklist) LongestLine() int {
maxLen := 0
Expand All @@ -99,29 +76,6 @@ func (list *Checklist) LongestLine() int {
return maxLen
}

// Prev selects the previous item in the checklist
func (list *Checklist) Prev() {
list.selected = list.selected - 1
if list.selected < 0 {
list.selected = len(list.Items) - 1
}
}

// Promote moves the selected item up in the checklist
func (list *Checklist) Promote() {
if list.IsUnselectable() {
return
}

j := list.selected - 1
if j < 0 {
j = len(list.Items) - 1
}

list.Swap(list.selected, j)
list.selected = j
}

func (list *Checklist) Selected() int {
return list.selected
}
Expand Down Expand Up @@ -182,6 +136,54 @@ func (list *Checklist) Update(text string) {
item.Text = text
}

/* -------------------- Item Movement -------------------- */

// Prev selects the previous item UP in the checklist
func (list *Checklist) Prev() {
list.selected = list.selected - 1
if list.selected < 0 {
list.selected = len(list.Items) - 1
}
}

// Next selects the next item DOWN in the checklist
func (list *Checklist) Next() {
list.selected = list.selected + 1
if list.selected >= len(list.Items) {
list.selected = 0
}
}

// Promote moves the selected item UP in the checklist
func (list *Checklist) Promote() {
if list.IsUnselectable() {
return
}

k := list.selected - 1
if k < 0 {
k = len(list.Items) - 1
}

list.Swap(list.selected, k)
list.selected = k
}

// Demote moves the selected item DOWN in the checklist
func (list *Checklist) Demote() {
if list.IsUnselectable() {
return
}

j := list.selected + 1
if j >= len(list.Items) {
j = 0
}

list.Swap(list.selected, j)
list.selected = j
}

/* -------------------- Sort Interface -------------------- */

func (list *Checklist) Len() int {
Expand Down
22 changes: 0 additions & 22 deletions modules/git/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,25 +216,3 @@ func (widget *Widget) findGitRepositories(repositories []*GitRepo, directory str

return repositories
}

func (widget *Widget) Next() {
widget.Idx = widget.Idx + 1
if widget.Idx == len(widget.GitRepos) {
widget.Idx = 0
}

if widget.DisplayFunction != nil {
widget.DisplayFunction()
}
}

func (widget *Widget) Prev() {
widget.Idx = widget.Idx - 1
if widget.Idx < 0 {
widget.Idx = len(widget.GitRepos) - 1
}

if widget.DisplayFunction != nil {
widget.DisplayFunction()
}
}

0 comments on commit 5620db2

Please sign in to comment.