blob: a7cbc432900d279e02847243f67cc1b8037bea86 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package gui
import (
"fmt"
"github.com/isacikgoz/gitbatch/pkg/git"
"github.com/jroimartin/gocui"
)
// updates the remotesview for given entity
func (gui *Gui) updateRemotes(g *gocui.Gui, entity *git.RepoEntity) error {
var err error
out, err := g.View(remoteViewFeature.Name)
if err != nil {
return err
}
out.Clear()
currentindex := 0
totalRemotes := len(entity.Remotes)
if totalRemotes > 0 {
for i, r := range entity.Remotes {
// TODO: maybe the text styling can be moved to textstyle.go file
_, shortURL := trimRemoteURL(r.URL[0])
suffix := shortURL
if r.Name == entity.Remote.Name {
currentindex = i
fmt.Fprintln(out, selectionIndicator+r.Name+": "+suffix)
continue
}
fmt.Fprintln(out, tab+r.Name+": "+suffix)
}
if err = gui.smartAnchorRelativeToLine(out, currentindex, totalRemotes); err != nil {
return err
}
}
return nil
}
// iteration handler for the remotesview
func (gui *Gui) nextRemote(g *gocui.Gui, v *gocui.View) error {
var err error
entity := gui.getSelectedRepository()
if err = entity.NextRemote(); err != nil {
return err
}
if err = gui.updateRemotes(g, entity); err != nil {
return err
}
if err = gui.updateRemoteBranches(g, entity); err != nil {
return err
}
return err
}
|