Path: ...!nx01.iad01.newshosting.com!newshosting.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newsfeed2.telusplanet.net!newsfeed.telus.net!xmission!nnrp.xmission!not-for-mail From: George Peter Staplin Newsgroups: comp.lang.tcl Subject: Re: embed vi editor in tk application Date: Tue, 3 Jun 2008 19:49:05 +0000 (UTC) Organization: nil Lines: 67 Message-ID: References: <2jggh5-o2j.ln1@klein-habertwedt.de> NNTP-Posting-Host: georgeps.dsl.xmission.com X-Trace: news.xmission.com 1212522545 22315 166.70.196.201 (3 Jun 2008 19:49:05 GMT) X-Complaints-To: abuse@xmission.com NNTP-Posting-Date: Tue, 3 Jun 2008 19:49:05 +0000 (UTC) User-Agent: slrn/0.9.8.1pl1 (Debian) Bytes: 3071 Uwe Klein wrote: > Bryan Oakley wrote: >> amitmjoshi@gmail.com wrote: >> >>> How can embed the vi editor in tk application? >>> Any tk widget available for this? >>> Currently i am using scrolledtext widget to show and edit the file. >>> I am used to with vi and want to embed the same in this application. >>> Can somebody please help me out. >>> >>> thanks >>> Amit M Joshi >> >> >> The problem is, vi expects a terminal with curses support and Tk has no > ........................... >> the text widget. >> >> >> >> >> > OK, try this: > > # 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