• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextView scroll to attribute/bookmark?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView scroll to attribute/bookmark?


  • Subject: Re: NSTextView scroll to attribute/bookmark?
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 24 Aug 2014 02:00:01 -0500

On Aug 24, 2014, at 1:05 AM, Samuel Williams <email@hidden> wrote:

> I'm generating a NSAttributedString which looks like the following:
>
> function_name_1
> disassembled code output
> disassembled code output
> disassembled code output
> function_name_2
> disassembled code output
> disassembled code output
> function_name_3
> disassembled code output
> disassembled code output
> disassembled code output
> disassembled code output
>
> I am assigning a special attribute to the function_name_x headers. I want
> to have a drop down box, not unlike the Xcode editor, where you can see a
> list of functions and jump to them quickly.
>
> What is the best way to achieve this functionality?
>
> 1/ Somehow scan through the list of attributes and find the one which
> should be focused, calling scroll to range
>
> 2/ Separate data structure

Both, I think.  You'll almost certainly want to keep an index for quickly jumping.  To build the index, you would initially scan the attributed string.  (Or, perhaps, you would build the index at the time you initially parse the text to figure out where to apply your attributes.)  After that, you would probably observe the notifications from the text storage to update the index.

> Thanks for any feedback. If possible, if you know some specific functions I
> should use please suggest them (e.g. finding all ranges for a given
> attribute on NSAttributedString??).

That one is easy: -[NSAttributedString enumerateAttribute:inRange:options:usingBlock:].

Regards,
Ken


_______________________________________________

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


References: 
 >NSTextView scroll to attribute/bookmark? (From: Samuel Williams <email@hidden>)

  • Prev by Date: NSTextView scroll to attribute/bookmark?
  • Next by Date: Re: Which NSWindow methods have asynchronous operation?
  • Previous by thread: NSTextView scroll to attribute/bookmark?
  • Next by thread: How to synchronize my MacOS-X application with Core-Data automatic Undo management?
  • Index(es):
    • Date
    • Thread