Re: [gtk-list] Re: gtktext anyone?



On Wed, 3 Dec 1997 Stefan_Wille@public.uni-hamburg.de wrote:

> On  3 Dec, Arun Sharma wrote:
> > 
> > Looks like no one is working on the gtktext widget. One of the main
> > reasons why Gtk gets beaten up on the Usenet seems to be due to the
> > absence of a good text widget.
> 
> > I'm hoping to be able to spend some time working on it. If you have
> > a wish list please send it to me.
> 
> cool! - here is my wish list:
> 
> - cut/copy/paste
> - unlimited undo/redo - this probably is a bunch of work, but I always
>   find it very annoying when I cannot use 'undo' in an email editor.

Actually, with the proper model this can be very simple. The basic idea is
that every function performed on the text widget should add another
function to a list that undoes the function. With sufficient ingenuity,
this one concept gives you unlimited undo/redo with little extra work.

The basic model looks like:

  gtk_text_insert(GtkText * widget, char * theText)
  {
    gtk_text_add_undo(widget, gtk_text_delete, startPos, endPos);
    // Deal with insertion
  }

  gtk_text_delete(GtkText * widget, int startPos, int endPos)
  {
    gtk_text_add_undo(widget, gtk_text_insert, startPos, theText);
    // Deal with deletion
  }

Of course, this is _much_ easier in a language other then C, where you
have closures, garbage collected strings, etc. Getting this technique
operating in Gtk is, unfortunately, left as an exercise for the reader. 

-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]