JumpToLinePrompt jumps to given line number (minus 1) from prompt
()
| 702 | |
| 703 | // JumpToLinePrompt jumps to given line number (minus 1) from prompt |
| 704 | func (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) |
| 725 | func (ed *Editor) jumpToLine(ln int) { |
no test coverage detected