using System; using System.Text; using InteractiveReadLine.Formatting; using InteractiveReadLine.Tokenizing; namespace InteractiveReadLine.KeyBehaviors { /// /// Provides the unified target of key behaviors, exposing a standard amount of state which the /// behavior method can act upon /// public interface IKeyBehaviorTarget { /// /// Gets the ConsoleKey which was received for the current request /// ConsoleKeyInfo ReceivedKey { get; } /// /// Gets the string buffer which holds the current readline text which is being edited by the user /// StringBuilder TextBuffer { get; } /// /// Gets or sets the integer position of the cursor. Cannot be set before the beginning or after the end /// of the TextBuffer. /// int CursorPosition { get; set; } /// /// Invokes the auto-complete's "next" functionality, which substitutes in the next suggestion /// void AutoCompleteNext(); /// /// Invokes the auto-complete's "previous" functionality, which substitutes in the previous suggestion /// void AutoCompletePrevious(); /// /// Inserts text to the console out in the spot where the current read line input is, then /// immediately re-displays the line input on the next row. Use this to interrupt the user with a message or /// information while the ReadLine is still being used /// /// The text to write to the console, a newline char will be added automatically void InsertText(FormattedText text); /// /// If the handler configuration has a tokenizer, this will get the tokenization result of the text /// buffer /// /// Returns null if there is no tokenizer, otherwise a Tokens result TokenizedLine GetTextTokens(); /// /// Invokes the history's "next" functionality, which replaces the entire line with the next element /// in the history collection. If the last history element has been reached, the previously entered /// LineState will be reverted. /// void HistoryNext(); /// /// Invokes the history's "previous" functionality, which replaces the entire line with the previous /// element in the history collection. /// void HistoryPrevious(); /// /// Tells the readline handler to finish this line of input and return it /// void Finish(); } }