TextCtrl, how to get the range of the line where the caret is ?

hello,

I want to highlight the selected line in a TextCtrl.
I can find the currentposition with InsertionPoint

but how do I find the begin and end of the line ?

thanks,
Stef Mientki

http://docs.wxwidgets.org/stable/wx_wxtextctrl.html#wxtextctrl

PositionToXY will give you the line number Y and use that with
GetLineLength and step through the lines up to the one you want to
highlight? Or go backwards and forwards searching GetValue() for \n
which will tell you the start and end of your current line.

Mark

···

On Oct 28, 4:07 am, Stef Mientki <stef.mien...@gmail.com> wrote:

hello,

I want to highlight the selected line in a TextCtrl.
I can find the currentposition with InsertionPoint

but how do I find the begin and end of the line ?

thanks,
Stef Mientki

thanks Mark,
I hoped there was a more elegant solution.

cheers,
Stef

···

On 28-10-2010 09:51, Mark wrote:

http://docs.wxwidgets.org/stable/wx_wxtextctrl.html#wxtextctrl

PositionToXY will give you the line number Y and use that with
GetLineLength and step through the lines up to the one you want to
highlight? Or go backwards and forwards searching GetValue() for \n
which will tell you the start and end of your current line.

Mark

On Oct 28, 4:07 am, Stef Mientki <stef.mien...@gmail.com> wrote:

hello,

I want to highlight the selected line in a TextCtrl.
I can find the currentposition with InsertionPoint

but how do I find the begin and end of the line ?

thanks,
Stef Mientki

Hi,

···

On Thu, Oct 28, 2010 at 2:18 PM, Stef Mientki <stef.mientki@gmail.com> wrote:

thanks Mark,
I hoped there was a more elegant solution.

I would suggest using the StyledTextCtrl instead of the regular
TextCtrl if you need to do any kind of manipulation like this. It has
a much better api to accommodate such tasks. In fact it even has a
feature built into it to highlight the line the the caret is on.

Cody

Looking for \n's is a few lines of code, no big deal I do something
similar.

Does StyledTextCtrl highlight the whole line as in the width of the
ctrl not just behind the text? I may need that my next project.

Mark

···

On Oct 29, 3:21 am, Cody Precord <codyprec...@gmail.com> wrote:

Hi,

On Thu, Oct 28, 2010 at 2:18 PM, Stef Mientki <stef.mien...@gmail.com> wrote:
> thanks Mark,
> I hoped there was a more elegant solution.

I would suggest using the StyledTextCtrl instead of the regular
TextCtrl if you need to do any kind of manipulation like this. It has
a much better api to accommodate such tasks. In fact it even has a
feature built into it to highlight the line the the caret is on.

Cody

Hi,

···

On Thu, Oct 28, 2010 at 3:28 PM, Mark <markreed99@gmail.com> wrote:

Looking for \n's is a few lines of code, no big deal I do something
similar.

Does StyledTextCtrl highlight the whole line as in the width of the
ctrl not just behind the text? I may need that my next project.

Yes, it highlights the whole width of the control

see: StyledTextCtrl.SetCaretLineVisible(bool)
see: StyledTextCtrl.SetCaretLineBack(Colour)

Cody

thanks Cody,
I might try that.

One thing I'm always afraid of,
isn't styledtextctrl musch heavier / larger than the standard TextCtrl ?
( I already have 5 STC's in this form)

cheers,
Stef

···

On 28-10-2010 22:35, Cody Precord wrote:

Hi,

On Thu, Oct 28, 2010 at 3:28 PM, Mark <markreed99@gmail.com> wrote:

Looking for \n's is a few lines of code, no big deal I do something
similar.

Does StyledTextCtrl highlight the whole line as in the width of the
ctrl not just behind the text? I may need that my next project.

Yes, it highlights the whole width of the control

see: StyledTextCtrl.SetCaretLineVisible(bool)
see: StyledTextCtrl.SetCaretLineBack(Colour)

Cody

I've you've already got the STC module loaded I wouldn't expect much additional overhead for using another one, unless the documents are real big of course.

···

On 10/29/10 2:17 PM, Stef Mientki wrote:

On 28-10-2010 22:35, Cody Precord wrote:

Hi,

On Thu, Oct 28, 2010 at 3:28 PM, Mark<markreed99@gmail.com> wrote:

Looking for \n's is a few lines of code, no big deal I do something
similar.

Does StyledTextCtrl highlight the whole line as in the width of the
ctrl not just behind the text? I may need that my next project.

Yes, it highlights the whole width of the control

see: StyledTextCtrl.SetCaretLineVisible(bool)
see: StyledTextCtrl.SetCaretLineBack(Colour)

Cody

thanks Cody,
I might try that.

One thing I'm always afraid of,
isn't styledtextctrl musch heavier / larger than the standard TextCtrl ?
( I already have 5 STC's in this form)

--
Robin Dunn
Software Craftsman