Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement an NSTextView that performs on-the-fly markup to RTF conversions
    text
    copied!<p>I'm trying to build an NSTextView that can take "marked up" input that is automatically translated into beautiful RTF-style text while the user types.</p> <p>The idea is to let the user enter text in "plain text" format, but to "beautify" it on the spot, e.g.</p> <pre><code>H1 A quick list: * first item * second item </code></pre> <p>would be translated into a first line with a header font, followed by a bulleted list.</p> <p>I have found plenty of potential ways of doing this, but the Text System is incredibly complicated (with reason) and I don't want to start "cooking my own" if there is already something suitable built-in. BTW I would be happy with a Snow Leopard only API.</p> <p>The first thing I thought of was "<strong>data detectors</strong>", but I can't find a public API for doing this.</p> <p>Having reached the end of the road with that, I turned to the new "<strong>Text Input Sources API</strong>". This does all kinds of things, but the "data-driven input methods" section of the WWDC 2006 presentation "Take Charge of the Text Input" seems interesting in my context. Beyond that single presentation slide however nothing seems to exist anywhere, so it's a bit of a dead end again.</p> <p>Finally, I had a look at the <strong>NSSpellChecker</strong> class which is also supposed to offer completion features and automatic corrections.. but I'm not sure how this could be re-purposed for my requirements either.</p> <p>At the moment, I'm tempted to just re-parse the entire NSTextStorage manually and make the changes myself when the user stops typing.. but I'm sure there are cleverer heads around this forum..</p> <p>Any advice or pointers in the right direction would be greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload