Beispiel #1
0
    public void HilightWord()
    {
        Gtk.TextIter prevEndCharIter = new Gtk.TextIter();
        //Gtk.TextIter nextCharIter = new Gtk.TextIter ();

        if (!(endHilightIter.Equal(Gtk.TextIter.Zero)))
        {
            textBuffer.RemoveTag("hilight", startHilightIter, endHilightIter);
        }

        startHilightIter = startWordIter;
        endHilightIter   = endWordIter;
        prevEndCharIter  = endWordIter;
        prevEndCharIter.BackwardChar();
        while (Regex.IsMatch(startHilightIter.Char, @"[\s-]", RegexOptions.None))
        {
            startHilightIter.ForwardChar();
        }

        while (Regex.IsMatch(prevEndCharIter.Char, @"\s", RegexOptions.None) &&
               Regex.IsMatch(endHilightIter.Char, @"\S", RegexOptions.None))
        {
            endHilightIter.BackwardChar();
            prevEndCharIter.BackwardChar();
        }

        textBuffer.ApplyTag(tag, startHilightIter, endHilightIter);
        textView.ScrollToIter(endWordIter, 0, false, 0, 0);


        if (!running)
        {
            statusBar.Push(0, "Stopped at position " + startWordIter.Offset);
        }
    }