On Thu, Sep 25, 2008 at 12:50 PM, True Friend <[EMAIL PROTECTED]> wrote:
>
> Ok I have added it to the MainWindow's constructor as follows.
>
> this.textview1.Buffer.Changed += new EventHandler(OnTextBufferChanged);
>
> The evnt handler is as follows.
> -----------------------------------------------
> protected virtual void OnTextBufferChanged(object o, System.EventArgs e)
>     {
>         string temp = this.textview1.Buffer.Text;
>            string temp1 = Regex.Replace(temp, "[\x0011\x0012\u0060]", "\'");
>            string temp2 = Regex.Replace(temp1, "[\x0013\x0014]", "\"");
>            string temp3 = Regex.Replace(temp2, "[+\x0017\x0005\x0015]", "");
>            string temp4 = Regex.Replace(temp3, "\x0016", "-");
>         this.textview1.Buffer.Text = temp4;
>     }

When you set the text, you fire a Changed event, which sets the text... etc

Add a flag that you can use to break the loop:

bool changingText = false;

protected virtual void OnTextBufferChanged(object o, System.EventArgs e)
{
    if (changingText)
        return;

    //do stuff

    changingText = true;
    this.textview1.Buffer.Text = temp4;
    changingText = false;
}

-- 
Michael Hutchinson
http://mjhutchinson.com
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to