2004-01-17 22:47:35 +00:00
|
|
|
using System;
|
2004-07-06 00:52:13 +00:00
|
|
|
using System.Collections;
|
2004-01-17 22:47:35 +00:00
|
|
|
using Gtk;
|
|
|
|
using Vte;
|
|
|
|
|
|
|
|
class T
|
|
|
|
{
|
2006-01-17 18:49:14 +00:00
|
|
|
private Gtk.Window window;
|
|
|
|
|
2004-01-17 22:47:35 +00:00
|
|
|
static void Main (string[] args)
|
|
|
|
{
|
|
|
|
new T (args);
|
|
|
|
}
|
|
|
|
|
|
|
|
T (string[] args)
|
|
|
|
{
|
2006-01-17 18:49:14 +00:00
|
|
|
|
|
|
|
Application.Init();
|
|
|
|
window = new Gtk.Window("Test for vte widget");
|
|
|
|
window.SetDefaultSize(600, 450);
|
|
|
|
window.DeleteEvent += new DeleteEventHandler (OnAppDelete);
|
2004-01-17 22:47:35 +00:00
|
|
|
|
2004-07-06 00:52:13 +00:00
|
|
|
HBox hbox = new HBox ();
|
2004-01-17 22:47:35 +00:00
|
|
|
Terminal term = new Terminal ();
|
2004-01-29 01:08:46 +00:00
|
|
|
term.EncodingChanged += new EventHandler (OnEncodingChanged);
|
2004-01-17 22:47:35 +00:00
|
|
|
term.CursorBlinks = true;
|
2004-01-18 00:54:08 +00:00
|
|
|
term.MouseAutohide = true;
|
|
|
|
term.ScrollOnKeystroke = true;
|
2004-01-29 01:08:46 +00:00
|
|
|
term.DeleteBinding = TerminalEraseBinding.Auto;
|
2004-04-04 21:18:56 +00:00
|
|
|
term.BackspaceBinding = TerminalEraseBinding.Auto;
|
2004-01-17 22:47:35 +00:00
|
|
|
term.Encoding = "UTF-8";
|
2004-04-04 21:18:56 +00:00
|
|
|
term.FontFromString = "Monospace 12";
|
2004-01-29 01:08:46 +00:00
|
|
|
term.TextDeleted += new EventHandler (OnTextDeleted);
|
2004-04-04 21:18:56 +00:00
|
|
|
term.ChildExited += new EventHandler (OnChildExited);
|
2004-01-29 01:08:46 +00:00
|
|
|
|
2004-07-06 00:52:13 +00:00
|
|
|
VScrollbar vscroll = new VScrollbar (term.Adjustment);
|
|
|
|
hbox.PackStart (term);
|
|
|
|
hbox.PackStart (vscroll);
|
|
|
|
|
2004-01-29 01:08:46 +00:00
|
|
|
Gdk.Color white = new Gdk.Color ();
|
|
|
|
Gdk.Color.Parse ("white", ref white);
|
2004-04-04 21:18:56 +00:00
|
|
|
// FIXME: following line is broken
|
|
|
|
//term.ColorBackground = white;
|
|
|
|
|
|
|
|
Gdk.Color black = new Gdk.Color ();
|
|
|
|
Gdk.Color.Parse ("black", ref black);
|
|
|
|
// FIXME: following line is broken
|
|
|
|
//term.ColorForeground = black;
|
2005-09-24 07:47:12 +00:00
|
|
|
|
|
|
|
// Create a palette with 0 colors. this could be replaced with
|
|
|
|
// a palette of colors with a size of 0, 8, 16, or 24.
|
|
|
|
Gdk.Color[] palette = new Gdk.Color[0];
|
|
|
|
|
|
|
|
term.SetColors (black, white, palette, palette.Length);
|
2004-01-17 22:47:35 +00:00
|
|
|
|
2004-07-06 00:52:13 +00:00
|
|
|
//Console.WriteLine (term.UsingXft);
|
|
|
|
//Console.WriteLine (term.Encoding);
|
|
|
|
//Console.WriteLine (term.StatusLine);
|
2004-01-18 00:54:08 +00:00
|
|
|
|
2004-04-04 21:18:56 +00:00
|
|
|
string[] argv = Environment.GetCommandLineArgs ();
|
2004-07-06 00:52:13 +00:00
|
|
|
// seems to want an array of "variable=value"
|
|
|
|
string[] envv = new string [Environment.GetEnvironmentVariables ().Count];
|
|
|
|
int i = 0;
|
|
|
|
foreach (DictionaryEntry e in Environment.GetEnvironmentVariables ())
|
|
|
|
{
|
|
|
|
if (e.Key == "" || e.Value == "")
|
|
|
|
continue;
|
|
|
|
string tmp = String.Format ("{0}={1}", e.Key, e.Value);
|
|
|
|
envv[i] = tmp;
|
|
|
|
i ++;
|
|
|
|
}
|
2004-01-18 00:54:08 +00:00
|
|
|
|
2004-07-06 00:52:13 +00:00
|
|
|
int pid = term.ForkCommand (Environment.GetEnvironmentVariable ("SHELL"), argv, envv, Environment.CurrentDirectory, false, true, true);
|
|
|
|
Console.WriteLine ("Child pid: {0}", pid);
|
2004-01-17 22:47:35 +00:00
|
|
|
|
2006-01-17 18:49:14 +00:00
|
|
|
window.Add(hbox);
|
|
|
|
window.ShowAll();
|
|
|
|
Application.Run();
|
2004-01-17 22:47:35 +00:00
|
|
|
}
|
2004-01-29 01:08:46 +00:00
|
|
|
|
|
|
|
private void OnTextDeleted (object o, EventArgs args)
|
|
|
|
{
|
|
|
|
Console.WriteLine ("text deleted");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnEncodingChanged (object o, EventArgs args)
|
|
|
|
{
|
|
|
|
Console.WriteLine ("encoding changed");
|
|
|
|
}
|
2004-01-17 22:47:35 +00:00
|
|
|
|
|
|
|
private void OnTextInserted (object o, EventArgs args)
|
|
|
|
{
|
2004-04-04 21:18:56 +00:00
|
|
|
Console.WriteLine ("text inserted");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnChildExited (object o, EventArgs args)
|
|
|
|
{
|
|
|
|
// optionally we could just reset instead of quitting
|
|
|
|
Console.WriteLine ("child exited");
|
|
|
|
Application.Quit ();
|
2004-01-17 22:47:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnAppDelete (object o, DeleteEventArgs args)
|
|
|
|
{
|
2004-04-04 21:18:56 +00:00
|
|
|
Application.Quit ();
|
2004-01-17 22:47:35 +00:00
|
|
|
}
|
|
|
|
}
|