Simple.Wpf.Terminal
Simple.Wpf.Terminal copied to clipboard
Command text removed
If command text is present after the prompt when items are added to the ItemsSource, the text is removed from after the prompt and placed in front of the item added. This means if data is added at regular intervals from an asynchronous source, the command text can become corrupted whist typing, before the return key is hit.
Hacking some code yields the desired effect for my issue (probably could be done better):
private void AddItems(object[] items)
{
Contract.Requires(items != null);
// added
var command = AggregateAfterPrompt();
ClearAfterPrompt();
_paragraph.Inlines.Remove(_promptInline);
var inlines = items.SelectMany(x =>
{
var value = ExtractValue(x);
var newInlines = new List<Inline>();
using (var reader = new StringReader(value))
{
var line = reader.ReadLine();
newInlines.Add(new Run(line) { Foreground = GetForegroundColor(x) });
newInlines.Add(new LineBreak());
}
return newInlines;
}).ToArray();
_paragraph.Inlines.AddRange(inlines);
AddPrompt();
// added
_paragraph.Inlines.Add(new Run(command));
CaretPosition = CaretPosition.DocumentEnd;
}