public override void InsertCompletionText(CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
        {
            // insert add/remove event handler code after +=/-=
            editor.Replace(initialOffset, editor.Caret.Offset - initialOffset, this.DisplayText + (AddSemicolon ? ";" : ""));

            // Search opening bracket of member
            int pos = callingMember != null?editor.Document.LocationToOffset(callingMember.BodyRegion.Start.Line, callingMember.BodyRegion.Start.Column) : initialOffset;

            while (pos < editor.Document.Length && editor.Document.GetCharAt(pos) != '{')
            {
                pos++;
            }

            // Search closing bracket of member
            pos = editor.Document.GetMatchingBracketOffset(pos) + 1;

            pos = Math.Max(0, Math.Min(pos, editor.Document.Length - 1));

            // Insert new event handler after closing bracket
            string indent = editor.Document.GetLine(callingMember.Location.Line).GetIndentation(editor.Document);

            StringBuilder sb = new StringBuilder();

            sb.Append(editor.EolMarker);
            sb.Append(editor.EolMarker);
            sb.Append(indent);
            if (callingMember.IsStatic)
            {
                sb.Append("static ");
            }
            sb.Append("void ");
            int pos2 = sb.Length;

            sb.Append(this.DisplayText); sb.Append(' '); sb.Append(this.parameterList); sb.Append(editor.EolMarker);
            sb.Append(indent); sb.Append("{"); sb.Append(editor.EolMarker);
            sb.Append(indent); sb.Append(TextEditorProperties.IndentString);
            int cursorPos = pos + sb.Length;

            sb.Append(editor.EolMarker);
            sb.Append(indent); sb.Append("}");
            editor.Insert(pos, sb.ToString());
            editor.Caret.Offset = cursorPos;

            // start text link mode after insert
            List <TextLink> links = new List <TextLink> ();
            TextLink        link  = new TextLink("name");

            link.AddLink(new Segment(0, this.DisplayText.Length));
            link.AddLink(new Segment(pos - initialOffset + pos2, this.DisplayText.Length));
            links.Add(link);

            CompletionTextLinkMode tle = new CompletionTextLinkMode(editor.Parent, initialOffset, links);

            tle.TriggerCodeCompletion = false;
            tle.SetCaretPosition      = true;
            tle.SelectPrimaryLink     = true;
            tle.OldMode = editor.CurrentMode;
            tle.StartMode();
            editor.CurrentMode = tle;
        }
		public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
		{
			// insert add/remove event handler code after +=/-=
			editor.Replace (initialOffset, editor.Caret.Offset - initialOffset, this.DisplayText + (AddSemicolon ? ";" : ""));
			
			// Search opening bracket of member
			int pos = callingMember != null ? editor.Document.LocationToOffset (callingMember.BodyRegion.BeginLine, callingMember.BodyRegion.BeginColumn) : initialOffset;
			while (pos < editor.Document.TextLength && editor.Document.GetCharAt (pos) != '{') {
				pos++;
			}
			
			// Search closing bracket of member
			pos = editor.Document.GetMatchingBracketOffset (pos) + 1;
			
			pos = Math.Max (0, Math.Min (pos, editor.Document.TextLength - 1));
			
			// Insert new event handler after closing bracket
			string indent = editor.Document.GetLine (callingMember.Region.BeginLine).GetIndentation (editor.Document);
			
			StringBuilder sb = new StringBuilder ();
			sb.Append (editor.EolMarker);
			sb.Append (editor.EolMarker);
			sb.Append (indent);
			if (callingMember.IsStatic)
				sb.Append ("static ");
			sb.Append ("void ");
			int pos2 = sb.Length;
			sb.Append (this.DisplayText);
			sb.Append (' ');
			sb.Append (this.parameterList);
			sb.Append (editor.EolMarker);
			sb.Append (indent);
			sb.Append ("{");
			sb.Append (editor.EolMarker);
			sb.Append (indent);
			sb.Append (editor.Options.IndentationString);
			int cursorPos = pos + sb.Length;
			sb.Append (editor.EolMarker);
			sb.Append (indent);
			sb.Append ("}");
			editor.Insert (pos, sb.ToString ());
			editor.Caret.Offset = cursorPos;
			
			// start text link mode after insert
			List<TextLink> links = new List<TextLink> ();
			TextLink link = new TextLink ("name");
			
			link.AddLink (new TextSegment (0, this.DisplayText.Length));
			link.AddLink (new TextSegment (pos - initialOffset + pos2, this.DisplayText.Length));
			links.Add (link);
			
			CompletionTextLinkMode tle = new CompletionTextLinkMode (editor.Parent, initialOffset, links);
			tle.TriggerCodeCompletion = false;
			tle.SetCaretPosition = true;
			tle.SelectPrimaryLink = true;
			tle.OldMode = editor.CurrentMode;
			tle.StartMode ();
			editor.CurrentMode = tle;
		}