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

Pressing Return/Enter in the GitHub widget opens the repo GitHub page

This commit is contained in:
Chris Cummer 2018-09-25 16:16:08 -07:00
parent c35c4e2e1d
commit e4efd6ed72
3 changed files with 16 additions and 1 deletions

View File

@ -32,6 +32,10 @@ func NewGithubRepo(name, owner string) *GithubRepo {
return &repo
}
func (repo *GithubRepo) Open() {
wtf.OpenFile(*repo.RemoteRepo.HTMLURL)
}
// Refresh reloads the github data via the Github API
func (repo *GithubRepo) Refresh() {
repo.PullRequests, _ = repo.loadPullRequests()

View File

@ -113,6 +113,9 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
}
switch event.Key() {
case tcell.KeyEnter:
widget.openRepo()
return nil
case tcell.KeyLeft:
widget.Prev()
return nil
@ -123,3 +126,11 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
return event
}
}
func (widget *Widget) openRepo() {
repo := widget.currentGithubRepo()
if repo != nil {
repo.Open()
}
}

View File

@ -219,7 +219,7 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
case "status":
widgets = append(widgets, status.NewWidget(app))
case "system":
widgets = append(widgets, system.NewWidget(date, version))
widgets = append(widgets, system.NewWidget(app, date, version))
case "spotify":
widgets = append(widgets, spotify.NewWidget(app, pages))
case "textfile":