Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-04

How to find position in TMemo.lines

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jon Foster

I'm trying to determine where the which line in a TMemo the cursor is on. In Delphi I could use CaretPos. I didn't find anything in the documentation for TMemo that indicated there was any way to do this. Is there some way to determine the cursor position within the lines property of a TMemo?

THX - Jon

Jon Foster JF Possibilities, Inc. 541-410-2760 Making computers work for you!

Reply by email

Felipe Monteiro de Carvalho
to Jon Foster

You can submit a bug report asking for CaretPos to be implemented.

In delphi it's a public property declared like this:

property CaretPos: TPoint;

Which widgetset are you using?

Felipe Monteiro de Carvalho

Reply by email

Henry Vermaak
to Jon Foster: I'm trying to determine where the which line in a TMemo the cursor is on. In Delphi I…
Jon Foster wrote 6 lines
I'm trying to determine where the which line in a TMemo the cursor is on. In Delphi I could use CaretPos. I didn't find anything in the documentation for TMemo that indicated there was any way to do this. Is there some way to determine the cursor position within the lines property of a TMemo?

err, this is probably a hack, but you can use pos(lineending, memo.lines.text) in a loop to count how many newlines before you get to memo.selstart. then rposex(lineending, memo.lines.text, memo.selstart) to find how far you are in the line you are. works in gtk2, at least (can send code if i don't make sense :).

henry

Reply by email

Jon Foster
to Henry Vermaak
Henry Vermaak wrote 10 lines
On 16/04/2008, Jon Foster wrote: > I'm trying to determine where the which line in a TMemo the cursor is > on. [...] err, this is probably a hack, but you can use pos(lineending, memo.lines.text) in a loop to count how many newlines before you get to memo.selstart. then rposex(lineending, memo.lines.text, memo.selstart) to find how far you are in the line you are. works in gtk2, at least (can send code if i don't make sense :).

Make sense. It would be quicker to write a loop to scan the string counting lineendings rather than using all those "pos" calls. Eliminates the overhead of having to make those calls. Since there doesn't appear to be any known built in solution for this I think I'll do just that.

THX - Jon

Jon Foster JF Possibilities, Inc. 541-410-2760 Making computers work for you!

Reply by email

Jon Foster
to Felipe Monteiro de Carvalho: You can submit a bug report asking for CaretPos to be implemented. In delphi it's a…

I'm using the default GTK widgets.It would seem to me that the widget has to already be aware of this information. Is there some way to get it to give it up? I'm ignorant of the interactions between GTK and Pascal or even how GTK functions. It would take me considerable time to trace through the code to figure this out. If no one else knows a method to do this I think I'll go with Henry's idea.

THX - Jon

Felipe Monteiro de Carvalho wrote 9 lines
You can submit a bug report asking for CaretPos to be implemented. In delphi it's a public property declared like this: property CaretPos: TPoint; Which widgetset are you using?
Jon Foster JF Possibilities, Inc. 541-410-2760 Making computers work for you!

Reply by email