Re: [Lazarus] How to find position in TMemo.lines
Henry Vermaak wrote: On 16/04/2008, Jon Foster [EMAIL PROTECTED] 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. [EMAIL PROTECTED] 541-410-2760 Making computers work for you! ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to find position in TMemo.lines
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: 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. [EMAIL PROTECTED] 541-410-2760 Making computers work for you! ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to find position in TMemo.lines
Could you post a bug report? http://wiki.lazarus.freepascal.org/How_do_I_create_a_bug_report -- Felipe Monteiro de Carvalho ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to find position in TMemo.lines
On 16/04/2008, Jon Foster [EMAIL PROTECTED] wrote: 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 ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus