Search Results for

    Show / Hide Table of Contents

    Class Autocomplete

    Renders an overlay on another view at a given point that allows selecting from a range of 'autocomplete' options.
    Inheritance
    System.Object
    Autocomplete
    TextFieldAutocomplete
    TextViewAutocomplete
    Implements
    IAutocomplete
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public abstract class Autocomplete : Object, IAutocomplete

    Constructors

    Autocomplete()

    Declaration
    protected Autocomplete()

    Properties

    AllSuggestions

    The full set of all strings that can be suggested.
    Declaration
    public virtual List<string> AllSuggestions { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.List<System.String>

    CloseKey

    The key that the user can press to close the currently popped autocomplete menu
    Declaration
    public virtual Key CloseKey { get; set; }
    Property Value
    Type Description
    Key

    ColorScheme

    The colors to use to render the overlay. Accessing this property before the Application has been initialized will cause an error
    Declaration
    public virtual ColorScheme ColorScheme { get; set; }
    Property Value
    Type Description
    ColorScheme

    HostControl

    The host control to handle.
    Declaration
    public virtual View HostControl { get; set; }
    Property Value
    Type Description
    View

    MaxHeight

    The maximum number of visible rows in the autocomplete dropdown to render
    Declaration
    public virtual int MaxHeight { get; set; }
    Property Value
    Type Description
    System.Int32

    MaxWidth

    The maximum width of the autocomplete dropdown
    Declaration
    public virtual int MaxWidth { get; set; }
    Property Value
    Type Description
    System.Int32

    PopupInsideContainer

    Gets or sets If the popup is displayed inside or outside the host limits.
    Declaration
    public bool PopupInsideContainer { get; set; }
    Property Value
    Type Description
    System.Boolean

    Reopen

    The key that the user can press to reopen the currently popped autocomplete menu
    Declaration
    public virtual Key Reopen { get; set; }
    Property Value
    Type Description
    Key

    ScrollOffset

    When more suggestions are available than can be rendered the user can scroll down the dropdown list. This indicates how far down they have gone
    Declaration
    public virtual int ScrollOffset { get; set; }
    Property Value
    Type Description
    System.Int32

    SelectedIdx

    The currently selected index into Suggestions that the user has highlighted
    Declaration
    public virtual int SelectedIdx { get; set; }
    Property Value
    Type Description
    System.Int32

    SelectionKey

    The key that the user must press to accept the currently selected autocomplete suggestion
    Declaration
    public virtual Key SelectionKey { get; set; }
    Property Value
    Type Description
    Key

    Suggestions

    The strings that form the current list of suggestions to render based on what the user has typed so far.
    Declaration
    public virtual ReadOnlyCollection<string> Suggestions { get; set; }
    Property Value
    Type Description
    System.Collections.ObjectModel.ReadOnlyCollection<System.String>

    Visible

    True if the autocomplete should be considered open and visible
    Declaration
    public virtual bool Visible { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    ClearSuggestions()

    Clears Suggestions
    Declaration
    public virtual void ClearSuggestions()

    Close()

    Closes the Autocomplete context menu if it is showing and ClearSuggestions()
    Declaration
    protected void Close()

    DeleteTextBackwards()

    Deletes the text backwards before insert the selected text in the HostControl.
    Declaration
    protected abstract void DeleteTextBackwards()

    EnsureSelectedIdxIsValid()

    Updates SelectedIdx to be a valid index within Suggestions
    Declaration
    public virtual void EnsureSelectedIdxIsValid()

    GenerateSuggestions()

    Populates Suggestions with all strings in AllSuggestions that match with the current cursor position/text in the HostControl
    Declaration
    public virtual void GenerateSuggestions()

    GetCurrentWord()

    Returns the currently selected word from the HostControl.

    When overriding this method views can make use of IdxToWord(List<Rune>, Int32)

    Declaration
    protected abstract string GetCurrentWord()
    Returns
    Type Description
    System.String

    IdxToWord(List<Rune>, Int32)

    Given a line of characters, returns the word which ends at idx or null. Also returns null if the idx is positioned in the middle of a word.

    Use this method to determine whether autocomplete should be shown when the cursor is at a given point in a line and to get the word from which suggestions should be generated.

    Declaration
    protected virtual string IdxToWord(List<Rune> line, int idx)
    Parameters
    Type Name Description
    System.Collections.Generic.List<System.Rune> line
    System.Int32 idx
    Returns
    Type Description
    System.String

    InsertSelection(String)

    Called when the user confirms a selection at the current cursor location in the HostControl. The accepted string is the full autocomplete word to be inserted. Typically a host will have to remove some characters such that the accepted string completes the word instead of simply being appended.
    Declaration
    protected virtual bool InsertSelection(string accepted)
    Parameters
    Type Name Description
    System.String accepted
    Returns
    Type Description
    System.Boolean True if the insertion was possible otherwise false

    InsertText(String)

    Inser the selected text in the HostControl.
    Declaration
    protected abstract void InsertText(string accepted)
    Parameters
    Type Name Description
    System.String accepted

    IsWordChar(Rune)

    Return true if the given symbol should be considered part of a word and can be contained in matches. Base behavior is to use System.Char.IsLetterOrDigit(System.Char)
    Declaration
    public virtual bool IsWordChar(Rune rune)
    Parameters
    Type Name Description
    System.Rune rune
    Returns
    Type Description
    System.Boolean

    MouseEvent(MouseEvent, Boolean)

    Handle mouse events before HostControl e.g. to make mouse events like report/click apply to the autocomplete control instead of changing the cursor position in the underlying text view.
    Declaration
    public virtual bool MouseEvent(MouseEvent me, bool fromHost = false)
    Parameters
    Type Name Description
    MouseEvent me The mouse event.
    System.Boolean fromHost If was called from the popup or from the host.
    Returns
    Type Description
    System.Boolean trueif the mouse can be handled falseotherwise.

    MoveDown()

    Moves the selection in the Autocomplete context menu down one
    Declaration
    protected void MoveDown()

    MoveUp()

    Moves the selection in the Autocomplete context menu up one
    Declaration
    protected void MoveUp()

    ProcessKey(KeyEvent)

    Handle key events before HostControl e.g. to make key events like up/down apply to the autocomplete control instead of changing the cursor position in the underlying text view.
    Declaration
    public virtual bool ProcessKey(KeyEvent kb)
    Parameters
    Type Name Description
    KeyEvent kb The key event.
    Returns
    Type Description
    System.Boolean trueif the key can be handled falseotherwise.

    RenderOverlay(Point)

    Renders the autocomplete dialog inside or outside the given HostControl at the given point.
    Declaration
    public virtual void RenderOverlay(Point renderAt)
    Parameters
    Type Name Description
    Point renderAt

    RenderSelectedIdxByMouse(MouseEvent)

    Render the current selection in the Autocomplete context menu by the mouse reporting.
    Declaration
    protected void RenderSelectedIdxByMouse(MouseEvent me)
    Parameters
    Type Name Description
    MouseEvent me

    ReopenSuggestions()

    Reopen the popup after it has been closed.
    Declaration
    protected bool ReopenSuggestions()
    Returns
    Type Description
    System.Boolean

    Select()

    Completes the autocomplete selection process. Called when user hits the SelectionKey.
    Declaration
    protected bool Select()
    Returns
    Type Description
    System.Boolean

    Implements

    IAutocomplete
    In This Article
    Back to top Generated by DocFX