/// <summary> /// Activate proposal at iter. When this functions returns FALSE, the /// default activation of proposal will take place which replaces the /// word at iter with the text of proposal (see /// gtk_source_completion_proposal_get_text()). /// /// Here is how the default activation selects the boundaries of the /// word to replace. The end of the word is iter . For the start of the /// word, it depends on whether a start iter is defined for proposal /// (see gtk_source_completion_provider_get_start_iter()). If a start /// iter is defined, the start of the word is the start iter. Else, the /// word (as long as possible) will contain only alphanumerical and the /// "_" characters. /// </summary> /// <param name="proposal"></param> /// <param name="iter"></param> /// <returns></returns> public bool ActivateProposal(ICompletionProposal proposal, TextIter iter) { if (proposal is CompletionProposalAdapter adapter && adapter.Implementor is CustomScriptCompletionProposal prop && prop.Item.IsMethod) { // The user has just activated a completion item which is a method. // Let's show the method signature in a popup window. // First, remove any existing method signature popups. if (methodSignaturePopup != null) { methodSignaturePopup.Hide(); methodSignaturePopup.Dispose(); } // TBI - parameter names, descriptions. // Also need to look into manual activation of the popup (ie // ctrl + shift + space). methodSignaturePopup = new CompletionInfo(); methodSignaturePopup.Add(new Label(proposal.Info)); // We need to attach the popup window to the sourceview, so it // gets hidden/removed when the sourceview loses focus. methodSignaturePopup.AttachedTo = view; methodSignaturePopup.ShowAll(); // Move the info window to the location of the cursor. methodSignaturePopup.MoveToIter(view, iter); } // Return false, to allow the sourceview to automatically handle // insertion of the selected completion item. return(false); }
/// <summary> /// Get a customized info widget to show extra information of a /// proposal. This allows for customized widgets on a proposal basis, /// although in general providers will have the same custom widget for /// all their proposals and proposal can be ignored. The implementation /// of this function is optional. /// /// If this function is not implemented, the default widget is a /// GtkLabel. The return value of /// gtk_source_completion_proposal_get_info() is used as the content of /// the GtkLabel. /// </summary> /// <remarks> /// This implementation is essentially the same as the default behvaiour /// when this method is not implemented (ie when it returns null), /// except that I've set UseMarkup to false, to ensure that generic /// members/parameters are displayed correctly without being parsed as /// markup. /// </remarks> /// <param name="proposal">The completion proposal.</param> public Widget GetInfoWidget(ICompletionProposal proposal) { return(new Label() { UseMarkup = false, Text = proposal.Info, Visible = true }); }
/// <summary> /// Get whether two proposal objects are the same. This is used to /// (together with gtk_source_completion_proposal_hash()) to match /// proposals in the completion model. By default, it uses direct /// equality (g_direct_equal()). /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equal(ICompletionProposal other) { return(string.Equals(Text, other.Text, StringComparison.InvariantCulture)); //return Equals(other); }
/// <summary> /// Update extra information shown in info for proposal. /// </summary> /// <param name="proposal">Completion proposal.</param> /// <param name="info">Completion information.</param> /// <remarks> /// This function must be implemented when /// gtk_source_completion_provider_get_info_widget() is implemented. /// </remarks> public void UpdateInfo(ICompletionProposal proposal, CompletionInfo info) { // Not using this feature (for now at least). return; }
/// <summary> /// Get the GtkTextIter at which the completion for proposal starts. /// When implemented, this information is used to position the /// completion window accordingly when a proposal is selected in the /// completion window. The proposal text inside the completion window /// is aligned on iter. /// /// If this function is not implemented, the word boundary is taken to /// position the completion window. See /// gtk_source_completion_provider_activate_proposal() for an /// explanation on the word boundaries. /// /// When the proposal is activated, the default handler uses iter as /// the start of the word to replace. See /// gtk_source_completion_provider_activate_proposal() for more /// information. /// </summary> /// <param name="context"></param> /// <param name="proposal"></param> /// <param name="iter"></param> /// <returns></returns> public bool GetStartIter(CompletionContext context, ICompletionProposal proposal, TextIter iter) { return(false); }
/// <summary> /// Get a customized info widget to show extra information of a /// proposal. This allows for customized widgets on a proposal basis, /// although in general providers will have the same custom widget for /// all their proposals and proposal can be ignored. The implementation /// of this function is optional. /// /// If this function is not implemented, the default widget is a /// GtkLabel. The return value of /// gtk_source_completion_proposal_get_info() is used as the content of /// the GtkLabel. /// </summary> /// <param name="proposal"></param> /// <returns></returns> public Widget GetInfoWidget(ICompletionProposal proposal) { // tbi return(null); }