Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 94969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:35:05+00:00 2026-05-10T23:35:05+00:00

I am using the code I posted as an answer to this question to

  • 0

I am using the code I posted as an answer to this question to display hidden characters in an NSTextView as bullets.

I am coloring the bullets gray with the addTemporaryAttributes:forCharacterRange: method of NSLayoutManager. Each range is of length 1 and colors a single bullet. (Most of the same text I am using has relatively few adjacent hidden characters, although this is an optimization I am planning to make in the future.)

This change has many adverse effects. Scrolling the text view becomes slow and jerky, especially for text with many hidden characters. How can I color parts of the text without incurring an unacceptable performance hit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:35:06+00:00Added an answer on May 10, 2026 at 11:35 pm

    The reason the biggest hit is coming when you scroll is that, every time the scrollview scrolls, it redraws the view and, by extension, recolorizes your entire document. Since, during a single scroll operation, the scrollview is scrolling by several pixels, just scrolling n pixels up or down is going to recolorize the entire document n times!

    I suggest making sure you are only colorizing text that’s on-screen. The last thing you ever want to be doing is adding attributes to characters that have been scrolled out of view, since it’s essentially wasted cycles at that point.

    You can get the range of visible text from the text view:

    - (NSRange)visibleRange {     NSRect visibleRect = [textView visibleRect];      NSRange glyphVisibleRange = [[textView layoutManager] glyphRangeForBoundingRect:visibleRect inTextContainer:[textView textContainer]];     NSRange charVisibleRange = [[textView layoutManager] characterRangeForGlyphRange:glyphVisibleRange  actualGlyphRange:nil];     return charVisibleRange; } 

    So, when you do your colorizing, only colorize glyphs that fall within this range. That should improve your scrolling performance by several orders of magnitude.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 182k
  • Answers 182k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The difference between private, protected and public is pretty straightforward:… May 12, 2026 at 4:22 pm
  • Editorial Team
    Editorial Team added an answer SHOW CREATE TABLE works even if there are no rows.… May 12, 2026 at 4:22 pm
  • Editorial Team
    Editorial Team added an answer Can't you just do this? ordered.colnames <- ordered.colnames[ordered.colnames %in% colnames(dataset)] May 12, 2026 at 4:22 pm

Related Questions

I am trying to open an InfoPath 2007 file programmatically from a Windows service,
I try to implement ASP.NET Authentication and Authorization on top of our existing database.
I am a real noob when it comes to javascript/ajax, so any help will
important ; I'm really looking for a StructureMap answer here. Please don't say how

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.