forked from IronLanguages/ironpython3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIronPythonWindow.cs
More file actions
61 lines (48 loc) · 1.74 KB
/
IronPythonWindow.cs
File metadata and controls
61 lines (48 loc) · 1.74 KB
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
56
57
58
59
60
61
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using System;
using System.Text;
using System.Windows.Forms;
using IronPython.Hosting;
using IronPython.Runtime;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Providers;
using Microsoft.Scripting.Hosting.Shell;
internal sealed class PythonWindowsConsoleHost : ConsoleHost {
protected override Type Provider {
get { return typeof(PythonContext); }
}
protected override CommandLine/*!*/ CreateCommandLine() {
return new PythonCommandLine();
}
protected override OptionsParser/*!*/ CreateOptionsParser() {
return new PythonOptionsParser();
}
protected override LanguageSetup/*!*/ CreateLanguageSetup() {
return Python.CreateLanguageSetup(null);
}
protected override string/*!*/ GetHelp() {
StringBuilder sb = new StringBuilder();
sb.AppendLine(PythonCommandLine.GetLogoDisplay());
PrintLanguageHelp(sb);
sb.AppendLine();
return sb.ToString();
}
protected override void ExecuteInternal() {
var pc = HostingHelpers.GetLanguageContext(Engine) as PythonContext;
pc.SetModuleState(typeof(ScriptEngine), Engine);
base.ExecuteInternal();
}
[STAThread]
private static int Main(string[] args) {
if (args.Length == 0) {
new PythonWindowsConsoleHost().PrintHelp();
return 1;
}
return new PythonWindowsConsoleHost().Run(args);
}
protected override void PrintHelp() {
MessageBox.Show(GetHelp(), "IronPython Window Console Help");
}
}