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

Method offerComplete

texteditor/spell.go:24–57  ·  view source on GitHub ↗

Complete and Spell offerComplete pops up a menu of possible completions

()

Source from the content-addressed store, hash-verified

22
23// offerComplete pops up a menu of possible completions
24func (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.

Callers 2

keyInputMethod · 0.95
keyInputInsertRuneMethod · 0.95

Calls 9

charStartPosMethod · 0.95
IsDisabledMethod · 0.80
CancelMethod · 0.80
InCommentMethod · 0.80
InLitStringMethod · 0.80
ToBytesMethod · 0.80
ToPointMethod · 0.80
ShowMethod · 0.65
RegionMethod · 0.45

Tested by

no test coverage detected