MCPcopy
hub / github.com/mkchoi212/fac / Select

Function Select

layout.go:159–223  ·  view source on GitHub ↗

Select selects conflict `c` as the current conflict displayed on the screen When selecting a conflict, it updates the side panel, and the code view

(g *gocui.Gui, c *conflict.Conflict, showHelp bool)

Source from the content-addressed store, hash-verified

157// Select selects conflict `c` as the current conflict displayed on the screen
158// When selecting a conflict, it updates the side panel, and the code view
159func Select(g *gocui.Gui, c *conflict.Conflict, showHelp bool) {
160 // Update side panel
161 g.Update(func(g *gocui.Gui) error {
162 v, err := g.View(Panel)
163 if err != nil {
164 return err
165 }
166 v.Clear()
167
168 for idx, conflict := range conflicts {
169 var out string
170 if conflict.Choice != 0 {
171 out = color.Green(color.Regular, "✔ %s:%d", conflict.File.Name, conflict.Start)
172 } else {
173 out = color.Red(color.Regular, "%d. %s:%d", idx+1, conflict.File.Name, conflict.Start)
174 }
175
176 if conflict.Equal(c) {
177 fmt.Fprintf(v, "-> %s\n", out)
178 } else {
179 fmt.Fprintf(v, "%s\n", out)
180 }
181 }
182
183 if showHelp {
184 PrintHelp(v, &keyBinding)
185 }
186 return nil
187 })
188
189 // Update code view
190 g.Update(func(g *gocui.Gui) error {
191 v, err := g.View(Current)
192 if err != nil {
193 return err
194 }
195 v.Title = fmt.Sprintf("%s %s", c.CurrentName, "(Local Version)")
196
197 top, bottom := c.PaddingLines()
198 v.Clear()
199 printLines(v, top)
200 printLines(v, c.ColoredLocalLines)
201 printLines(v, bottom)
202 if c.Choice == conflict.Local {
203 v.FgColor = gocui.ColorGreen
204 }
205
206 v, err = g.View(Foreign)
207 if err != nil {
208 return err
209 }
210 v.Title = fmt.Sprintf("%s %s", c.ForeignName, "(Incoming Version)")
211
212 top, bottom = c.PaddingLines()
213 v.Clear()
214 printLines(v, top)
215 printLines(v, c.ColoredIncomingLines)
216 printLines(v, bottom)

Callers 5

EvaluateFunction · 0.85
ParseInputFunction · 0.85
MoveFunction · 0.85
ScrollFunction · 0.85
runUIFunction · 0.85

Calls 5

PrintHelpFunction · 0.85
printLinesFunction · 0.85
UpdateMethod · 0.80
EqualMethod · 0.80
PaddingLinesMethod · 0.80

Tested by

no test coverage detected