Re: texbuffer

Espen S Johnsen <[email protected]> 25 Aug 2006 14:37:49 +0200
Newsgroups gmane.lisp.clg.devel
Message-ID <[email protected]>
[email protected] writes:

> I have a little problem with the textbuffer object: I want to get the
> cursor-position propertie of a textbuffer but i dont find a slot or a
> method for it.

The cursor position in a text buffer is represented by a mark called
"insert". To retrieve this mark you could use gtk:text-buffer-get-insert
(or the more general text-buffer-get-mark). But the mark it self doesn't
contain the position, so you need to get an iterator for it. To get that
you could use text-buffer-get-iter-at-insert.

If you want to know the position when the cursor moves, you could
connect to the signal "mark-set" (I found an error in the definition of
tree-mark causing a memory fault when accessing the name slot, so you
need to do an update from CVS to try this):

(signal-connect buffer 'mark-set
 #'(lambda (iter mark)
     (when (and (slot-boundp mark 'name) (string= (text-mark-name mark) "insert"))
       (do-something-with-current-position iter))))

Unfortunately the "insert" mark doesn't move when text is inserted so
you may also have to connect to "insert-text":

(signal-connect buffer 'insert-text
 #'(lambda (iter &rest rest)
     (declare (ignore rest))
     (do-something-with-current-position iter))
 :after t)

> P.S. We are going to finish soon the OM porting on Linux. OM is a visual
> interface to CLOS specialized on music composition but also in teaching
> programming language and in particular Lisp. You can visit the page
> http://recherche.ircam.fr/equipes/repmus/OpenMusic/
> for more information.

Sounds interesting...

-- 
Espen

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642