Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
* History.cs: Remove history, will implement a different system than
Browse files Browse the repository at this point in the history
  the bash-like system.  This model does not match.
* Main.cs: Use a cool trick from Alan McGovern to guess whether the
  host application had Gtk running or not.

svn path=/trunk/mono-tools/; revision=114345
  • Loading branch information
migueldeicaza committed Sep 28, 2008
1 parent ab54370 commit 6e3247e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 252 deletions.
7 changes: 7 additions & 0 deletions gsharp/ChangeLog
@@ -1,3 +1,10 @@
2008-09-28 Miguel de Icaza <miguel@novell.com>

* History.cs: Remove history, will implement a different system than
the bash-like system. This model does not match.
* Main.cs: Use a cool trick from Alan McGovern to guess whether the
host application had Gtk running or not.

2008-09-28 Miguel de Icaza <miguel@novell.com>

* MainWindow.cs: New dialog box, based on Paolo's dialog box.
Expand Down
221 changes: 0 additions & 221 deletions gsharp/History.cs

This file was deleted.

19 changes: 17 additions & 2 deletions gsharp/Main.cs
Expand Up @@ -14,11 +14,24 @@ namespace Mono.CSharp.Gui
class MainClass
{
public static bool Attached;
public static bool HostHasGtkRunning;

public static void Main (string[] args)
{
if (args.Length > 0 && args [0] == "--agent"){
Attached = true;

// First, try to detect if Gtk.Application.Run is running,
// to determine whether we need to run a mainloop oursvels or not.
//
// This test is not bullet proof, its just a simple guess.
//
// Thanks to Alan McGovern for this brilliant hack.
//
ManualResetEvent handle = new ManualResetEvent(false);

Gtk.Application.Invoke (delegate { handle.Set (); });
HostHasGtkRunning = handle.WaitOne (3000, true);

Gtk.Application.Invoke (delegate {
try {
Expand All @@ -44,7 +57,6 @@ public static void Main (string[] args)
return;
}
Start ("C# InteractiveBase Shell");
Application.Run ();
}

static void AssemblyLoaded (object sender, AssemblyLoadEventArgs e)
Expand All @@ -54,10 +66,13 @@ static void AssemblyLoaded (object sender, AssemblyLoadEventArgs e)

public static void Start (string title)
{
Application.Init ();
if (!HostHasGtkRunning)
Application.Init ();
MainWindow m = new MainWindow ();
m.Title = title;
m.ShowAll ();
if (!HostHasGtkRunning)
Application.Run ();
}
}
}
1 change: 0 additions & 1 deletion gsharp/Mono.CSharp.Gui.csproj
Expand Up @@ -51,7 +51,6 @@
<Compile Include="Shell.cs" />
<Compile Include="MainWindow.cs" />
<Compile Include="gtk-gui\Mono.CSharp.Gui.MainWindow.cs" />
<Compile Include="History.cs" />
<Compile Include="ProcessSelector.cs" />
<Compile Include="gtk-gui\Mono.CSharp.Gui.ProcessSelector.cs" />
</ItemGroup>
Expand Down
34 changes: 6 additions & 28 deletions gsharp/Shell.cs
Expand Up @@ -46,7 +46,6 @@ public class Shell : TextView
{
TextMark end_of_last_processing;
string expr = null;
History history;

public Shell() : base()
{
Expand All @@ -56,9 +55,6 @@ public Shell() : base()
Pango.FontDescription font_description = new Pango.FontDescription();
font_description.Family = "Monospace";
ModifyFont(font_description);

history = new History ("gsharp", 300);
history.CursorToEnd ();

TextIter end = Buffer.EndIter;
Buffer.InsertWithTagsByName (ref end, "Mono C# Shell, type 'help;' for help\n\nEnter statements or expressions below.\n", "Comment");
Expand Down Expand Up @@ -146,7 +142,7 @@ bool Evaluate (string s)

void HistoryUpdateLine ()
{
history.Update (GetCurrentExpression ());
Console.WriteLine ("ADDED: {0}", GetCurrentExpression ());
expr = null;
}

Expand All @@ -170,23 +166,17 @@ protected override bool OnKeyPressEvent(Gdk.EventKey evnt)
string copy;
copy = expr = GetCurrentExpression ();

if (Evaluate (expr))
history.Accept (copy);

if (Evaluate (expr)){
}
return true;

case Gdk.Key.Up:
if (!history.PreviousAvailable ())
return true;
HistoryUpdateLine ();
InputLine = history.Previous ();

return true;

case Gdk.Key.Down:
if (!history.NextAvailable ())
return true;
HistoryUpdateLine ();
InputLine = history.Next ();

return true;

case Gdk.Key.Left:
Expand Down Expand Up @@ -313,18 +303,6 @@ public void SetResult (InterpreterResult result)
Buffer.Insert(ref start, value);
}
}

private bool InputLineStartsBlock {
get {
string line = InputLine.Trim();

if(line.Length > 0) {
return line.Substring(line.Length - 1) == ":";
}

return false;
}
}

static void p (TextWriter output, string s)
{
Expand Down

0 comments on commit 6e3247e

Please sign in to comment.