From dccf04a27a5d63f07f1b3ad2a88604697515071e Mon Sep 17 00:00:00 2001 From: Anand Sudhir Prayaga Date: Tue, 28 Aug 2018 17:52:11 +0200 Subject: [PATCH] Make Jira widget scrollable Adds ability to scroll through the list of issues when they don't fit into the view --- jira/widget.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jira/widget.go b/jira/widget.go index 4fcac8ab..b1e248a6 100644 --- a/jira/widget.go +++ b/jira/widget.go @@ -6,6 +6,7 @@ import ( "github.com/gdamore/tcell" "github.com/rivo/tview" "github.com/senorprogrammer/wtf/wtf" + "strconv" ) const HelpText = ` @@ -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 } @@ -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() { @@ -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,