// -------------------------------------------------------------------- // VIRTUAL METHODS // -------------------------------------------------------------------- protected virtual void HandleCommandHistoryRequest(CommandHistoryDirection direction) { switch (direction) { case CommandHistoryDirection.BACKWARD: if (indexInLog > 0) { indexInLog--; } if (CommandLog.Count > 0) { Text = GetTextWithPromptSuffix(CommandLog[indexInLog].Raw); CaretIndex = Text.Length; } break; case CommandHistoryDirection.FORWARD: if (indexInLog < CommandLog.Count - 1) { indexInLog++; } if (CommandLog.Count > 0) { Text = GetTextWithPromptSuffix(CommandLog[indexInLog].Raw); CaretIndex = Text.Length; } break; } }
/// <summary> /// Called when a user requests a command entered in the past. /// </summary> /// <param name="direction">The direction to browse the list of the previous commands.</param> private void HandleCommandHistoryRequest(CommandHistoryDirection direction) { switch (direction) { // if user wants the previous command case CommandHistoryDirection.Backward: if (this.indexInPreviousCommand > 0) { this.indexInPreviousCommand--; } if (this.PreviousCommands.Count > 0) { this.Text = this.AddSuffixToLastPrompt(this.PreviousCommands[this.indexInPreviousCommand]); this.CaretIndex = this.Text.Length; } break; // if user wants the next command case CommandHistoryDirection.Forward: if (this.indexInPreviousCommand < this.PreviousCommands.Count - 1) { this.indexInPreviousCommand++; } if (this.PreviousCommands.Count > 0) { this.Text = this.AddSuffixToLastPrompt(this.PreviousCommands[indexInPreviousCommand]); this.CaretIndex = this.Text.Length; } break; } }
// -------------------------------------------------------------------- // VIRTUAL METHODS // -------------------------------------------------------------------- protected virtual void HandleCommandHistoryRequest(CommandHistoryDirection direction) { switch (direction) { case CommandHistoryDirection.BACKWARD: if (indexInLog > 0) indexInLog--; if (CommandLog.Count > 0) { Text = GetTextWithPromptSuffix(CommandLog[indexInLog].Raw); CaretIndex = Text.Length; } break; case CommandHistoryDirection.FORWARD: if (indexInLog < CommandLog.Count - 1) indexInLog++; if (CommandLog.Count > 0) { Text = GetTextWithPromptSuffix(CommandLog[indexInLog].Raw); CaretIndex = Text.Length; } break; } }
// -------------------------------------------------------------------- // VIRTUAL METHODS // -------------------------------------------------------------------- protected virtual void HandleCommandHistoryRequest(CommandHistoryDirection direction) { switch (direction) { case CommandHistoryDirection.BACKWARD: { try { if (indexInLog > 0) indexInLog--; if (CommandLog.Count > 0) { Document.Blocks.Remove(Document.Blocks.LastBlock); InsertNewPrompt(CommandLog[indexInLog].Raw.Trim()); this.ScrollToEnd(); this.CaretPosition = Document.Blocks.LastBlock.ContentEnd; } } catch (Exception ee) { } break; } case CommandHistoryDirection.FORWARD: { try { if (indexInLog < CommandLog.Count - 1) indexInLog++; if (indexInLog == CommandLog.Count - 1) { InsertNewPrompt(); this.ScrollToEnd(); this.CaretPosition = Document.Blocks.LastBlock.ContentEnd; } if (CommandLog.Count > 0) { Document.Blocks.Remove(Document.Blocks.LastBlock); InsertNewPrompt(CommandLog[indexInLog].Raw.Trim()); this.ScrollToEnd(); this.CaretPosition = Document.Blocks.LastBlock.ContentEnd; } } catch (Exception ee) { } break; } } }