mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-25 20:55:35 +00:00
a0901fea5e
* vte/Vte.metadata: mark argv and envv parameters to Vte.Terminal.ForkCommand as arrays, it finally works * sample/Vte-test.cs: adjust for above svn path=/trunk/gtk-sharp/; revision=25014
92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using System;
|
|
using Gtk;
|
|
using Gnome;
|
|
using Vte;
|
|
|
|
class T
|
|
{
|
|
static void Main (string[] args)
|
|
{
|
|
new T (args);
|
|
}
|
|
|
|
T (string[] args)
|
|
{
|
|
Program program = new Program ("vte-sharp-test", "0.0", Modules.UI, args);
|
|
App app = new App ("vte-sharp-test", "Test for vte widget");
|
|
app.SetDefaultSize (600, 450);
|
|
app.DeleteEvent += new DeleteEventHandler (OnAppDelete);
|
|
|
|
ScrolledWindow sw = new ScrolledWindow ();
|
|
Terminal term = new Terminal ();
|
|
term.EncodingChanged += new EventHandler (OnEncodingChanged);
|
|
term.CursorBlinks = true;
|
|
term.MouseAutohide = true;
|
|
term.ScrollOnKeystroke = true;
|
|
term.DeleteBinding = TerminalEraseBinding.Auto;
|
|
term.BackspaceBinding = TerminalEraseBinding.Auto;
|
|
term.Encoding = "UTF-8";
|
|
term.FontFromString = "Monospace 12";
|
|
term.TextDeleted += new EventHandler (OnTextDeleted);
|
|
term.ChildExited += new EventHandler (OnChildExited);
|
|
|
|
Gdk.Color white = new Gdk.Color ();
|
|
Gdk.Color.Parse ("white", ref white);
|
|
// 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;
|
|
term.SetColors (black, white, white, 16);
|
|
|
|
Console.WriteLine (term.UsingXft);
|
|
Console.WriteLine (term.Encoding);
|
|
Console.WriteLine (term.StatusLine);
|
|
|
|
string[] argv = Environment.GetCommandLineArgs ();
|
|
|
|
string[] envv = new string[] {""};
|
|
// FIXME: send the env vars to ForkCommand
|
|
Console.WriteLine (Environment.GetEnvironmentVariables ().Count);
|
|
Console.WriteLine (Environment.CurrentDirectory);
|
|
|
|
int pid = term.ForkCommand ("/bin/bash", argv, envv, Environment.CurrentDirectory, false, true, true);
|
|
Console.WriteLine ("Child pid: " + pid);
|
|
|
|
sw.AddWithViewport (term);
|
|
|
|
app.Contents = sw;
|
|
app.ShowAll ();
|
|
program.Run ();
|
|
}
|
|
|
|
private void OnTextDeleted (object o, EventArgs args)
|
|
{
|
|
Console.WriteLine ("text deleted");
|
|
}
|
|
|
|
private void OnEncodingChanged (object o, EventArgs args)
|
|
{
|
|
Console.WriteLine ("encoding changed");
|
|
}
|
|
|
|
private void OnTextInserted (object o, EventArgs args)
|
|
{
|
|
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 ();
|
|
}
|
|
|
|
private void OnAppDelete (object o, DeleteEventArgs args)
|
|
{
|
|
Application.Quit ();
|
|
}
|
|
}
|