Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gsharp/MainWindow.cs')
-rw-r--r--gsharp/MainWindow.cs68
1 files changed, 67 insertions, 1 deletions
diff --git a/gsharp/MainWindow.cs b/gsharp/MainWindow.cs
index 4003f695..cb26b969 100644
--- a/gsharp/MainWindow.cs
+++ b/gsharp/MainWindow.cs
@@ -48,7 +48,73 @@ namespace Mono.CSharp.Gui
p.Destroy ();
}
-
+ delegate string ReadLiner (bool primary);
+
+ public void LoadStartupFiles ()
+ {
+ string dir = System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
+ "gsharp");
+ if (!System.IO.Directory.Exists (dir))
+ return;
+
+ ArrayList sources = new ArrayList ();
+ ArrayList libraries = new ArrayList ();
+
+ foreach (string file in System.IO.Directory.GetFiles (dir)){
+ string l = file.ToLower ();
+
+ if (l.EndsWith (".cs"))
+ sources.Add (file);
+ else if (l.EndsWith (".dll"))
+ libraries.Add (file);
+ }
+
+ foreach (string file in libraries){
+ Evaluator.LoadAssembly (file);
+ }
+
+ foreach (string file in sources){
+ try {
+ using (System.IO.StreamReader r = System.IO.File.OpenText (file)){
+ ReadEvalPrintLoopWith (p => r.ReadLine ());
+ }
+ } catch {
+ }
+ }
+ }
+
+ string Evaluate (string input)
+ {
+ bool result_set;
+ object result;
+
+ try {
+ input = Evaluator.Evaluate (input, out result, out result_set);
+ } catch (Exception e){
+ Console.WriteLine (e);
+ return null;
+ }
+
+ return input;
+ }
+
+ void ReadEvalPrintLoopWith (ReadLiner readline)
+ {
+ string expr = null;
+ while (true){
+ string input = readline (expr == null);
+ if (input == null)
+ return;
+
+ if (input == "")
+ continue;
+
+ expr = expr == null ? input : expr + "\n" + input;
+
+ expr = Evaluate (expr);
+ }
+ }
+
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
this.Build();