thanks
Amit M Joshi
The problem is, vi expects a terminal with curses support and Tk has no
widget that meets that criteria. It's not impossible, though. If you
can use the expect extension, it includes demo code that emulates a
terminal in which vi can run and which you can embed in a program (last
I checked anyway, which admittedly was a few years ago).
With a lot of work you might be able to make it happen in pure Tcl/Tk
but I don't think anyone has ever needed it badly enough to do it.
Probably an easier task would be to create a set of vi-like bindings to
the text widget.
# create a frame configure to embed another app
frame .f -container true
pack .f -expand 1 -fill both
# expr used to a dezimal window ID
# as winfo returns a string with the hexnumber
set wID [ expr [ winfo id .f ] ]
# the content you want to work on
set file /etc/hosts
# exec xterm with the "-into" option and have
# it run vi with your file in background:
exec xterm -into $wID -e vi $file &
# exercise left: how to notice vi has ended.
uwe
As the author of the -into patch to xterm (years ago), I think I should
point out that the example isn't ideal, because it won't resize with the
parent. However it's possible to make it do so by selecting the
SubstructureRedirectMask so that everytime the xterm resizes, you get a
ConfigureRequest. That's originally how I used xterm as a widget.
The original project I wrote that used the embedded xterm is no longer
maintained. I do however have some more recent code that demonstrates
the sequence with ntk in a prototype:
http://code.google.com/p/megapkg/source/browse/trunk/tclsrc/xterm_proto.tcl
Note: I decided I may need the ability to render offscreen with the
XComposite, and XDamage extensions (at the least), so that it would work
with NexTk and overlapped windows.
I'm willing to write an xterm widget that embeds xterm as a Tk widget,
but I don't always have a lot of time and/or motivation. I'll see if I
can piece some code together this week though.
The Whim desktop could use a Whimterm or something like that.
George
http://gpl.internetconnection.net/vi/
You wouldn't think anyone would need vi-in-javascript badly enough to do
it either. :-) If there's a javascript interpreter in Tcl, you might be
able to get there from here, depending on how great your need is.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
> As the author of the -into patch to xterm (years ago), I think I should
> point out that the example isn't ideal, because it won't resize with the
> parent. However it's possible to make it do so by selecting the
> SubstructureRedirectMask so that everytime the xterm resizes, you get a
> ConfigureRequest. That's originally how I used xterm as a widget.
Facinating.
uwe ;-)
and thanks for this information.
I just pieced this together with some diddling ( I knew about
-container and -into ) but had only used container stuff via
blt.
Tk's text widget is appropriate for any text manipulation. Melissa
Schrumpf offers vi-command implementations in pure tcl as part of her
code-editor on http://www.geocities.com/m_schrumpf/tcl/index.html
roland frank
> Tk's text widget is appropriate for any text manipulation. Melissa
> Schrumpf offers vi-command implementations in pure tcl as part of her
> code-editor on http://www.geocities.com/m_schrumpf/tcl/index.html
It's a pretty sad commentary when other people can find your website
more easily than you can find it yourself.
--
MKS