5 class CompletionProvider : Gtk.SourceCompletionProvider, Object
8 public List<Gtk.SourceCompletionItem> proposals;
9 //public List<Gtk.SourceCompletionItem> filtered_proposals;
14 this.proposals = new List<Gtk.SourceCompletionItem> ();
17 public string get_name ()
22 public int get_priority ()
27 public bool match (Gtk.SourceCompletionContext context)
33 public void populate (Gtk.SourceCompletionContext context)
35 var buffer = context.completion.view.buffer;
36 var mark = buffer.get_insert ();
39 buffer.get_iter_at_mark (out end, mark);
42 var searchpos = endpos;
44 searchpos.backward_find_char(is_space, null);
45 searchpos.forward_char();
46 var search = endpos.get_text(searchpos);
50 var filtered_proposals = new List<Gtk.SourceCompletionItem> ();
51 foreach(var i in this.proposals) {
52 //if(i.text.contains(search)) // starts??
53 // this.filtered_proposals.prepend (new Gtk.SourceCompletionItem (i.label, i.text, i.icon, i.info));
56 context.add_proposals (this, filtered_proposals, true);
59 public bool activate_proposal (Gtk.SourceCompletionProposal proposal, Gtk.TextIter iter)
62 istart.backward_find_char(is_space, null);
63 istart.forward_char();
65 // var search = iter.get_text(istart);
67 var buffer = iter.get_buffer();
68 buffer.delete(ref istart, ref iter);
69 buffer.insert(ref istart, proposal.get_text(), -1);
74 public Gtk.SourceCompletionActivation get_activation ()
76 //if(SettingsManager.Get_Setting("complete_auto") == "true"){
77 return Gtk.SourceCompletionActivation.INTERACTIVE | Gtk.SourceCompletionActivation.USER_REQUESTED;
79 // return Gtk.SourceCompletionActivation.USER_REQUESTED;
83 public int get_interactive_delay ()
88 public bool get_start_iter (Gtk.SourceCompletionContext context, Gtk.SourceCompletionProposal proposal, Gtk.TextIter iter)
93 public void update_info (Gtk.SourceCompletionProposal proposal, Gtk.SourceCompletionInfo info)
98 private bool is_space(unichar space){
99 return space.isspace() || space.to_string() == "";
102 private bool is_forward_space(unichar space){
104 space.to_string() == " "
106 space.to_string() == ""
108 space.to_string() == "\n")
110 space.to_string() == ")")
112 space.to_string() == "("