4 // not sure why - but extending Gtk.SourceCompletionProvider seems to give an error..
7 public class CompletionProvider : Object, SourceCompletionProvider
10 WindowState windowstate;
11 //public List<Gtk.SourceCompletionItem> filtered_proposals;
13 public CompletionProvider(Editor editor)
16 this.windowstate = editor.window.windowstate;
20 public string get_name ()
25 public int get_priority ()
30 public bool match (SourceCompletionContext context)
36 public void populate (SourceCompletionContext context)
38 var buffer = context.completion.view.buffer;
39 var mark = buffer.get_insert ();
42 buffer.get_iter_at_mark (out end, mark);
45 var searchpos = endpos;
47 searchpos.backward_find_char(is_space, null);
48 searchpos.forward_char();
49 var search = endpos.get_text(searchpos);
50 print("got search %s\n", search);
52 if (search.length < 2) {
56 var filtered_proposals = windowstate.file.palete().suggestComplete(
57 this.windowstate.file,
65 context.add_proposals (this, filtered_proposals, true);
68 public bool activate_proposal (SourceCompletionProposal proposal, TextIter iter)
71 istart.backward_find_char(is_space, null);
72 istart.forward_char();
74 // var search = iter.get_text(istart);
76 var buffer = iter.get_buffer();
77 buffer.delete(ref istart, ref iter);
78 buffer.insert(ref istart, proposal.get_text(), -1);
83 public SourceCompletionActivation get_activation ()
85 //if(SettingsManager.Get_Setting("complete_auto") == "true"){
86 return SourceCompletionActivation.INTERACTIVE | SourceCompletionActivation.USER_REQUESTED;
88 // return Gtk.SourceCompletionActivation.USER_REQUESTED;
92 public int get_interactive_delay ()
97 public bool get_start_iter (SourceCompletionContext context, SourceCompletionProposal proposal, out TextIter iter)
102 public void update_info (SourceCompletionProposal proposal, SourceCompletionInfo info)
107 private bool is_space(unichar space){
108 return space.isspace() || space.to_string() == "";
111 private bool is_forward_space(unichar space){
113 space.to_string() == " "
115 space.to_string() == ""
117 space.to_string() == "\n"
119 space.to_string() == ")"
121 space.to_string() == "("