@@ -3,13 +3,15 @@ package controllers
33import (
44 "errors"
55 "fmt"
6- "strconv "
6+ "strings "
77
8+ "github.com/gookit/color"
89 "github.com/jesseduffield/gocui"
910 "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
1011 "github.com/jesseduffield/lazygit/pkg/commands/models"
1112 "github.com/jesseduffield/lazygit/pkg/gui/context"
1213 "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
14+ "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
1315 "github.com/jesseduffield/lazygit/pkg/gui/style"
1416 "github.com/jesseduffield/lazygit/pkg/gui/types"
1517 "github.com/jesseduffield/lazygit/pkg/utils"
@@ -206,10 +208,13 @@ func (self *BranchesController) GetOnRenderToMain() func() {
206208 )
207209
208210 if pr , ok := prs [branch .Name ]; ok {
209- ptyTask .Prefix = fmt .Sprintf ("%s %s (%s)\n \n " ,
210- coloredPrNumber (pr ),
211- style .FgYellow .Sprint (style .PrintHyperlink (pr .Title , pr .Url )),
212- pr .State )
211+ ptyTask .Prefix = style .PrintHyperlink (fmt .Sprintf ("%s %s %s %s\n " ,
212+ icons .IconForRemoteUrl (pr .Url ),
213+ coloredStateText (pr .State ),
214+ pr .Title ,
215+ style .FgCyan .Sprintf ("#%d" , pr .Number )),
216+ pr .Url )
217+ ptyTask .Prefix += strings .Repeat ("─" , self .c .Contexts ().Normal .GetView ().InnerWidth ()) + "\n "
213218 }
214219 }
215220
@@ -224,20 +229,56 @@ func (self *BranchesController) GetOnRenderToMain() func() {
224229 }
225230}
226231
227- func coloredPrNumber (pr * models.GithubPullRequest ) string {
228- return prColor (pr .State ).Sprint ("#" + strconv .Itoa (pr .Number ))
232+ func stateText (state string ) string {
233+ // TODO: add icons only if nerd fonts are used
234+ switch state {
235+ case "OPEN" :
236+ return " Open"
237+ case "CLOSED" :
238+ return " Closed"
239+ case "MERGED" :
240+ return " Merged"
241+ case "DRAFT" :
242+ return " Draft"
243+ default :
244+ return ""
245+ }
246+ }
247+
248+ func coloredStateText (state string ) string {
249+ return fmt .Sprintf ("%s%s%s" ,
250+ withPrFgColor (state , "" ),
251+ withPrBgColor (state , style .FgWhite .Sprint (stateText (state ))),
252+ withPrFgColor (state , "" ))
253+ }
254+
255+ func withPrFgColor (state string , text string ) string {
256+ switch state {
257+ case "OPEN" :
258+ return style .FgGreen .Sprint (text )
259+ case "CLOSED" :
260+ return style .FgRed .Sprint (text )
261+ case "MERGED" :
262+ return style .FgMagenta .Sprint (text )
263+ case "DRAFT" :
264+ return color .RGB (0x66 , 0x66 , 0x66 , false ).Sprint (text )
265+ default :
266+ return style .FgDefault .Sprint (text )
267+ }
229268}
230269
231- func prColor (state string ) style. TextStyle {
270+ func withPrBgColor (state string , text string ) string {
232271 switch state {
233272 case "OPEN" :
234- return style .FgGreen
273+ return style .BgGreen . Sprint ( text )
235274 case "CLOSED" :
236- return style .FgRed
275+ return style .BgRed . Sprint ( text )
237276 case "MERGED" :
238- return style .FgMagenta
277+ return style .BgMagenta .Sprint (text )
278+ case "DRAFT" :
279+ return color .RGB (0x66 , 0x66 , 0x66 , true ).Sprint (text )
239280 default :
240- return style .FgDefault
281+ return style .BgDefault . Sprint ( text )
241282 }
242283}
243284
0 commit comments