Complete and Spell offerComplete pops up a menu of possible completions
()
| 22 | |
| 23 | // offerComplete pops up a menu of possible completions |
| 24 | func (ed *Editor) offerComplete() { |
| 25 | if ed.Buffer.Complete == nil || ed.ISearch.On || ed.QReplace.On || ed.IsDisabled() { |
| 26 | return |
| 27 | } |
| 28 | ed.Buffer.Complete.Cancel() |
| 29 | if !ed.Buffer.Options.Completion { |
| 30 | return |
| 31 | } |
| 32 | if ed.Buffer.InComment(ed.CursorPos) || ed.Buffer.InLitString(ed.CursorPos) { |
| 33 | return |
| 34 | } |
| 35 | |
| 36 | ed.Buffer.Complete.SrcLn = ed.CursorPos.Ln |
| 37 | ed.Buffer.Complete.SrcCh = ed.CursorPos.Ch |
| 38 | st := lexer.Pos{ed.CursorPos.Ln, 0} |
| 39 | en := lexer.Pos{ed.CursorPos.Ln, ed.CursorPos.Ch} |
| 40 | tbe := ed.Buffer.Region(st, en) |
| 41 | var s string |
| 42 | if tbe != nil { |
| 43 | s = string(tbe.ToBytes()) |
| 44 | s = strings.TrimLeft(s, " \t") // trim ' ' and '\t' |
| 45 | } |
| 46 | |
| 47 | // count := ed.Buf.ByteOffs[ed.CursorPos.Ln] + ed.CursorPos.Ch |
| 48 | cpos := ed.charStartPos(ed.CursorPos).ToPoint() // physical location |
| 49 | cpos.X += 5 |
| 50 | cpos.Y += 10 |
| 51 | // ed.Buffer.setByteOffs() // make sure the pos offset is updated!! |
| 52 | // todo: why? for above |
| 53 | ed.Buffer.currentEditor = ed |
| 54 | ed.Buffer.Complete.SrcLn = ed.CursorPos.Ln |
| 55 | ed.Buffer.Complete.SrcCh = ed.CursorPos.Ch |
| 56 | ed.Buffer.Complete.Show(ed, cpos, s) |
| 57 | } |
| 58 | |
| 59 | // CancelComplete cancels any pending completion. |
| 60 | // Call this when new events have moved beyond any prior completion scenario. |
no test coverage detected