Skip to content

Commit

Permalink
Make Jira widget scrollable
Browse files Browse the repository at this point in the history
Adds ability to scroll through the list of issues when they don't fit into the view
  • Loading branch information
anandsudhir committed Aug 28, 2018
1 parent 1c413c6 commit dccf04a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jira/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/gdamore/tcell"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
"strconv"
)

const HelpText = `
Expand Down Expand Up @@ -38,6 +39,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget.HelpfulWidget.SetView(widget.View)
widget.unselect()

widget.View.SetScrollable(true)
widget.View.SetRegions(true)
widget.View.SetInputCapture(widget.keyboardIntercept)
return &widget
}
Expand Down Expand Up @@ -75,8 +78,10 @@ func (widget *Widget) display() {

str := fmt.Sprintf("%s- [green]%s[white]", widget.Name, wtf.Config.UString("wtf.mods.jira.project"))

widget.View.Clear()
widget.View.SetTitle(widget.ContextualTitle(str))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.result)))
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
}

func (widget *Widget) next() {
Expand Down Expand Up @@ -110,7 +115,8 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {

for idx, issue := range searchResult.Issues {
fmtStr := fmt.Sprintf(
"[%s] [%s]%-6s[white] [green]%-10s[white] [%s]%s",
`["%d"][""][%s] [%s]%-6s[white] [green]%-10s[white] [%s]%s`,
idx,
widget.rowColor(idx),
widget.issueTypeColor(&issue),
issue.IssueFields.IssueType.Name,
Expand Down

0 comments on commit dccf04a

Please sign in to comment.