EditorGadget scrolling

Just starting out? Need help? Post your questions and find answers here.
User avatar
kenmo
Addict
Addict
Posts: 2043
Joined: Tue Dec 23, 2003 3:54 am

EditorGadget scrolling

Post by kenmo »

Hey, I've got a couple questions on editorgadgets, both concerning API (I'm assuming).

First, how do I enable word-wrap, and second, how can I automatically scroll it to the bottom when a line is added (like a ENSUREVISIBLE message for editorgadgets...)?

Thanks in advance.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: EditorGadget scrolling

Post by ts-soft »

kenmo wrote: First, how do I enable word-wrap

Code: Select all

SendMessage_(GadgetID(Gadget),#EM_SETTARGETDEVICE, #Null, Flag); Flag: 0 = WordWrap or 1 = no WordWrap
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
kenmo
Addict
Addict
Posts: 2043
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Wow, fast and perfect answer! Thanks, man.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

The following will scroll the editor gadget in order to show the last line in the control. However, if there are more lines than are visible, then it scrolls until the final line is at the very top of the client area.

The only way I can find of scrolling to put the last line at the bottom of the visible area involves some dirty scumy hit-testing in order to determine how many rows are visible within the control. I guess I shouldn't be surprised that I can't find an easy way of doing this, considering all the different font sizes which are possible etc.

Code: Select all

topvisible=sendmessage_(gadgetid(0), #EM_GETFIRSTVISIBLELINE,0,0)
sendmessage_(gadgetid(0), #EM_LINESCROLL, 0, countgadgetitems(0)-topvisible-1)
I may look like a mule, but I'm not a complete ass.
User avatar
kenmo
Addict
Addict
Posts: 2043
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

srod wrote:The only way I can find of scrolling to put the last line at the bottom of the visible area involves some dirty scumy hit-testing in order to determine how many rows are visible within the control. I guess I shouldn't be surprised that I can't find an easy way of doing this, considering all the different font sizes which are possible etc.
Actually that's specifically what I'm looking for... I assumed there WAS an easy way to do it. In any application's editor window, if you press CTRL+End it takes you to the bottom, but what message is performing that?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Doh!

How about this:

Code: Select all

SendMessage_(gadgetid(0), #EM_SETSEL,-1,-1)
Seems to do the job!
I may look like a mule, but I'm not a complete ass.
User avatar
kenmo
Addict
Addict
Posts: 2043
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Haha, wow, I was not aware of that simple trick. Thank you.
Post Reply