Re: How to highlight the current line in NSTextView?
Re: How to highlight the current line in NSTextView?
- Subject: Re: How to highlight the current line in NSTextView?
- From: Nick <email@hidden>
- Date: Sun, 06 Nov 2011 17:39:17 +0200
Keary, Douglas
Could you please give me a hint what methods to search for?
Basically I need an NSRange of the current line (or that part of it, whereb
the cursor is in, if the line is word-wrapped). Then I'll simply change
this substring's attributes.
Should i find the current text cursor's position (location) in text, and
keep invoking locationForGlyphAtIndex for every previous symbol to this
cursor location, up till I get the smallest value?
What's the right way here?
2011/11/4 Keary Suska <email@hidden>
> On Nov 4, 2011, at 7:19 AM, Nick wrote:
>
> > Hello
> > Basically the question is about getting the NSRange of the line of
> > NSTextView where the text input cursor is currently in.
> > Word wraps are considered as legal 'new lines' - only one line should
> > actually be highlighted.
> >
> > How could I do this (get an NSRange of a single line)?
>
> Cocoa's text handling system is a bit complex (you should read the
> text-handling guide) but it shouldn't be too difficult. The object you
> probably need to talk to is the appropriate NSLayoutManager (probably just
> one) which belongs to the NSTextStorage of the NSTextView (whew!). That
> should get you started.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden