Fwd: [PHP-GTK] Change the cursor position on a TextView/TextBuffer
| From: | Marc Quinton | Date: | Thu, 22 Feb 2007 09:49:18 +0000 |
| Subject: | Fwd: [PHP-GTK] Change the cursor position on a TextView/TextBuffer | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-7694@lists.php.net to get a copy of this message | ||
---------- Forwarded message ----------
From: Marc Quinton <mquinton@gmail.com>
Date: Feb 22, 2007 8:06 AM
Subject: Re: [PHP-GTK] Change the cursor position on a TextView/TextBuffer
To: Fernando Correa da Conceição <conceicao.fernando@gmail.com>
On 2/22/07, Fernando Correa da Conceição <conceicao.fernando@gmail.com> wrote:
I need do some task on a textbuffer, like change the cursor forward and back, get the char at the current cursor position, select and replace some piece of text. Someone have a example on this thing or know how i can do it?* for cursor position, get an iter : $iter = $this->buffer->get_iter_at_mark($this->buffer->get_mark('insert')); (here buffer is a GtkTextBuffer or GtkTextView::get_buffer()) * moving cursor should be a forward, backward method in Textview, but can't see anyone. Perhaps you could move a special mark named 'insert'. * you don't need to move cursor to select some arbitrary text in TextBuffer. So perhaps you don't need to move cursor. * text modification in usualy made with (beetween) 2 GtkTextIter : - iters can be returned from selection, - can be computed depending on application context. - some method are available for this. after that, have a look in GtktextBuffer : delete, insert ... -have a look a kksou site for some examples. - I have uploaded a simple example with GtkTextedit here with a screen shot. Don't know exactly what it contains ands perhaps some optimisations may be needed. http://quinton.free.fr/php/gtk/examples/ Now I al working on a Wysiwyg editor with GtkTextView. Actual source code is also available at the same location.