Ejemplo n.º 1
0
        void OnMenuItemActivated(object sender, EventArgs args)
        {
            Gtk.TextIter cursor = Buffer.GetIterAtMark (Buffer.InsertMark);

            CodeSnippetWindow newcs = new CodeSnippetWindow ();

            Gtk.TextChildAnchor child = Buffer.CreateChildAnchor (ref cursor);
            Window.Editor.AddChildAtAnchor (newcs, child);

            newcs.cs_pos = Buffer.CreateMark (null, Buffer.GetIterAtChildAnchor (child), false);
            newcs.cs_pos_ = Buffer.CreateMark (null, Buffer.GetIterAtChildAnchor (child), true);

            newcs.ShowAll ();
            csList.Add (newcs);
        }
Ejemplo n.º 2
0
        void checkCodeSnippet()
        {
            string lang;
            try {
                Gtk.TextIter pos = Buffer.StartIter;
                pos.ForwardLine (); // skip the title

                while (true) {
                    Gtk.TextIter match_start = pos;
                    Gtk.TextIter match_end = pos;
                    string code;
                    if (!findCodeSnippet (pos, out match_start, out match_end, out lang, out code))
                        break;
                    Logger.Info ("Code Snippet: Creating snippet ...");

                    CodeSnippetWindow newcs = new CodeSnippetWindow ();
                    newcs.writeCode (code, lang);

                    newcs.cs_pos_ = Buffer.CreateMark (null, match_start, true);
                    Buffer.ApplyTag ("codesnippet_code", match_start, match_end);

                    Gtk.TextChildAnchor child = Buffer.CreateChildAnchor (ref match_end);
                    newcs.cs_pos = Buffer.CreateMark (null, Buffer.GetIterAtChildAnchor (child), false);
                    Window.Editor.AddChildAtAnchor (newcs, child);

                    newcs.ShowAll ();

                    csList.Add (newcs);
                    pos = Buffer.GetIterAtMark (newcs.cs_pos);

                }
            } finally {
            }
        }