Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A widget for the user's editor of choice

16 views
Skip to first unread message

Lan

unread,
Jun 28, 2007, 11:36:26 PM6/28/07
to
Some Linux friends were bemoaning all the apps that have their own
editors. Why can't you just tell the app which editor you prefer (as,
for example, one can specify vim in mutt)? There should be a simple,
direct way to do this in Tcl.

It seems Tk should allow us to put up a widget, spawn a CLI shell
inside it, and invoke an editor. I poked around on the wiki and there
are plenty of small editors, but not what I'm looking for.

TIA,

Jan Kandziora

unread,
Jun 29, 2007, 5:33:26 AM6/29/07
to
Lan schrieb:

> Some Linux friends were bemoaning all the apps that have their own
> editors. Why can't you just tell the app which editor you prefer (as,
> for example, one can specify vim in mutt)? There should be a simple,
> direct way to do this in Tcl.
>
It *should* work like this:

package require Tk
frame .f -container yes
pack .f -fill both -expand yes
exec xterm -into [ winfo id .f ] -e $env(EDITOR) &

However, the xterm is not reparented into the frame on my machine. Does
anyone know what I left out?

Kind regards

Jan

Jan Kandziora

unread,
Jun 29, 2007, 5:43:17 AM6/29/07
to
Jan Kandziora schrieb:

> It *should* work like this:
>
> package require Tk
> frame .f -container yes
> pack .f -fill both -expand yes
> exec xterm -into [ winfo id .f ] -e $env(EDITOR) &
>
BTW: There are other programs where reparenting works fine for me, like
mplayer:

exec mplayer -vo x11 -wid [ winfo id .f ] FILENAME &

Kind regards

Jan1

Larry W. Virden

unread,
Jun 29, 2007, 8:57:09 AM6/29/07
to
On Jun 29, 5:33 am, Jan Kandziora <j...@gmx.de> wrote:

>
> However, the xterm is not reparented into the frame on my machine. Does
> anyone know what I left out?


In my case, when I type the commands you list, I end up with this
(sparc solaris):

% exec xterm -into [winfo id .f] -e nvi &
10333
% xterm: bad command line option "-into"

usage: xterm [-help] [-display displayname] [-geometry geom] [-/+rv]
[-bg color] [-fg color] [-bd color] [-bw number] [-fn fontset or
font name]
[-fb fontset or font name] [-iconic] [-name string] [-title
string]
[-xrm resourcestring] [-/+132] [-/+ah] [-/+ai] [-fi fontname or
fontset]
[-b number] [-/+cb] [-cc classrange] [-/+cn] [-cr color] [-/+cu]
[-/+im]
[-/+j] [-/+l] [-lf filename] [-/+ls] [-/+mb] [-mc milliseconds] [-
ms color]
[-nb number] [-/+aw] [-/+rw] [-/+s] [-/+sb] [-/+sf] [-/+si] [-/
+sk]
[-sl number] [-/+t] [-tm string] [-tn name] [-/+ut] [-/+vb] [-/
+wf]
[-e command args ...] [%geom] [#geom] [-T string] [-n string] [-C]
[-Sxxd]

Type xterm -help for a full description.


Looks like the xterm that Sun uses doesn't support -into.

skuh...@web.de

unread,
Jun 29, 2007, 9:08:24 AM6/29/07
to
Larry W. Virden wrote:
> Looks like the xterm that Sun uses doesn't support -into.

It only depends on the version of the XServer, that is used. If you
use the current versions of Xorg on your Solaris-machine, then your
xterm also knows "-into", because xterm is part of X11.

The reason, why the OPs example does not work is explained in the man-
page of xterm:
"-into windowId
Given an X window identifier (a decimal integer),
xterm will reparent its top-level shell widget to that window. This
is
used to embed xterm within other applications."

It says, that the WindoID must be a decimal integer string, but [winfo
id .f] returns a hex-string. Changing the line to

exec xterm -into [expr [winfo id .f]] -e $env(EDITOR) &

solves the problem, since [expr] returns a decimal string.

HTH, regards
Stephan

Schelte Bron

unread,
Jun 29, 2007, 9:13:30 AM6/29/07
to
Jan Kandziora wrote:
> package require Tk
> frame .f -container yes
> pack .f -fill both -expand yes
> exec xterm -into [ winfo id .f ] -e $env(EDITOR) &
>
> However, the xterm is not reparented into the frame on my machine.
> Does anyone know what I left out?
>
The problem seems to be that [winfo id .f] returns a hex number
(something like 0x3e00005). The xterm man page indicates that it
wants a decimal number.

This works:
exec xterm -into [expr {[winfo id .f]}] -e $env(EDITOR) &


Schelte.
--
set Reply-To [string map {nospam schelte} $header(From)]

Thomas Dickey

unread,
Jun 29, 2007, 11:53:37 AM6/29/07
to
Larry W. Virden <lvi...@gmail.com> wrote:
> On Jun 29, 5:33 am, Jan Kandziora <j...@gmx.de> wrote:

>>
>> However, the xterm is not reparented into the frame on my machine. Does
>> anyone know what I left out?


> In my case, when I type the commands you list, I end up with this
> (sparc solaris):

> % exec xterm -into [winfo id .f] -e nvi &

It's a feature of modern xterm (Solaris delivers an antique ;-)

see

http://invisible-island.net/xterm/xterm.log.html#xterm_168

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Larry W. Virden

unread,
Jun 29, 2007, 12:03:42 PM6/29/07
to
On Jun 29, 11:53 am, Thomas Dickey <dic...@saltmine.radix.net> wrote:
> It's a feature of modern xterm (Solaris delivers an antique ;-)
>


On the other hand, poking around I discovered /opt/sfw/bin/xterm ,
which says it is XFree 86 4.0.1c(146), which surely is newer than the
other ;-)

Thomas Dickey

unread,
Jun 29, 2007, 12:26:02 PM6/29/07
to
Larry W. Virden <lvi...@gmail.com> wrote:

but "-into" was added in #168 - still more recent than #146

iirc, sunfreeware has more recent packages than that (the last I checked
it was around 200). current is #227...

Jan Kandziora

unread,
Jun 29, 2007, 2:35:23 PM6/29/07
to
Schelte Bron schrieb:

>
> This works:
> exec xterm -into [expr {[winfo id .f]}] -e $env(EDITOR) &
>
Cool, thanks.

Kind regards

Jan

Lan

unread,
Jun 29, 2007, 8:41:51 PM6/29/07
to

Thanks from the OP. I will test, post, and amaze them. The rest is
implementation details.

~Lan

0 new messages