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

Method Init

filetree/node.go:72–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func (fn *Node) Init() {
73 fn.Tree.Init()
74 fn.IconOpen = icons.FolderOpen
75 fn.IconClosed = icons.Folder
76 fn.ContextMenus = nil // do not include tree
77 fn.AddContextMenu(fn.contextMenu)
78 fn.Styler(func(s *styles.Style) {
79 status := fn.Info.VCS
80 switch {
81 case status == vcs.Untracked:
82 s.Color = errors.Must1(gradient.FromString("#808080"))
83 case status == vcs.Modified:
84 s.Color = errors.Must1(gradient.FromString("#4b7fd1"))
85 case status == vcs.Added:
86 s.Color = errors.Must1(gradient.FromString("#008800"))
87 case status == vcs.Deleted:
88 s.Color = errors.Must1(gradient.FromString("#ff4252"))
89 case status == vcs.Conflicted:
90 s.Color = errors.Must1(gradient.FromString("#ce8020"))
91 case status == vcs.Updated:
92 s.Color = errors.Must1(gradient.FromString("#008060"))
93 case status == vcs.Stored:
94 s.Color = colors.Scheme.OnSurface
95 }
96 })
97 fn.On(events.KeyChord, func(e events.Event) {
98 if core.DebugSettings.KeyEventTrace {
99 fmt.Printf("Tree KeyInput: %v\n", fn.Path())
100 }
101 kf := keymap.Of(e.KeyChord())
102 selMode := events.SelectModeBits(e.Modifiers())
103
104 if selMode == events.SelectOne {
105 if fn.SelectMode {
106 selMode = events.ExtendContinuous
107 }
108 }
109
110 // first all the keys that work for ReadOnly and active
111 if !fn.IsReadOnly() && !e.IsHandled() {
112 switch kf {
113 case keymap.Delete:
114 fn.deleteFiles()
115 e.SetHandled()
116 case keymap.Backspace:
117 fn.deleteFiles()
118 e.SetHandled()
119 case keymap.Duplicate:
120 fn.duplicateFiles()
121 e.SetHandled()
122 case keymap.Insert: // New File
123 core.CallFunc(fn, fn.newFile)
124 e.SetHandled()
125 case keymap.InsertAfter: // New Folder
126 core.CallFunc(fn, fn.newFolder)
127 e.SetHandled()
128 }
129 }

Callers

nothing calls this directly

Calls 15

deleteFilesMethod · 0.95
duplicateFilesMethod · 0.95
IsDirMethod · 0.95
IsExecMethod · 0.95
setFileIconMethod · 0.95
RepoMethod · 0.95
initFileInfoMethod · 0.95
IsIrregularMethod · 0.95
dirFileListMethod · 0.95
Must1Function · 0.92
FromStringFunction · 0.92
OfFunction · 0.92

Tested by

no test coverage detected