Page 1 of 1

Cursor in an editor gadget

Posted: Thu Nov 08, 2007 4:07 am
by Armoured
Hi :)
Is possible to read and to set the position of the cursor in one editor gadget?
If yes how?





Thanks

Posted: Thu Nov 08, 2007 9:14 am
by blueznl
Reply deleted. Mine was Windows based :oops:

Posted: Thu Nov 08, 2007 9:26 am
by Armoured
blueznl wrote:Reply deleted. Mine was Windows based :oops:
;)

To set the cursor position for Linux I have found this: http://www.purebasic.fr/english/viewtop ... ght=cursor

But to read the cursor position? :?

Posted: Thu Nov 08, 2007 5:01 pm
by dhouston
Would you mind posting a working example? I tried the code in that post and it does not work for me.

Code: Select all

  IO = EditorGadget(#PB_Any, 6, 207, 540, 260 , #PB_Editor_ReadOnly)
   GadgetToolTip(IO, "Input/Output Window")
   ;remove from compiled version
   For k=0 To 50
     AddGadgetItem(IO, -1, "15:20:36 <T1 This is only an example n° "+Str(k))
   Next
  ;'does not work
  GadgetID = GadgetID(IO)
  length = gtk_text_get_length_(GadgetID)  ;returns 0
  gtk_editable_set_position_(GadgetID, length)  ;does nothing

Posted: Thu Nov 08, 2007 8:19 pm
by Armoured
Hi
I'm sorry but my link is wrong for this type of gadget.
I think the solution is to use "gtk_text_buffer_place_cursor" but I need an example of code.

Posted: Thu Nov 08, 2007 11:13 pm
by Armoured
I need help with this:

Code: Select all

     buffer = gtk_text_view_get_buffer_(GadgetID(#Gadget_Form1_Editor1))
     gtk_text_buffer_place_cursor_(buffer,?)
what is the second parameter of the "gtk_text_buffer_place_cursor"? :?

Posted: Fri Nov 09, 2007 6:09 pm
by hardfalcon
gtk_editable_get_position_() :?:

Posted: Sat Nov 10, 2007 1:52 pm
by dhouston
Armoured wrote:what is the second parameter of the "gtk_text_buffer_place_cursor"? :?
It's a pointer so it should be the sum of the buffer pointer plus the length of the text but I do not know how to get the length of the text in the buffer.