Emulating editors in Tk

2 views
Skip to first unread message

steve bold

unread,
Nov 15, 2002, 3:12:03 AM11/15/02
to
I was asked recently whether it is possible to emulate vi and emacs in a
text editor
based on the Tk text widget. The answer is of course that, it depends
exactly
which keystrokes you want to emulate and how exactly the behaviour must
match
the original editor. However, to some extent it can certainly be done. I was
wondering though whether anyone has implemented such a thing already. A
quick
google search didn't locate anything.

Thanks,
Steve.


Bryan Oakley

unread,
Nov 15, 2002, 11:09:47 AM11/15/02
to
The tk text widget already has emacs-like bindings for navigation
(control-n, control-p, etc) for which I am eternally grateful. But
there's no M-x equivalent to execute arbitrary commands. 'twould be cool
if there was.

In my mind's eye, vi emulation should be fairly easy to write, and I've
been tempted to do that on several occassions. The biggest hurdle is
just the amount of grunt work involved -- redefining all key bindings to
whatever makes sense for vi and re-implementing the most common
commands. Managing the insert-vs-command mode seems trivial -- just
define bindtags for each mode, set appropriate bindings on those tags
(rather than on Text or on the widget itself), and the swap the bindtags
whenever the user presses <esc>.

For a long time now I've wanted to write a megawidget that lets you
toggle between emacs-like behavior and vi-like behavior. That should
cover about 90% of the world's population of geeks. Alas, it's way down
on my priority list. I think it's doable, but would likely take several
days of coding.

art morel

unread,
Nov 19, 2002, 10:18:07 AM11/19/02
to
Bryan Oakley <br...@bitmover.com> wrote in message news:<f%8B9.1468$nr.667...@newssvr12.news.prodigy.com>...


How about trying Peter DeJijk's interface SW and just write the spec
and get others to do the coding? Here is some comments on his SW:
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=3dd53009%40news.uia.ac.be&prev=/groups%3Fdq%3D%26num%3D25%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.tcl%26start%3D50

thanks,
art

Reply all
Reply to author
Forward
0 new messages