Home > Archive > Tcl > June 2007 > A widget for the user's editor of choice
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
A widget for the user's editor of choice
|
|
|
| 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 2007-06-29, 8:08 am |
| 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 2007-06-29, 8:08 am |
| 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 2007-06-29, 8:08 am |
| 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.
| |
| skuhagen@web.de 2007-06-29, 8:08 am |
| 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 2007-06-29, 10:08 pm |
| 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)]
| |
|
|
| Larry W. Virden 2007-06-29, 10:08 pm |
| 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 2007-06-29, 10:08 pm |
| Larry W. Virden <lvirden@gmail.com> wrote:
> On Jun 29, 11:53 am, Thomas Dickey <dic...@saltmine.radix.net> wrote:
[color=darkred]
> 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 ;-)
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...
--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
| |
| Jan Kandziora 2007-06-29, 10:08 pm |
| Schelte Bron schrieb:
>
> This works:
> exec xterm -into [expr {[winfo id .f]}] -e $env(EDITOR) &
>
Cool, thanks.
Kind regards
Jan
| |
|
| On Jun 29, 11:35 am, Jan Kandziora <j...@gmx.de> wrote:
> Schelte Bron schrieb:
>
>
> Cool, thanks.
>
> Kind regards
>
> Jan
Thanks from the OP. I will test, post, and amaze them. The rest is
implementation details.
~Lan
| |
|
|
|
|
|