using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Rune = System.Rune; namespace Terminal.Gui { /// /// A replacement suggestion made by /// public class Suggestion { /// /// The number of characters to remove at the current cursor position /// before adding the /// public int Remove { get; } /// /// The user visible description for the . Typically /// this would be the same as but may vary in advanced /// use cases (e.g. Title= "ctor", Replacement = "MyClass()\n{\n}") /// public string Title {get;} /// /// The replacement text that will be added /// public string Replacement { get; } /// /// Creates a new instance of the class. /// /// /// /// User visible title for the suggestion or null if the same /// as . public Suggestion (int remove, string replacement, string title = null) { Remove = remove; Replacement = replacement; Title = title ?? replacement; } } /// /// Renders an overlay on another view at a given point that allows selecting /// from a range of 'autocomplete' options. /// public interface IAutocomplete { /// /// The host control that will use autocomplete. /// View HostControl { get; set; } /// /// Gets or sets where the popup will be displayed. /// bool PopupInsideContainer { get; set; } /// /// The maximum width of the autocomplete dropdown /// int MaxWidth { get; set; } /// /// The maximum number of visible rows in the autocomplete dropdown to render /// int MaxHeight { get; set; } /// /// True if the autocomplete should be considered open and visible /// bool Visible { get; set; } /// /// The strings that form the current list of suggestions to render /// based on what the user has typed so far. /// ReadOnlyCollection Suggestions { get; set; } /// /// The currently selected index into that the user has highlighted /// int SelectedIdx { get; set; } /// /// The colors to use to render the overlay. Accessing this property before /// the Application has been initialized will cause an error /// ColorScheme ColorScheme { get; set; } /// /// The key that the user must press to accept the currently selected autocomplete suggestion /// Key SelectionKey { get; set; } /// /// The key that the user can press to close the currently popped autocomplete menu /// Key CloseKey { get; set; } /// /// The key that the user can press to reopen the currently popped autocomplete menu /// Key Reopen { get; set; } /// /// Renders the autocomplete dialog inside the given at the /// given point. /// /// void RenderOverlay (Point renderAt); /// /// Handle key events before 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. /// /// The key event. /// trueif the key can be handled falseotherwise. bool ProcessKey (KeyEvent kb); /// /// Handle mouse events before 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. /// /// The mouse event. /// If was called from the popup or from the host. /// trueif the mouse can be handled falseotherwise. bool MouseEvent (MouseEvent me, bool fromHost = false); /// /// Clears /// void ClearSuggestions (); ISuggestionGenerator SuggestionGenerator {get;set;} /// /// Populates with all /// proposed by at the given /// of /// void GenerateSuggestions (List currentLine, int idx); } }