Display hidden characters in NSTextView

前端 未结 6 1581
孤城傲影
孤城傲影 2020-12-15 01:14

I am writing a text editor for Mac OS X. I need to display hidden characters in an NSTextView (such as spaces, tabs, and special characters). I have spent a lot of time se

6条回答
  •  余生分开走
    2020-12-15 01:48

    Have a look at the NSLayoutManager class. Your NSTextView will have a layout manager associated with it, and the layout manager is responsible for associating a character (space, tab, etc.) with a glyph (the image of that character drawn on the screen).

    In your case, you would probably be most interested in the replaceGlyphAtIndex:withGlyph: method, which would allow you to replace individual glyphs.

提交回复
热议问题