ctietze,
@ctietze@mastodon.social avatar

Hey TextKit aficionados @mattiem @krzyzanowskim :)

I'm at a point where I want to make writing structural transformations to Markdown documents easier.

I believe I can get the API of this screenshot to compile and then execute the steps on NSTextStorage, replacing a hideous procedural approach I wrote earlier this week.

Would an API like this be useful for your text editors?

Would an API similar to this with some changes be?

Not sure if open sourcing is worth it.

mattiem,
@mattiem@mastodon.social avatar

@ctietze @krzyzanowskim I’ve read it a few times. It does remind me of stuff I’ve had to do in the past. How does the selection stuff work at the storage level?

My own text mutation stuff is really complex. Supporting an arbitrary number of cursors is something I’m working towards, and that is a tough performance issue which requires a lot of special code in this kind of area…

ctietze,
@ctietze@mastodon.social avatar

@mattiem @krzyzanowskim Ah right, multiple cursors 🤔 That would suck.

At the moment, SelectLineRange with the token list as parameters would boil down to get the NSRange for all tokens in the list, then use NSString.lineRange to make sure I'm only operating on whole lines.

Deletions are applied from back to front and shrink the selection by the deleted character delta.

Insertion likewise increases the affectedLineRange.

Finally, the Select call places the cursor in 1 location.

mattiem,
@mattiem@mastodon.social avatar

@ctietze @krzyzanowskim I really do like the concept here, because stuff like this is really hard to get right and the code is usually gross.

Multiple cursors is hard, because there are pathological cases which make performance is really tricky. And I don’t know if it’s worth it for you, because I bet it would make your API much more complex for almost no benefit

ctietze,
@ctietze@mastodon.social avatar

@mattiem @krzyzanowskim I mean I would like to support multiple cursors eventually. But in the meantime, typing text that's worth keeping at all is a hard enough task :)

Also, Emacs didn't need multiple cursors thanks to Macros for decades, so maybe I can get by with macros instead :p

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • InstantRegret
  • GTA5RPClips
  • ethstaker
  • Youngstown
  • everett
  • slotface
  • osvaldo12
  • rosin
  • mdbf
  • kavyap
  • thenastyranch
  • ngwrru68w68
  • megavids
  • Durango
  • modclub
  • cubers
  • khanakhh
  • Leos
  • tacticalgear
  • cisconetworking
  • vwfavf
  • tester
  • anitta
  • normalnudes
  • provamag3
  • JUstTest
  • All magazines