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

Make Jira widget scrollable

Adds ability to scroll through the list of issues when they don't fit into the view
This commit is contained in:
Anand Sudhir Prayaga 2018-08-28 17:52:11 +02:00 committed by Anand Sudhir Prayaga
parent 1c413c60d8
commit dccf04a27a

View File

@ -6,6 +6,7 @@ import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf" "github.com/senorprogrammer/wtf/wtf"
"strconv"
) )
const HelpText = ` const HelpText = `
@ -38,6 +39,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget.HelpfulWidget.SetView(widget.View) widget.HelpfulWidget.SetView(widget.View)
widget.unselect() widget.unselect()
widget.View.SetScrollable(true)
widget.View.SetRegions(true)
widget.View.SetInputCapture(widget.keyboardIntercept) widget.View.SetInputCapture(widget.keyboardIntercept)
return &widget 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")) 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.SetTitle(widget.ContextualTitle(str))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.result))) widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.result)))
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
} }
func (widget *Widget) next() { func (widget *Widget) next() {
@ -110,7 +115,8 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
for idx, issue := range searchResult.Issues { for idx, issue := range searchResult.Issues {
fmtStr := fmt.Sprintf( 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.rowColor(idx),
widget.issueTypeColor(&issue), widget.issueTypeColor(&issue),
issue.IssueFields.IssueType.Name, issue.IssueFields.IssueType.Name,