示例#1
0
 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();
         }
     }
 }
示例#2
0
文件: TextEditor.cs 项目: victorb/KOS
        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);
        }
示例#3
0
        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');
            }
        }