Beispiel #1
0
 public Result <FlushedEntry> Flush()
 {
     if (appender.Count > 0)
     {
         var entry  = new FlushedEntry(appender.Cells(), appender.ToString());
         var result = Result.Ok(entry);
         OnFlushedEntry.RaiseEvent(this, entry.StringRepresentation);
         appender.Clear();
         history.Add(entry);
         return(result);
     }
     return(Result.Fail <FlushedEntry>("No entries"));
 }
Beispiel #2
0
 private void SubscribeEntryToKeyprocessor()
 {
     keyProcessor.KeyPressed += (sender, ch) => EntryPoint.AddEntry(ch);
     keyProcessor.BackSpace  += (sender, args) => EntryPoint.DeleteEntry();
     keyProcessor.Delete     += (sender, args) => EntryPoint.DeleteEntryAfterCursor();
     keyProcessor.Left       += (sender, args) => EntryPoint.Cursor.Left();
     keyProcessor.Right      += (sender, args) => EntryPoint.Cursor.Right();
     keyProcessor.Up         += (sender, args) => EntryPoint.PeekNext();
     keyProcessor.Down       += (sender, args) => EntryPoint.PeekPrevious();
     keyProcessor.Insert     += (sender, args) =>
     {
         var entry = EntryPoint.Flush();
     };
     EntryPoint.OnFlushedEntry += async(sender, command) =>
     {
         window.AddCellRange(appender.Cells());
         await terminal.ExecuteCommand(command);
     };
 }
Beispiel #3
0
        public TerminalEntry(CellAppender appender, CellRowAligner aligner, Func <int> spacing, Func <float> rowSize, int historyEntries = 40)
        {
            this.cursor = new Cursor();

            if (appender == null)
            {
                throw new ArgumentNullException("appender");
            }
            this.appender = appender;

            AddEntryRule(new EntryRule(ch => appender.Count < 100));

            history = new CommandHistory(historyEntries);

            appender.OnCellAppend((sender, args) =>
            {
                aligner.AlignToRows(appender.Cells(), spacing(), rowSize());
                cursor.Update(aligner.Rows());
            });
        }