Beispiel #1
0
    public DemoApp(string[] args, params object[] props) : base("DemoApp", "0.1", Modules.UI, args, props)
    {
        ParseArgs(args);

        Glade.XML gxml = new Glade.XML("sourceview.glade", "win", null);
        gxml.Autoconnect(this);

        if (win == null)
        {
            throw new Exception("GladeWidgetAttribute is broken.");
        }

        Gtk.TextView tw = (Gtk.TextView)gxml.GetWidget("tw");

        System.IO.StreamReader stream = new StreamReader(this.file);
        string text = stream.ReadToEnd();

        tw.Buffer.Insert(tw.Buffer.EndIter, text);

        Console.WriteLine("here we go");
        Config     conf = new Config();
        Highlights hl   = new Highlights(conf.patterns);

        ConnectTextTagTable(tw.Buffer.TagTable, conf.styles);

        hl.DebugPrint();
        Token [] tokens = hl.Search(text);

        foreach (Token t in tokens)
        {
            Gtk.TextIter siter, eiter;

            tw.Buffer.GetIterAtOffset(out siter, t.sindex);
            tw.Buffer.GetIterAtOffset(out eiter, t.eindex);

            //Console.WriteLine("*** {3} - {4}*** <{0}>{1}</{0}:{2}>",
            //t.style.name, tw.Buffer.GetText(siter, eiter, false), t.style.pattern, t.sindex, t.eindex + 1);

            tw.Buffer.ApplyTag(tw.Buffer.TagTable.Lookup(t.style.path), siter, eiter);
        }
    }