MCPcopy
hub / github.com/micro-editor/micro / HandleEvent

Method HandleEvent

internal/action/tab.go:102–142  ·  view source on GitHub ↗

HandleEvent checks for a resize event or a mouse event on the tab bar otherwise it will forward the event to the currently active tab

(event tcell.Event)

Source from the content-addressed store, hash-verified

100// HandleEvent checks for a resize event or a mouse event on the tab bar
101// otherwise it will forward the event to the currently active tab
102func (t *TabList) HandleEvent(event tcell.Event) {
103 switch e := event.(type) {
104 case *tcell.EventResize:
105 t.Resize()
106 case *tcell.EventMouse:
107 mx, my := e.Position()
108 switch e.Buttons() {
109 case tcell.Button1:
110 if my == t.Y && len(t.List) > 1 {
111 if mx == 0 {
112 t.Scroll(-4)
113 } else if mx == t.Width-1 {
114 t.Scroll(4)
115 } else {
116 ind := t.LocFromVisual(buffer.Loc{mx, my})
117 if ind != -1 {
118 t.SetActive(ind)
119 }
120 }
121 return
122 }
123 case tcell.ButtonNone:
124 if t.List[t.Active()].release {
125 // Mouse release received, while already released
126 t.ResetMouse()
127 return
128 }
129 case tcell.WheelUp:
130 if my == t.Y && len(t.List) > 1 {
131 t.Scroll(4)
132 return
133 }
134 case tcell.WheelDown:
135 if my == t.Y && len(t.List) > 1 {
136 t.Scroll(-4)
137 return
138 }
139 }
140 }
141 t.List[t.Active()].HandleEvent(event)
142}
143
144// Display updates the names and then displays the tab bar
145func (t *TabList) Display() {

Callers

nothing calls this directly

Calls 7

ResizeMethod · 0.95
SetActiveMethod · 0.95
ResetMouseMethod · 0.95
ActiveMethod · 0.80
ScrollMethod · 0.65
LocFromVisualMethod · 0.65
HandleEventMethod · 0.65

Tested by

no test coverage detected