Debian Codegraph @

internal/gui/overview.go

raw symbols SCIP
1 package gui
2
3 import (
4 "github.com/jroimartin/gocui"
5 )
6
7 // set the layout and create views with their default size, name etc. values
8 // TODO: window sizes can be handled better
9 func (gui *Gui) overviewLayout(g *gocui.Gui) error {
10 g.SelFgColor = gocui.ColorDefault
11 maxX, maxY := g.Size()
12 // dx := int(0.55 * float32(maxX))
13 dx := -2
14 if v, err := g.SetView(mainViewFrameFeature.Name, 0, 0, maxX-1, maxY-2); err != nil {
15 if err != gocui.ErrUnknownView {
16 return err
17 }
18 v.Title = mainViewFrameFeature.Title
19 }
20 if v, err := g.SetView(mainViewFeature.Name, 1, 1, maxX-1, maxY-2); err != nil {
21 if err != gocui.ErrUnknownView {
22 return err
23 }
24 v.Title = mainViewFeature.Title
25 v.Overwrite = true
26 if _, err := g.SetCurrentView(mainViewFeature.Name); err != nil {
27 return err
28 }
29 v.Frame = false
30 }
31 if v, err := g.SetView(remoteViewFeature.Name, dx, 0, -1, int(0.15*float32(maxY))-1); err != nil {
32 if err != gocui.ErrUnknownView {
33 return err
34 }
35 v.Title = remoteViewFeature.Title
36 v.Wrap = false
37 v.Autoscroll = false
38 }
39 if v, err := g.SetView(remoteBranchViewFeature.Name, dx, int(0.15*float32(maxY)), -1, int(0.55*float32(maxY))-1); err != nil {
40 if err != gocui.ErrUnknownView {
41 return err
42 }
43 v.Title = remoteBranchViewFeature.Title
44 v.Wrap = false
45 v.Overwrite = false
46 }
47 if v, err := g.SetView(branchViewFeature.Name, int(0.25*float32(maxX)), int(0.25*float32(maxY)), int(0.75*float32(maxX)), int(0.75*float32(maxY))); err != nil {
48 if err != gocui.ErrUnknownView {
49 return err
50 }
51 v.Title = branchViewFeature.Title
52 v.Wrap = false
53 v.Autoscroll = false
54 _, _ = g.SetViewOnBottom(v.Name())
55 }
56 if v, err := g.SetView(batchBranchViewFeature.Name, int(0.25*float32(maxX)), int(0.25*float32(maxY)), int(0.75*float32(maxX)), int(0.75*float32(maxY))); err != nil {
57 if err != gocui.ErrUnknownView {
58 return err
59 }
60 v.Title = batchBranchViewFeature.Title
61 v.Wrap = false
62 v.Autoscroll = false
63 _, _ = g.SetViewOnBottom(v.Name())
64 }
65 if v, err := g.SetView(suggestBranchViewFeature.Name, int(0.30*float32(maxX)), int(0.45*float32(maxY)), int(0.70*float32(maxX)), int(0.55*float32(maxY))); err != nil {
66 if err != gocui.ErrUnknownView {
67 return err
68 }
69 v.Title = suggestBranchViewFeature.Title
70 v.Editable = true
71 v.Wrap = false
72 v.Autoscroll = false
73 _, _ = g.SetViewOnBottom(v.Name())
74 }
75 if v, err := g.SetView(stashViewFeature.Name, -1*int(0.20*float32(maxX)), 0, -1, maxY); err != nil {
76 if err != gocui.ErrUnknownView {
77 return err
78 }
79 v.Title = stashViewFeature.Title
80 v.Wrap = false
81 v.Autoscroll = false
82 }
83 if v, err := g.SetView(commitViewFeature.Name, -1*int(0.20*float32(maxX)), 0, -1, maxY); err != nil {
84 if err != gocui.ErrUnknownView {
85 return err
86 }
87 v.Title = commitViewFeature.Title
88 v.Wrap = false
89 v.Autoscroll = false
90 }
91 if v, err := g.SetView(dynamicViewFeature.Name, -1*int(0.20*float32(maxX)), 0, -1, maxY); err != nil {
92 if err != gocui.ErrUnknownView {
93 return err
94 }
95 v.Title = dynamicViewFeature.Title
96 v.Wrap = false
97 v.Autoscroll = false
98 }
99 if v, err := g.SetView(keybindingsViewFeature.Name, -1, maxY-2, maxX, maxY); err != nil {
100 if err != gocui.ErrUnknownView {
101 return err
102 }
103 v.BgColor = gocui.ColorWhite
104 v.FgColor = gocui.ColorBlack
105 v.Frame = false
106 _ = gui.updateKeyBindingsView(g, mainViewFeature.Name)
107 }
108 return nil
109 }
110
111 // close confirmation view
112 func (gui *Gui) openBranchesView(g *gocui.Gui, v *gocui.View) error {
113 if _, err := g.SetViewOnTop(branchViewFeature.Name); err != nil {
114 return err
115 }
116 return gui.focusToView(branchViewFeature.Name)
117 }
118
119 // close confirmation view
120 func (gui *Gui) closeBranchesView(g *gocui.Gui, v *gocui.View) error {
121 if gui.order == focus {
122 return nil
123 }
124 if _, err := g.SetViewOnBottom(branchViewFeature.Name); err != nil {
125 return err
126 }
127 return gui.focusToView(mainViewFeature.Name)
128 }