MCPcopy
hub / github.com/mathaou/termdbms / wordLeft

Method wordLeft

tuiutil/textinput.go:484–514  ·  view source on GitHub ↗

wordLeft moves the cursor one word to the left. Returns whether or not the cursor blink should be reset. If input is masked, move input to the start so as not to reveal word breaks in the masked input.

()

Source from the content-addressed store, hash-verified

482// cursor blink should be reset. If input is masked, move input to the start
483// so as not to reveal word breaks in the masked input.
484func (m *TextInputModel) wordLeft() bool {
485 if m.pos == 0 || len(m.value) == 0 {
486 return false
487 }
488
489 if m.EchoMode != EchoNormal {
490 return m.cursorStart()
491 }
492
493 blink := false
494 i := m.pos - 1
495 for i >= 0 {
496 if unicode.IsSpace(m.value[i]) {
497 blink = m.setCursor(m.pos - 1)
498 i--
499 } else {
500 break
501 }
502 }
503
504 for i >= 0 {
505 if !unicode.IsSpace(m.value[i]) {
506 blink = m.setCursor(m.pos - 1)
507 i--
508 } else {
509 break
510 }
511 }
512
513 return blink
514}
515
516// wordRight moves the cursor one word to the right. Returns whether or not the
517// cursor blink should be reset. If the input is masked, move input to the end

Callers 1

UpdateMethod · 0.95

Calls 2

cursorStartMethod · 0.95
setCursorMethod · 0.95

Tested by

no test coverage detected