MCPcopy Create free account
hub / github.com/cogentcore/core / Init

Method Init

filetree/vcslog.go:52–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func (lv *VCSLog) Init() {
53 lv.Frame.Init()
54 lv.revisionA = "HEAD"
55 lv.revisionB = ""
56 lv.setA = true
57 lv.Styler(func(s *styles.Style) {
58 s.Direction = styles.Column
59 s.Grow.Set(1, 1)
60 })
61 tree.AddChildAt(lv, "toolbar", func(w *core.Toolbar) {
62 w.Maker(lv.makeToolbar)
63 })
64 tree.AddChildAt(lv, "log", func(w *core.Table) {
65 w.SetReadOnly(true)
66 w.SetSlice(&lv.Log)
67 w.AddContextMenu(func(m *core.Scene) {
68 core.NewButton(m).SetText("Set Revision A").
69 SetTooltip("Set Buffer A's revision to this").
70 OnClick(func(e events.Event) {
71 cmt := lv.Log[w.SelectedIndex]
72 lv.setRevisionA(cmt.Rev)
73 })
74 core.NewButton(m).SetText("Set Revision B").
75 SetTooltip("Set Buffer B's revision to this").
76 OnClick(func(e events.Event) {
77 cmt := lv.Log[w.SelectedIndex]
78 lv.setRevisionB(cmt.Rev)
79 })
80 core.NewButton(m).SetText("Copy Revision ID").
81 SetTooltip("Copies the revision number / hash for this").
82 OnClick(func(e events.Event) {
83 cmt := lv.Log[w.SelectedIndex]
84 w.Clipboard().Write(mimedata.NewText(cmt.Rev))
85 })
86 core.NewButton(m).SetText("View Revision").
87 SetTooltip("Views the file at this revision").
88 OnClick(func(e events.Event) {
89 cmt := lv.Log[w.SelectedIndex]
90 fileAtRevisionDialog(lv, lv.Repo, lv.File, cmt.Rev)
91 })
92 core.NewButton(m).SetText("Checkout Revision").
93 SetTooltip("Checks out this revision").
94 OnClick(func(e events.Event) {
95 cmt := lv.Log[w.SelectedIndex]
96 errors.Log(lv.Repo.UpdateVersion(cmt.Rev))
97 })
98 })
99 w.OnSelect(func(e events.Event) {
100 idx := w.SelectedIndex
101 if idx < 0 || idx >= len(lv.Log) {
102 return
103 }
104 cmt := lv.Log[idx]
105 if lv.setA {
106 lv.setRevisionA(cmt.Rev)
107 } else {
108 lv.setRevisionB(cmt.Rev)
109 }

Callers

nothing calls this directly

Calls 15

setRevisionAMethod · 0.95
setRevisionBMethod · 0.95
toggleRevisionMethod · 0.95
StatMethod · 0.95
SetTextMethod · 0.95
AddChildAtFunction · 0.92
NewButtonFunction · 0.92
NewTextFunction · 0.92
LogFunction · 0.92
NewBodyFunction · 0.92
NewBufferFunction · 0.92
FilenameTypeAlias · 0.92

Tested by

no test coverage detected