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

Method deleteWordRight

tuiutil/textinput.go:448–479  ·  view source on GitHub ↗

deleteWordRight deletes the word right to the cursor. Returns whether or not the cursor blink should be reset. If input is masked delete everything after the cursor so as not to reveal word breaks in the masked input.

()

Source from the content-addressed store, hash-verified

446// the cursor blink should be reset. If input is masked delete everything after
447// the cursor so as not to reveal word breaks in the masked input.
448func (m *TextInputModel) deleteWordRight() bool {
449 if m.pos >= len(m.value) || len(m.value) == 0 {
450 return false
451 }
452
453 if m.EchoMode != EchoNormal {
454 return m.deleteAfterCursor()
455 }
456
457 i := m.pos
458 m.setCursor(m.pos + 1)
459 for unicode.IsSpace(m.value[m.pos]) {
460 // ignore series of whitespace after cursor
461 m.setCursor(m.pos + 1)
462 }
463
464 for m.pos < len(m.value) {
465 if !unicode.IsSpace(m.value[m.pos]) {
466 m.setCursor(m.pos + 1)
467 } else {
468 break
469 }
470 }
471
472 if m.pos > len(m.value) {
473 m.value = m.value[:i]
474 } else {
475 m.value = append(m.value[:i], m.value[m.pos:]...)
476 }
477
478 return m.setCursor(i)
479}
480
481// wordLeft moves the cursor one word to the left. Returns whether or not the
482// cursor blink should be reset. If input is masked, move input to the start

Callers 1

UpdateMethod · 0.95

Calls 2

deleteAfterCursorMethod · 0.95
setCursorMethod · 0.95

Tested by

no test coverage detected