Collaborative Text Editor

John J. Lee jjl at
Thu Jul 15 00:21:38 CEST 2004

Ed Suominen <ed-no at> writes:

> I'm thinking of implementing a real-time collaborative text editor in Python
> using Twisted.

Cool!  I've wondered about this in the past.  Not sure how useful it
would turn out to be, but would be fun to find out.

> An initial plan is to use a Twisted PB server daemon that
> accepts user:password:file connections from text editor clients to make
> changes to a specified file on the server, and have the text editor clients
> update their local copies of the file based on local user input or input
> entered from other users, relayed via the server.

I wonder if client-server is the way to go here.  On the surface, P2P
seems more natural fit.

The way I've always imagined it working is as follows.  I'm sure
experimentation is the way to find out what works, though, so Twisted
certainly sounds like a great idea.

- At any time, exactly one person has control.

- The only person able to move the cursor and edit text is the one
  with control.

- Anybody may flag up that they want control.  Everybody is notified
  when this happens.

- Control passes from one person to another by means of the person
  with control yielding it to a specified person.

If I were doing this (which I'm not, of course), I would go out of my
way to meet the following goals:

- Critical: the way should be left open to implementing the protocol
  on any decent editor.

- Important: the protocol should be efficient, so that latency is
  minimised.  I imagine this requires pushing changes out rather than
  polling to check for changes, and having reasonably high-level
  primitive operations -- maybe insert, cut, paste, move, maybe
  rectangle-wise cut/paste operations too, maybe indent / dedent, plus
  operations on a circular clipboard stack (strange image ;-).

> Jabber compatibility would be nice, as would color-coding of different
> users' text, etc.

Jabber certainly seems an entirely secondary thing: if it helps meet
your goals, great.  If not, who cares?

I don't see how colour coding would work, other than to have text that
has been entered since the last switch of control coloured

> I'd appreciate pointers to any existing, simple Python-based text editors
> suitable for being adapted to this purpose. "Suitable" means under an
> OSI-approved license and written cleanly and modularly to facilitate
> incorporation into another project.

I know vim is Python-scriptable, and has a fairly wide user base
(especially if you count).

For a number of reasons I've been meaning to learn vi properly for
ages, but find it very hard to kick my emacs habit...

have-the-appropriate-amount-of-fun-ly y'rs


More information about the Python-list mailing list