[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-gtk-general
Subject:    Fwd: [PHP-GTK] Change the cursor position on a TextView/TextBuffer
From:       "Marc Quinton" <mquinton () gmail ! com>
Date:       2007-02-22 9:49:18
Message-ID: 69ef070e0702220149r2bd3f03aoc91a8eab0cf905b4 () mail ! gmail ! com
[Download RAW message or body]

---------- 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.

-- 
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic