forked from Pash-Project/Pash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cs
55 lines (42 loc) · 1.28 KB
/
MainWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using Gtk;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Host;
using PashGui;
public partial class MainWindow: Gtk.Window
{
readonly Model Model;
Runspace runspace { get { return this.Model.runspace; } }
public MainWindow(): base (Gtk.WindowType.Toplevel)
{
Build();
this.consoleview1.ConsoleInput += this.OnConsoleview1ConsoleInput;
Runspace runspace = RunspaceFactory.CreateRunspace(new Host(this.consoleview1));
this.Model = new Model(runspace);
this.runspace.Open();
ExecutePrompt();
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
void ExecuteCommand(string command)
{
using (Pipeline currentPipeline = this.Model.BuildExecutePipeline(command, true))
{
currentPipeline.Invoke();
}
}
void ExecutePrompt()
{
this.consoleview1.PromptString = this.Model.ExecutePrompt();
this.consoleview1.Prompt(false);
}
protected void OnConsoleview1ConsoleInput(object sender, MonoDevelop.Components.ConsoleInputEventArgs e)
{
string command = e.Text;
ExecuteCommand(command);
ExecutePrompt();
}
}