Пример #1
0
    public void PreviousWord(object o, EventArgs args)
    {
        if (startWordIter.Equal(Gtk.TextIter.Zero))
        {
            startWordIter = textBuffer.StartIter;
        }
        endWordIter = startWordIter;

        while (startWordIter.BackwardChar() && !startWordIter.StartsWord())
        {
        }

        curWord = startWordIter.GetText(endWordIter);

        curWord = Regex.Replace(curWord, @"--", "", RegexOptions.Multiline);
        curWord = curWord.TrimStart(new char[5] {
            ' ', '\n', '\t', '\r', '-'
        });
        curWord = curWord.TrimEnd(new char[5] {
            ' ', '\n', '\t', '\r', '-'
        });
        curWord = Regex.Replace(curWord, @"\s+", " ", RegexOptions.Multiline);
        //Console.WriteLine("Word: \"" + curWord +"\"");
        ShowWord(curWord);
        HilightWord();
        slideLock    = true;
        slider.Value = endWordIter.Offset;
        slideLock    = false;
    }
Пример #2
0
 public void NextWord(object o, EventArgs args)
 {
     if (!running)
     {
         if (endWordIter.Equal(Gtk.TextIter.Zero))
         {
             endWordIter = textBuffer.StartIter;
         }
         startWordIter = endWordIter;
         curWord       = GetNextWord();
         if (curWord == "")
         {
             return;
         }
         HilightWord();
         ShowWord(curWord);
         slideLock    = true;
         slider.Value = endWordIter.Offset;
         slideLock    = false;
     }
 }
Пример #3
0
    public void OpenFile(string filename)
    {
        string text;

        TextReader reader = File.OpenText(filename);

        try {
            statusBar.Push(0, "Opening file " + filename);
            text = reader.ReadToEnd();
        } finally {
            if (reader != null)
            {
                ((IDisposable)reader).Dispose();
            }
        }

        statusBar.Push(0, filename);
        textBuffer      = textView.Buffer;
        textBuffer.Text = text;

        //endWordIter = textBuffer.StartIter;
        endWordIter      = Gtk.TextIter.Zero;
        startWordIter    = Gtk.TextIter.Zero;
        endHilightIter   = Gtk.TextIter.Zero;
        startHilightIter = Gtk.TextIter.Zero;
        curWord          = "";
        slider.SetRange(0, textBuffer.CharCount);
        MakeHilightTag();

        if (endWordIter.Equal(Gtk.TextIter.Zero))
        {
            endWordIter = textBuffer.StartIter;
        }
        startWordIter = endWordIter;
        curWord       = GetNextWord();
        ShowWord(curWord);
        HilightWord();

        fileLoaded            = true;
        startButton.Sensitive = true;
        prevButton.Sensitive  = true;
        nextButton.Sensitive  = true;
    }