Hi everyone,I recetly wrote a program that used the LibEditorPlus libary from Progi1984,and used some of the functions in my program,but would like to know if there is some way of implimenting some of the same functions in PB 4.
The functions I am looking for are things like.
Editor_locate(gadget,x,y) ,place caret somewhere within editor.
Editor_CursorX(gadget) ,return the carets X position in chars,not pixels
Editor_CursorY(gadget) ,return the carets Y position in chars,not pixels.
Editor_Select(gadget, LStart.l, CStart.l, LEnd.l, CEnd.l) select a section of the editor.
I`ve got cut,copy,paste ok,but am a bit lost with the rest.
Please try to keep it simple Im still learning.
I would have liked to use somthing like scintilla but don`t know how and it looks a bit complicated,as I would have liked it to find and format some keywords.
Any idea why these sort of functions are not in PB already?.
Thanks.
Editor Gadget functions.Help needed.
Editor Gadget functions.Help needed.
Last edited by ferty on Thu Jun 15, 2006 11:11 am, edited 1 time in total.
They Say You Never Stop Learning,Well I Can`t Seem To Start. 

- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Sorry I'm in a rush I have to go out but I whacked something together quickly, see if it is of any help:
Run it as is to see cursor pos set @ get char coords, then uncomment the last SendMessage to see targeted selection by line and charpos.
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(0, a, "Line number"+Str(a))
Next
SetFocus_(GadgetID(0))
charposinalltext=SendMessage_(GadgetID(0),#EM_SETSEL,32,32) ;set cursor at 32nd char in text
Debug charposinalltext
currentline=SendMessage_(GadgetID(0),#EM_LINEFROMCHAR,-1,0) ;get the current (0-based) line#
Debug currentline
charposonline=charposinalltext-SendMessage_(GadgetID(0),#EM_LINEINDEX,2,0) ;get the current charpos on it
Debug charposonline
startselpos = SendMessage_(GadgetID(0),#EM_LINEINDEX,3,0)+ 5 ;we want to start at char 5 of line 3
startselend = startselpos+6 ; we're selecting six characters
;SendMessage_(GadgetID(0),#EM_SETSEL, startselpos,startselend)
; To target a line and offset for setting the cursor without selecting,
; do as above but use the same pos for start and end.
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
BERESHEIT
Hi,thanks for your reply.
With regard to selecting a section of text in the editor gadget,how do you select a whole single line,somewhere, no matter what it`s length?.
----------------------------------
Such as
linetoselect=36
Editor_select(#editor,linetoselect)
Return a string holding line #36 from editor.
----------------------------------
And to select a number of lines,no matter there length.
Such as
linefrom=10
lineto=14
Editor_Select(#editor,linefrom,lineto)
Return a string or somthing holding lines 10 to 14.
----------------------------------
And will these work no matter what the text file size,( >64k.)
Thanks.
With regard to selecting a section of text in the editor gadget,how do you select a whole single line,somewhere, no matter what it`s length?.
----------------------------------
Such as
linetoselect=36
Editor_select(#editor,linetoselect)
Return a string holding line #36 from editor.
----------------------------------
And to select a number of lines,no matter there length.
Such as
linefrom=10
lineto=14
Editor_Select(#editor,linefrom,lineto)
Return a string or somthing holding lines 10 to 14.
----------------------------------
And will these work no matter what the text file size,( >64k.)
Thanks.
Last edited by ferty on Thu Jun 15, 2006 11:11 am, edited 1 time in total.
They Say You Never Stop Learning,Well I Can`t Seem To Start. 

Hi,Progi1984,I used your lib on 3.94 and liked these ease of use(I don`t know anything about the 32 API).
Is it working on PB 4,and if not do you think it would be long.
And thanks for a great lib.

Oh,And Any Chance Of some Docs in english?
I Don`t know Any french,Heck I only just know english.
Is it working on PB 4,and if not do you think it would be long.
And thanks for a great lib.

Oh,And Any Chance Of some Docs in english?
I Don`t know Any french,Heck I only just know english.

They Say You Never Stop Learning,Well I Can`t Seem To Start. 

Documentation Question
Where do you find documentation to explain the code that you used in the above example. Lines such as:
charposinalltext=SendMessage_(GadgetID(0),#EM_SETSEL,3,7)
I can find the constant #EM_SETSEL listed but not defined. I can't find any documentation that says what the collection of elements within the () does. I have downloaded the API-Guide, but no help.
Would appreciate your help, I'm a "NewBie"
charposinalltext=SendMessage_(GadgetID(0),#EM_SETSEL,3,7)
I can find the constant #EM_SETSEL listed but not defined. I can't find any documentation that says what the collection of elements within the () does. I have downloaded the API-Guide, but no help.
Would appreciate your help, I'm a "NewBie"
Re: Documentation Question
Take a look at this thread:laborde wrote:Where do you find documentation to explain the code that you used in the above example. Lines such as:
charposinalltext=SendMessage_(GadgetID(0),#EM_SETSEL,3,7)
I can find the constant #EM_SETSEL listed but not defined. I can't find any documentation that says what the collection of elements within the () does. I have downloaded the API-Guide, but no help.
Would appreciate your help, I'm a "NewBie"
http://www.purebasic.fr/english/viewtopic.php?t=10046
Download and install the MS Win32® API Reference.

- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
This should give an idea how to manage text selections/copies by line. For more lines just use different parameters for the start and end selection indexes.
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(0, a, "The fact of the matter is this: It's Line number "+Str(a))
Next
SetFocus_(GadgetID(0))
Mystring.s=Space(255)
SendMessage_(GadgetID(0),#EM_GETLINE,1,@Mystring) ; How to get a line quickly without selecting it
Debug Mystring
startselpos = SendMessage_(GadgetID(0),#EM_LINEINDEX,3,0) ; How to select a line first and copy it
startselend = SendMessage_(GadgetID(0),#EM_LINEINDEX,4,0) ; First define start and end pos for selection
SendMessage_(GadgetID(0),#EM_SETSEL, startselpos,startselend) ; Invoke the selection
SendMessage_(GadgetID(0),#EM_GETSELTEXT, 0,@Mystring) ; Copy the selected text to a string
Debug Mystring
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
BERESHEIT