private static void ShowErrorWindow(string message) { var dialog = new Dialog(); dialog.Title = "Fatal error"; var markdown = new MarkdownView(); markdown.Markdown = message.Split(new [] { '\n' }).Select(x => "\t" + x).Aggregate((x, y) => x + "\n" + y); var copyButton = new Button("Copy to clipboard"); copyButton.Clicked += (sender, ev) => Clipboard.SetText(message); var box = new VBox(); box.PackStart(new Label("Got unhandled exception") { Font = global::Xwt.Drawing.Font.SystemFont.WithSize(15).WithWeight(Xwt.Drawing.FontWeight.Bold) }); box.PackStart(new ScrollView(markdown), true, true); box.PackStart(copyButton); dialog.Content = box; dialog.Buttons.Add(new DialogButton(Command.Ok)); dialog.Width = 350; dialog.Height = 300; var mre = new ManualResetEvent(false); ApplicationExtensions.InvokeInUIThread(() => { dialog.Run(); dialog.Dispose(); mre.Set(); }); mre.WaitOne(); }
public void Show() { #if !EMUL8_PLATFORM_WINDOWS if (terminalWidget != null) { #endif var mre = new ManualResetEventSlim(); ApplicationExtensions.InvokeInUIThread(() => { window = new Window(); window.Title = Name; window.Width = 700; window.Height = 400; window.Padding = new WidgetSpacing(); window.Content = terminalWidget; terminalWidget.Initialized += mre.Set; window.Show(); window.Closed += (sender, e) => { DetachConsoleWindow(); OnClose(); }; if (NextWindowLocation != default(Point)) { window.Location = NextWindowLocation; NextWindowLocation = NextWindowLocation.Offset(WindowOffset); } else { NextWindowLocation = window.Location.Offset(WindowOffset); } }); mre.Wait(); #if !EMUL8_PLATFORM_WINDOWS } else { var windowCreators = new Dictionary <TerminalTypes, CreateWindowDelegate> { #if EMUL8_PLATFORM_LINUX { TerminalTypes.XTerm, CreateXtermWindow }, { TerminalTypes.Putty, CreatePuttyWindow }, { TerminalTypes.GnomeTerminal, CreateGnomeTerminalWindow }, #endif #if EMUL8_PLATFORM_OSX { TerminalTypes.TerminalApp, CreateTerminalAppWindow } #endif } ; var commandString = string.Format("screen {0}", ptyUnixStream.SlaveName); //Try preferred terminal first, than any other. If all fail, throw. if (!windowCreators.OrderByDescending(x => x.Key == preferredTerminal).Any(x => x.Value(commandString, out process))) { throw new NotSupportedException(String.Format("Could not start terminal. Possible config values: {0}.", windowCreators.Keys.Select(x => x.ToString()) .Prepend(TerminalTypes.Termsharp.ToString()).Aggregate((x, y) => x + ", " + y))); } Thread.Sleep(1000); // I know - this is ugly. But here's the problem: // we start terminal process with embedded socat and it takes time // how much? - you ask // good question - we don't know it; sometimes more, sometimes less // sometimes it causes a problem - socat is not ready yet when first data arrives // what happens then? - you ask // good question - we lost some input, Emul8 banner most probably // how to solve it? - you ask // good question - with no good answer though, i'm affraid // that is why we sleep here for 1s hoping it's enough // // This will be finally changed to our own implementation of VirtualTerminalEmulator. } #endif if (Backend != null) { ((UARTBackend)Backend).BindAnalyzer(IO); } }
public void Write(byte b) { ApplicationExtensions.InvokeInUIThread(() => utfDecoder.Feed(b)); }