[nem-pl] Re: Vte w nemerle
Michal Moskal
malekith at pld-linux.org
Wed Feb 25 19:18:07 CET 2004
On Wed, Feb 25, 2004 at 02:15:40PM +0100, Artur Frysiak wrote:
> Witam.
> MoĹźesz mi podpowiedzieÄ co robie nie tak jak powinienem ?
Hm, coś nie tak z encoding? Czy mój mutt głupieje?
> // REFERENCE: System.dll
> // REFERENCE: gtk-sharp.dll
> // REFERENCE: gnome-sharp.dll
> // REFERENCE: vte-sharp.dll
To jest tylko dla tego programu do testowania. Jak kompilujesz z command
line to nie musisz tego pisać.
Ładowanie bibliotek mamy teraz trochę zepsute, nie ładują się
automagicznie zależności i dlatego dość dziwnie się sypie. (short
term TODO).
Pełny command line żeby to skompilować, to:
ncc VteTest.n -r gtk-sharp -r gnome-sharp -r vte-sharp \
-r glib-sharp -r gdk-sharp -r System.Drawing
> public Main (_args : string) : void
public static Main (args : array <string>) : void
> {
> def test = T (_args);
> test;
Ta funkcja zwraca obiek klasy T, dlatego był błąd. Żeby stworzyć obiekt
i zignorować go użyj
ignore (T (args))
> def program = Program ("test", "0.0", Modules.UI, _args);
W gnome-sharp 0.16 trzeba jeszcze jakieś properties (pusta tablica).
> app.DeleteEvent += DeleteEventHandler (OnAppDelete);
Tego niestety jeszcze nie mamy (somewhat longer TODO). Na szczęście
można to obejść.
app.add_DeleteEvent (DeleteEventHandler (OnAppDelete));
> def term.CursorBlinks = true;
Przypisanie do pola robi się tak:
term.CursorBlinks <- true;
> def white = Gdk.Color ();
> Gdk.Color.Parse ("white", ref white);
Parametrów ref też niestety nie ma :/ (jeszcze dłuższe TODO).
> Console.WriteLine (Environment.GetEnvironmentVariables ().Count);
Hm, u mnie coś nie umiał tego Count znaleźć. Ale nie wiem czemu.
> private OnCommit (o : object, args:VteSharp.CommitArgs) : void
> {
> def term = o;
def term = (o :> Terminal);
> if (args.P0 == "\r")
> {
> //FIXME: maybe a setting somewhere
> term.Feed ("\r\n");
> return;
Tak też nie można, nie ma return. Trzeba normalnie w if to, a w else to
niżej.
A teraz najlepsze -- po porawieniu tego wszystkiego -- to działa ! :)
Co prawda przy zamykaniu okna coś rzuca wyjątkami, ale to pewnie można
łatwo poprawić.
Załączam poprawiony przykład.
--
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?
-------------- next part --------------
// REFERENCE: System.dll
// REFERENCE: gtk-sharp.dll
// REFERENCE: gnome-sharp.dll
// REFERENCE: vte-sharp.dll
using System;
using Gtk;
using GtkSharp;
using Gnome;
using GnomeSharp;
using Vte;
using VteSharp;
public class N
{
public static Main (_args : array <string>) : void
{
def test = T (_args);
test;
()
}
}
public class T
{
private program : Program;
public this (_args : array <string>)
{
def program = Program ("test", "0.0", Modules.UI, _args, array []);
def app = App ("test", "Test for vte widget");
app.SetDefaultSize (600, 450);
app.add_DeleteEvent (DeleteEventHandler (OnAppDelete));
def sw = ScrolledWindow ();
def term = Terminal ();
term.add_EncodingChanged (EventHandler (OnEncodingChanged));
term.CursorBlinks <- true;
term.MouseAutohide <- true;
term.ScrollOnKeystroke <- true;
term.DeleteBinding <- TerminalEraseBinding.Auto;
term.Encoding <- "UTF-8";
term.FontFromString <- "Monospace";
term.add_Commit (VteSharp.CommitHandler (OnCommit));
term.add_TextDeleted (EventHandler (OnTextDeleted));
def white = Gdk.Color ((255 :> System.Byte), (255 :> System.Byte), (255 :> System.Byte));
term.ColorBackground <- white;
Console.WriteLine (term.UsingXft);
Console.WriteLine (term.Encoding);
Console.WriteLine (term.StatusLine);
def argv = Environment.GetCommandLineArgs () [0];
def envv = "";
// 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 OnCommit (o : object, args:VteSharp.CommitArgs) : void
{
def term = (o :> Terminal);
if (args.P0 == "\r")
//FIXME: maybe a setting somewhere
term.Feed ("\r\n")
else
term.Feed (args.P0)
}
private OnTextDeleted (o : object , args : EventArgs) : void
{
Console.WriteLine ("text deleted");
}
private OnEncodingChanged (o : object , args: EventArgs) : void
{
Console.WriteLine ("encoding changed");
}
private OnTextInserted (o: object, args: EventArgs) : void
{
}
private OnAppDelete (o: object, args: DeleteEventArgs) : void
{
program.Quit ();
}
}
More information about the devel-pl
mailing list