private void ShowCommandHistoryEntry(int deltaIndex) { if (commandHistory.Count > 0) { int newHistoryIndex = commandHistoryIndex + deltaIndex; if (newHistoryIndex >= 0 && newHistoryIndex < commandHistory.Count) { commandHistoryIndex = newHistoryIndex; LineBuilder = new StringBuilder(); LineBuilder.Append(commandHistory[commandHistoryIndex]); LineCursorIndex = LineBuilder.Length; MarkRowsDirty(LineSubBuffer.PositionRow, LineSubBuffer.RowCount); LineSubBuffer.Wipe(); UpdateLineSubBuffer(); } } }
protected void UpdateLineSubBuffer() { string commandText = LineBuilder.ToString(); List <string> lines = SplitIntoLinesPreserveNewLine(commandText); if (lines.Count != LineSubBuffer.RowCount) { LineSubBuffer.SetSize(lines.Count, LineSubBuffer.ColumnCount); } for (int lineIndex = 0; lineIndex < lines.Count; lineIndex++) { char[] lineCharArray = lines[lineIndex].PadRight(LineSubBuffer.ColumnCount, ' ').ToCharArray(); lineCharArray.CopyTo(LineSubBuffer.Buffer[lineIndex], 0); } UpdateSubBufferCursor(lines); }
protected override void NewLine() { string commandText = LineBuilder.ToString(); if (Shared.ScriptHandler.IsCommandComplete(commandText)) { base.NewLine(); AddCommandHistoryEntry(commandText); // add to history first so that if ProcessCommand generates an exception, // the command is present in the history to be found and printed in the // error message. ProcessCommand(commandText); int numRows = LineSubBuffer.RowCount; LineSubBuffer.Wipe(); LineSubBuffer.SetSize(numRows, ColumnCount); // refill it to its previous size } else { InsertChar('\n'); } }