public override void Output(string value, string data) { var msg = new FormattedMessage(2); msg.PushColor(Color.Black); msg.AddText(value); _textBox.AddMessage(msg); }
public void AddLine(string message, ChatChannel channel, Color color) { if (Disposed) { return; } var formatted = new FormattedMessage(3); formatted.PushColor(color); formatted.AddText(message); formatted.Pop(); contents.AddMessage(formatted); }
public void ReceiveResponse(MsgScriptResponse response) { RunButton.Disabled = false; // Remove > or . at the end of the output panel. OutputPanel.RemoveEntry(^ 1); _linesEntered += 1; if (!response.WasComplete) { if (_linesEntered == 1) { OutputPanel.AddText($"> {_lastEnteredText}"); } else { OutputPanel.AddText($". {_lastEnteredText}"); } OutputPanel.AddText("."); return; } // Remove echo of partial submission from the output panel. for (var i = 1; i < _linesEntered; i++) { OutputPanel.RemoveEntry(^ 1); } _linesEntered = 0; // Echo entered script. var echoMessage = new FormattedMessage(); echoMessage.PushColor(Color.FromHex("#D4D4D4")); echoMessage.AddText("> "); echoMessage.AddMessage(response.Echo); OutputPanel.AddMessage(echoMessage); OutputPanel.AddMessage(response.Response); OutputPanel.AddText(">"); }
private void _addFormattedLineInternal(FormattedMessage message) { Output.AddMessage(message); }
protected override async void Run() { var code = InputBar.Text; InputBar.Clear(); // Remove > or . at the end of the output panel. OutputPanel.RemoveEntry(^ 1); _inputBuffer.AppendLine(code); _linesEntered += 1; var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(_inputBuffer.ToString()), ScriptInstanceShared.ParseOptions); if (!SyntaxFactory.IsCompleteSubmission(tree)) { if (_linesEntered == 1) { OutputPanel.AddText($"> {code}"); } else { OutputPanel.AddText($". {code}"); } OutputPanel.AddText("."); return; } code = _inputBuffer.ToString().Trim(); // Remove echo of partial submission from the output panel. for (var i = 1; i < _linesEntered; i++) { OutputPanel.RemoveEntry(^ 1); } _inputBuffer.Clear(); _linesEntered = 0; Script newScript; if (_state != null) { newScript = _state.Script.ContinueWith(code); } else { var options = ScriptInstanceShared.GetScriptOptions(_reflectionManager); newScript = CSharpScript.Create(code, options, typeof(ScriptGlobals)); } // Compile ahead of time so that we can do syntax highlighting correctly for the echo. newScript.Compile(); // Echo entered script. var echoMessage = new FormattedMessage(); echoMessage.PushColor(Color.FromHex("#D4D4D4")); echoMessage.AddText("> "); ScriptInstanceShared.AddWithSyntaxHighlighting(newScript, echoMessage, code, _highlightWorkspace); OutputPanel.AddMessage(echoMessage); try { if (_state != null) { _state = await newScript.RunFromAsync(_state, _ => true); } else { _state = await newScript.RunAsync(_globals, _ => true); } } catch (CompilationErrorException e) { var msg = new FormattedMessage(); msg.PushColor(Color.Crimson); foreach (var diagnostic in e.Diagnostics) { msg.AddText(diagnostic.ToString()); msg.AddText("\n"); } OutputPanel.AddMessage(msg); OutputPanel.AddText(">"); return; } if (_state.Exception != null) { var msg = new FormattedMessage(); msg.PushColor(Color.Crimson); msg.AddText(CSharpObjectFormatter.Instance.FormatException(_state.Exception)); OutputPanel.AddMessage(msg); } else if (ScriptInstanceShared.HasReturnValue(newScript)) { var msg = new FormattedMessage(); msg.AddText(CSharpObjectFormatter.Instance.FormatObject(_state.ReturnValue)); OutputPanel.AddMessage(msg); } OutputPanel.AddText(">"); }