Mutating text by cursor?


Hi everyone! My name is Kyle, and I’m new to the fourms.

I’ve recently started a project for atom here, and have hit a few brick walls. Some of this could be due to my lack of understanding of coffee script and you should feel free to correct me if I’m simply under-educated on the subject.

That being said, here is my problem. I want to create multiple cursors on the text editor, and feed them text individually. Is there a way to do this, or am I simply wasting my time?


It might not be a waste of time, but it’s also not going to be a piece of cake. Atom’s cursor API is designed with a single user in mind, and multiple cursors are mostly used to write the same string of text in multiple places at once.

One thing you could do is watch the collaboration buffer with editor.buffer.onDidStopChanging(), create a checkpoint there, and then send the results of getChangesSinceCheckpoint() across to the linked Atom instances.

For the cursors, you could mimic a cursor with a DisplayMarker (cursors are one such type of marker that happen to have a bunch of functions attached to them). A gutter could also be useful to indicate lines where another user is working.

You would also have to create logic for detecting and prioritizing changes that conflict with each other.


Thanks for your reply. I’ll get on that :slight_smile: