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

Method JumpToLinePrompt

texteditor/nav.go:704–722  ·  view source on GitHub ↗

JumpToLinePrompt jumps to given line number (minus 1) from prompt

()

Source from the content-addressed store, hash-verified

702
703// JumpToLinePrompt jumps to given line number (minus 1) from prompt
704func (ed *Editor) JumpToLinePrompt() {
705 val := ""
706 d := core.NewBody().AddTitle("Jump to line").AddText("Line number to jump to")
707 tf := core.NewTextField(d).SetPlaceholder("Line number")
708 tf.OnChange(func(e events.Event) {
709 val = tf.Text()
710 })
711 d.AddBottomBar(func(parent core.Widget) {
712 d.AddCancel(parent)
713 d.AddOK(parent).SetText("Jump").OnClick(func(e events.Event) {
714 val = tf.Text()
715 ln, err := reflectx.ToInt(val)
716 if err == nil {
717 ed.jumpToLine(int(ln))
718 }
719 })
720 })
721 d.RunDialog(ed)
722}
723
724// jumpToLine jumps to given line number (minus 1)
725func (ed *Editor) jumpToLine(ln int) {

Callers 1

keyInputMethod · 0.95

Calls 15

jumpToLineMethod · 0.95
NewBodyFunction · 0.92
NewTextFieldFunction · 0.92
ToIntFunction · 0.92
AddTextMethod · 0.80
AddTitleMethod · 0.80
AddBottomBarMethod · 0.80
AddCancelMethod · 0.80
AddOKMethod · 0.80
RunDialogMethod · 0.80
SetPlaceholderMethod · 0.45
OnChangeMethod · 0.45

Tested by

no test coverage detected