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

Method CursorLeft

internal/action/actions.go:277–299  ·  view source on GitHub ↗

CursorLeft moves the cursor left

()

Source from the content-addressed store, hash-verified

275
276// CursorLeft moves the cursor left
277func (h *BufPane) CursorLeft() bool {
278 if h.Cursor.HasSelection() {
279 h.Cursor.Deselect(true)
280 } else {
281 tabstospaces := h.Buf.Settings["tabstospaces"].(bool)
282 tabmovement := h.Buf.Settings["tabmovement"].(bool)
283 if tabstospaces && tabmovement {
284 tabsize := int(h.Buf.Settings["tabsize"].(float64))
285 line := h.Buf.LineBytes(h.Cursor.Y)
286 if h.Cursor.X-tabsize >= 0 && util.IsSpaces(line[h.Cursor.X-tabsize:h.Cursor.X]) && util.IsBytesWhitespace(line[0:h.Cursor.X-tabsize]) {
287 for i := 0; i < tabsize; i++ {
288 h.Cursor.Left()
289 }
290 } else {
291 h.Cursor.Left()
292 }
293 } else {
294 h.Cursor.Left()
295 }
296 }
297 h.Relocate()
298 return true
299}
300
301// CursorRight moves the cursor right
302func (h *BufPane) CursorRight() bool {

Callers

nothing calls this directly

Calls 7

IsSpacesFunction · 0.92
IsBytesWhitespaceFunction · 0.92
LeftMethod · 0.80
LineBytesMethod · 0.65
RelocateMethod · 0.65
HasSelectionMethod · 0.45
DeselectMethod · 0.45

Tested by

no test coverage detected