1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
Subject: tkman contribution
From: Scott Schwartz <schwartz@groucho.cse.psu.edu>
Here's a contribution to tkman. It lets you select a string, in an xterm
or wherever, hit the <Help> key, and have your selection looked up by
tkman. It uses the "remote.tcl" thing from the current distribution,
included inline, and the "xselection" program, from ftp.x.org:/contrib
(since you might want to look in the CLIPBOARD selection rather than
the primary selection, and tk doesn't do that yet.)
#!/depot/tcl/bin/wish -f
# tkman_selection --
# Sweep out a selection with the mouse, hit Help, and the word
# will be looked up in the manual.
#
# To install
# put this file in your bin
# put this line in your .twmrc (adapt for other window managers as needed)
# "Help" = :all:!"tkman_selection&"
# remote.tcl:
proc tkman {man} {
if {[set found [lsearch [winfo interps] tkman*]]==-1} {
# if TkMan doesn't already exist, start one up
if {[catch {exec tkman &}]} {puts stdout "tkman not found"; return}
# wait for it to be registered
for {set found -1} {$found==-1} {after 1} {
set found [lsearch [winfo interps] tkman*]
}
# wait for it to initialize
for {set ready 0} {!$ready} {after 1} {
catch {if {[send tkman set manx(init)]=="1"} {set ready 1}}
}
}
set tkman [lindex [winfo interps] $found]
# .man is the main window, guaranteed to exist
set w .man
send $tkman raise $w
send $tkman manShowMan $man
return
}
#
# main - tkman from selection
#
wm withdraw .
set sel [exec xselection PRIMARY]
# we could check other places too
catch {tkman $sel}
destroy .
|