public void Initialize(IPadWindow container) { if (IdeApp.Preferences.CustomOutputPadFont != null) customFont = IdeApp.Preferences.CustomOutputPadFont; else customFont = Pango.FontDescription.FromString("Courier New"); view = new ReplView (); view.PromptMultiLineString = "+ "; view.ConsoleInput += OnViewConsoleInput; view.SetFont (customFont); view.ShadowType = Gtk.ShadowType.None; //view.AddMenuCommand("Start Interactive Session", StartInteractiveSessionHandler); //view.AddMenuCommand("Connect to Interactive Session", ConnectToInteractiveSessionHandler); view.ShowAll (); IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomOutputPadFontChanged; ReplPad.Instance = this; }
public StreamOutputter(StreamReader source, ReplView destination, string name="") { this.Source = source; this.Destination = destination; this.Name = name; }
public ReplSession(ReplView view, int port, Process proc = null) { replView = view; process = proc; this.port = port; if (proc != null) { stderr = new StreamOutputter (proc.StandardError, replView); stdout = new StreamOutputter (proc.StandardOutput, replView); Stderr.Start (); Stdout.Start (); } var tmprepl = new CSharpReplServerProxy (String.Format ("tcp://127.0.0.1:{0}", port)); tmprepl.Start (); repl = tmprepl; }
public ReplSession(ReplView view, string address) { replView = view; this.port = port; var tmprepl = new CSharpReplServerProxy (address); tmprepl.Start (); repl = tmprepl; }
void StartInteractiveSession(ReplView view, string platform = "AnyCPU") { if (view == null) { throw new InvalidProgramException ("ReplView is null"); } string exe_name; switch (platform.ToLower ()) { case "anycpu": exe_name = "CSharpReplServer.exe"; break; case "x86": exe_name = "CSharpReplServer32.exe"; break; case "x64": exe_name = "CSharpReplServer64.exe"; break; default: view.WriteOutput (String.Format ("Cannot start interactive session for platform {0}. Platform not supported.", platform)); return; } string bin_dir = Path.GetDirectoryName (Assembly.GetAssembly (typeof(ReplPad)).Location); string repl_exe = Path.Combine (bin_dir, exe_name); var port = nextPort++; var config = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.Project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration) as DotNetProjectConfiguration; var start_info = new ProcessStartInfo (repl_exe, port.ToString ()); start_info.UseShellExecute = false; start_info.CreateNoWindow = true; start_info.RedirectStandardError = true; start_info.RedirectStandardOutput = true; var proc = config.TargetRuntime.ExecuteAssembly (start_info); var session = new ReplSession (view, port, proc); replSessions.Add (view, session); //Running = true; Thread.Sleep (1000); // Give _repl_process time to start up before we let anybody do anything with it }
private ReplView AddRepl(string title = "REPL") { var repl = new ReplView (); repl.PromptString = "csharp> "; repl.PromptMultiLineString = "+ "; repl.ConsoleInput += OnViewConsoleInput; repl.SetFont (customFont); repl.ShadowType = Gtk.ShadowType.None; var tabLabel = new MDComponents.TabLabel (new Label (title), emptyImage); notebook.AppendPage (repl, tabLabel); if (notebook.NPages < 2) notebook.ShowTabs = false; else notebook.ShowTabs = true; tabLabel.CloseClicked += (object sender, EventArgs e) => { Stop (repl); }; notebook.ShowAll (); return repl; }
public void Stop(ReplView view) { if (view != null) { if (replSessions.ContainsKey (view)) { var session = replSessions [view]; if (session != null) { session.Stdout.Stop (); session.Stderr.Stop (); try { session.Process.Kill (); } catch (InvalidOperationException) { } session.Process.Close (); session.Process.Dispose (); } } if (notebook.Children.Contains (view)) notebook.Remove (view); } }