public void Hide() { var w = window; if (w != null) { ApplicationExtensions.InvokeInUIThreadAndWait(() => { w.Hide(); }); w = null; return; } var p = process; if (p == null) { return; } try { p.CloseMainWindow(); } catch (InvalidOperationException e) { // do not report an exception if the problem has already exited if (!e.Message.Contains("finished") && !e.Message.Contains("exited")) { throw; } } process = null; }
public ConsoleWindowBackendAnalyzer() { preferredTerminal = ConfigurationManager.Instance.Get("general", "terminal", TerminalTypes.Termsharp); #if EMUL8_PLATFORM_WINDOWS if (preferredTerminal != TerminalTypes.Termsharp) { Logger.LogAs(this, LogLevel.Warning, "Only >>Termsharp<< terminal is available on Windows - forcing to use it."); } #endif if (preferredTerminal == TerminalTypes.Termsharp) { ApplicationExtensions.InvokeInUIThreadAndWait(() => { terminalWidget = new TerminalWidget(() => window.HasFocus); }); IO = terminalWidget.IO; } #if !EMUL8_PLATFORM_WINDOWS else { ptyUnixStream = new PtyUnixStream(); IO = new IOProvider(new StreamIOSource(ptyUnixStream)); } #endif }
private void StopXwtThread() { lock (internalLock) { if (UiThreadId == -1) { return; } ApplicationExtensions.InvokeInUIThreadAndWait(Application.Exit); } }
public override void Show() { string tabName; if (!EmulationManager.Instance.CurrentEmulation.TryGetEmulationElementName(Backend.AnalyzableElement, out tabName)) { tabName = "?"; } ApplicationExtensions.InvokeInUIThreadAndWait(() => Emulator.UserInterfaceProvider.ShowAnalyser(this, tabName)); }
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)); }
public override void AttachTo(T backend) { base.AttachTo(backend); ApplicationExtensions.InvokeInUIThreadAndWait(() => OnAttach(backend)); }
public override void Hide() { ApplicationExtensions.InvokeInUIThreadAndWait(() => Emulator.UserInterfaceProvider.HideAnalyser(this)); }