head	1.7;
access;
symbols
	core-8-5-9:1.6
	core-8-5-8:1.6
	macosx-cocoa-merge:1.7
	macosx-cocoa-premerge:1.7
	macosx-carbon-freeze:1.7
	core-8-5-7:1.6
	core-8-5-6:1.6
	core-8-6-b1:1.6
	core-8-6-a3:1.6
	core-8-5-5:1.6
	core-8-6-a2:1.6
	core-8-5-4:1.6
	core-8-5-3:1.6
	core-8-6-a1:1.6
	core-8-4-19:1.3
	core-8-5-branch:1.6.0.2
	core-8-5-2:1.6
	core-8-4-18:1.3
	core-8-5-1:1.6
	core-8-4-17:1.3
	core-8-5-0:1.6
	core-8-5-b3:1.5
	core-8-5-b2:1.4
	core-8-4-16:1.3
	core-8-5-b1:1.4
	core-stablilizer-merge:1.4
	core-stabilizer-branch:1.4.0.4
	core-stabilizer-merge:1.6
	core-8-4-15:1.3
	core-8-5-a6:1.4
	core-8-5-a5:1.4
	core-8-4-14:1.3
	core-8-5-a4:1.4
	core-8-4-13:1.3
	core-8-4-12:1.3
	core-8-4-11:1.3
	core-8-5-a3:1.4
	core-8-4-10:1.3
	core-8-4-9-branch:1.3.0.4
	core-8-5-a2:1.4
	core-8-4-9:1.3
	core-8-4-8:1.3
	core-8-4-7:1.3
	core-8-5-a1:1.4
	core-8-4-6:1.3
	core-8-4-5:1.3
	mistachkin-dev-branch:1.4.0.2
	core-8-4-4:1.3
	core-8-4-3:1.3
	core-8-4-branch:1.3.0.2
	core-8-4-2:1.3
	core-8-4-1:1.3
	core-8-3-5:1.2.18.1
	core-8-4-0:1.3
	macosx-8-4-merge-2002-08-31-trunk:1.3
	macosx-8-4-premerge-2002-08-31-branch:1.2.24.1
	macosx-8-4-premerge-2002-08-31-trunk:1.3
	macosx-8-4-merge-2002-08-30-branch:1.2.24.1
	macosx-8-4-merge-2002-08-30-trunk:1.3
	macosx-8-4-merge-2002-08-20-branch:1.2.24.1
	macosx-8-4-merge-2002-08-20-trunk:1.3
	core-8-4-b2:1.3
	core-8-4-b1:1.3
	macosx-premerge-6-9-02:1.2.24.1
	core-8-4-a4:1.3
	core-8-3-4:1.2.18.1
	macosx-8-4-branch:1.2.0.24
	macosx-8-4-branchpoint:1.2
	core-8-4-a3:1.2
	core-8-3-3:1.2
	dgp-privates-into-namespace:1.2.0.22
	tclpro-1-5-0:1.2
	core-8-4-win-speedup:1.2.0.20
	core-8-4-a2:1.2
	tclpro-1-4-1:1.2
	tclpro-1-4-0:1.2
	core-8-3-2:1.2
	ajuba-ajuba2-2-1-base:1.2
	ajuba-ajuba2-2-0:1.2
	core-8-4-a1:1.2
	core-8-3-1-branch:1.2.0.18
	core-8-3-1:1.2
	scriptics-sc-2-0-b5:1.2
	scriptics-sc-2-0-fixed:1.2
	scriptics-sc-2-0-b2:1.2
	scriptics-sc-2-0-b1:1.2
	core-8-3-0:1.2
	core-8-3-b2:1.2
	core-8-3-b1:1.2
	scriptics-sc-1-1:1.2
	scriptics-sc-1-1-b1:1.2
	core-8-2-3:1.2
	scriptics-sc-1-1-branch:1.2.0.16
	scriptics-sc-1-1-base:1.2
	scriptics-sc-1-0:1.2
	scriptics-sc-1-0-branch:1.2.0.14
	scriptics-sc-1-0-base:1.2
	core-8-2-2:1.2
	core-8-2-1:1.2
	scriptics-bc-1-0-b1:1.2
	core-8-2-1-branch:1.2.0.12
	scriptics-tclpro-1-3-0:1.2
	core-8-2-0:1.2
	core-8-2-b3-branch:1.2.0.10
	core-8-2-b3-base:1.2
	scriptics-tclpro-1-3-b4:1.2
	core-8-2-b2:1.2
	scriptics-tclpro-1-3-b3:1.2
	core-8-2-b1:1.2
	scriptics-tclpro-1-3-b2:1.2
	merge-to-mainline-5/21/99:1.2
	scriptics-tclpro-1-3-b2-branch:1.2.0.8
	core-8-1-1:1.2
	scriptics-tclpro-1-3-b1:1.2
	core-8-1-1-base:1.2
	core-8-1-0:1.2
	merge-to-mainline-4-29-99:1.2
	merge-to-mainline-4-23-99:1.2
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.2.0.6
	core-8-0-6-base:1.2
	core-8-0-5:1.2
	core-8-1-b3:1.1.4.1
	core-8-1-b2:1.1.4.1
	dev-8-1-stubs-branch:1.1.4.1.0.2
	dev-stubs-branch:1.2.0.4
	scriptics-tclpro-1-2:1.2
	scriptics-tclpro-1-2-b2:1.2
	core-8-1-merge-2/10/99:1.2
	core-8-0-5-branch:1.2.0.2
	core-8-0-5-base:1.2
	scriptics-tclpro-1-2-b1:1.2
	scriptics-tclpro-1-2-a1:1.2
	core-8-1-b1:1.1.4.1
	core-8-0-4:1.2
	core-8-1-a2:1.1
	core-8-0-2:1.1
	core-8-0-3:1.2;
locks; strict;
comment	@# @;


1.7
date	2009.03.25.23.27.14;	author nijtmans;	state Exp;
branches;
next	1.6;

1.6
date	2007.12.13.15.27.07;	author dgp;	state Exp;
branches;
next	1.5;

1.5
date	2007.10.30.01.57.54;	author hobbs;	state Exp;
branches;
next	1.4;

1.4
date	2003.09.30.14.54.30;	author dkf;	state Exp;
branches
	1.4.4.1;
next	1.3;

1.3
date	2001.10.29.16.23.32;	author dkf;	state Exp;
branches;
next	1.2;

1.2
date	98.09.14.18.23.29;	author stanton;	state Exp;
branches
	1.2.18.1
	1.2.20.1
	1.2.24.1;
next	1.1;

1.1
date	98.04.01.09.54.29;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.30.02.17.52;	author stanton;	state Exp;
branches;
next	;

1.2.18.1
date	2001.10.12.10.56.13;	author dkf;	state Exp;
branches;
next	;

1.2.20.1
date	2002.04.02.20.58.51;	author hobbs;	state Exp;
branches;
next	;

1.2.24.1
date	2002.02.05.02.25.16;	author wolfsuit;	state Exp;
branches;
next	;

1.4.4.1
date	2007.11.01.16.37.22;	author dgp;	state Exp;
branches;
next	;


desc
@@


1.7
log
@bring doc and demos in line with http://wiki.tcl.tk/812
@
text
@#!/bin/sh
# the next line restarts using wish \
exec wish "$0" ${1+"$@@"}

# rmt --
# This script implements a simple remote-control mechanism for
# Tk applications.  It allows you to select an application and
# then type commands to that application.
#
# RCS: @@(#) $Id: rmt,v 1.6 2007/12/13 15:27:07 dgp Exp $

package require Tcl 8.4
package require Tk

wm title . "Tk Remote Controller"
wm iconname . "Tk Remote"
wm minsize . 1 1

# The global variable below keeps track of the remote application
# that we're sending to.  If it's an empty string then we execute
# the commands locally.

set app "local"

# The global variable below keeps track of whether we're in the
# middle of executing a command entered via the text.

set executing 0

# The global variable below keeps track of the last command executed,
# so it can be re-executed in response to !! commands.

set lastCommand ""

# Create menu bar.  Arrange to recreate all the information in the
# applications sub-menu whenever it is cascaded to.

. configure -menu [menu .menu]
menu .menu.file
menu .menu.file.apps  -postcommand fillAppsMenu
.menu add cascade  -label "File"  -underline 0  -menu .menu.file
.menu.file add cascade  -label "Select Application"  -underline 0 \
	-menu .menu.file.apps
.menu.file add command  -label "Quit"  -command "destroy ."  -underline 0

# Create text window and scrollbar.

text .t -yscrollcommand ".s set" -setgrid true
scrollbar .s -command ".t yview"
grid .t .s -sticky nsew
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1

# Create a binding to forward commands to the target application,
# plus modify many of the built-in bindings so that only information
# in the current command can be deleted (can still set the cursor
# earlier in the text and select and insert;  just can't delete).

bindtags .t {.t Text . all}
bind .t <Return> {
    .t mark set insert {end - 1c}
    .t insert insert \n
    invoke
    break
}
bind .t <Delete> {
    catch {.t tag remove sel sel.first promptEnd}
    if {[.t tag nextrange sel 1.0 end] eq ""} {
	if {[.t compare insert < promptEnd]} {
	    break
	}
    }
}
bind .t <BackSpace> {
    catch {.t tag remove sel sel.first promptEnd}
    if {[.t tag nextrange sel 1.0 end] eq ""} {
	if {[.t compare insert <= promptEnd]} {
	    break
	}
    }
}
bind .t <Control-d> {
    if {[.t compare insert < promptEnd]} {
	break
    }
}
bind .t <Control-k> {
    if {[.t compare insert < promptEnd]} {
	.t mark set insert promptEnd
    }
}
bind .t <Control-t> {
    if {[.t compare insert < promptEnd]} {
	break
    }
}
bind .t <Meta-d> {
    if {[.t compare insert < promptEnd]} {
	break
    }
}
bind .t <Meta-BackSpace> {
    if {[.t compare insert <= promptEnd]} {
	break
    }
}
bind .t <Control-h> {
    if {[.t compare insert <= promptEnd]} {
	break
    }
}
### This next bit *isn't* nice - DKF ###
auto_load tk::TextInsert
proc tk::TextInsert {w s} {
    if {$s eq ""} {
	return
    }
    catch {
	if {
	    [$w compare sel.first <= insert] && [$w compare sel.last >= insert]
	} then {
	    $w tag remove sel sel.first promptEnd
	    $w delete sel.first sel.last
	}
    }
    $w insert insert $s
    $w see insert
}

.t configure -font {Courier 12}
.t tag configure bold -font {Courier 12 bold}

# The procedure below is used to print out a prompt at the
# insertion point (which should be at the beginning of a line
# right now).

proc prompt {} {
    global app
    .t insert insert "$app: "
    .t mark set promptEnd {insert}
    .t mark gravity promptEnd left
    .t tag add bold {promptEnd linestart} promptEnd
}

# The procedure below executes a command (it takes everything on the
# current line after the prompt and either sends it to the remote
# application or executes it locally, depending on "app".

proc invoke {} {
    global app executing lastCommand
    set cmd [.t get promptEnd insert]
    incr executing 1
    if {[info complete $cmd]} {
	if {$cmd eq "!!\n"} {
	    set cmd $lastCommand
	} else {
	    set lastCommand $cmd
	}
	if {$app eq "local"} {
	    set result [catch [list uplevel #0 $cmd] msg]
	} else {
	    set result [catch [list send $app $cmd] msg]
	}
	if {$result != 0} {
	    .t insert insert "Error: $msg\n"
	} elseif {$msg ne ""} {
	    .t insert insert $msg\n
	}
	prompt
	.t mark set promptEnd insert
    }
    incr executing -1
    .t yview -pickplace insert
}

# The following procedure is invoked to change the application that
# we're talking to.  It also updates the prompt for the current
# command, unless we're in the middle of executing a command from
# the text item (in which case a new prompt is about to be output
# so there's no need to change the old one).

proc newApp appName {
    global app executing
    set app $appName
    if {!$executing} {
	.t mark gravity promptEnd right
	.t delete "promptEnd linestart" promptEnd
	.t insert promptEnd "$appName: "
	.t tag add bold "promptEnd linestart" promptEnd
	.t mark gravity promptEnd left
    }
    return
}

# The procedure below will fill in the applications sub-menu with a list
# of all the applications that currently exist.

proc fillAppsMenu {} {
    set m .menu.file.apps
    catch {$m delete 0 last}
    foreach i [lsort [winfo interps]] {
	$m add command -label $i -command [list newApp $i]
    }
    $m add command -label local -command {newApp local}
}

set app [winfo name .]
prompt
focus .t

# Local Variables:
# mode: tcl
# End:
@


1.6
log
@merge stable branch onto HEAD
@
text
@d3 1
a3 1
exec wish "$0" "$@@"
d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.4.4.1 2007/11/01 16:37:22 dgp Exp $
@


1.5
log
@	* tests/listbox.test, tests/panedwindow.test, tests/scrollbar.test:
	* library/bgerror.tcl, library/dialog.tcl, library/listbox.tcl:
	* library/msgbox.tcl, library/optMenu.tcl, library/tclIndex:
	* library/tkfbox.tcl, library/demos/floor.tcl, library/demos/rmt:
	* library/demos/tcolor, library/demos/text.tcl:
	* library/demos/twind.tcl, library/demos/widget: Buh-bye Motif look
	* library/ttk/fonts.tcl:    Update of Tk default look in 8.5
	* macosx/tkMacOSXDefault.h: Trims border sizes, cleaner X11 look
	* unix/tkUnixDefault.h:     with minor modifications for Win32/Aqua.
	* win/tkWinDefault.h:       Uses Tk*Font definitions throughout for
	* win/tkWinFont.c:          classic widgets. [Bug #1820344]
	* library/obsolete.tcl (::tk::classic::restore): This restores
	changes made to defaults in 8.5 using the 'option' command,
	segmented into logical groups.
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.4 2003/09/30 14:54:30 dkf Exp $
@


1.4
log
@Added [package require] to demos. [FRQ 815118]
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.3 2001/10/29 16:23:32 dkf Exp $
d48 1
a48 1
text .t -relief sunken -bd 2 -yscrollcommand ".s set" -setgrid true
@


1.4.4.1
log
@merge updates from HEAD
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.4 2003/09/30 14:54:30 dkf Exp $
d48 1
a48 1
text .t -yscrollcommand ".s set" -setgrid true
@


1.3
log
@Improvements to the demo scripts, mostly up-ported from 8.3.4
@
text
@d10 4
a13 1
# RCS: @@(#) $Id: rmt,v 1.2 1998/09/14 18:23:29 stanton Exp $
d68 2
a69 2
    if {[.t tag nextrange sel 1.0 end] == ""} {
	if [.t compare insert < promptEnd] {
d76 2
a77 2
    if {[.t tag nextrange sel 1.0 end] == ""} {
	if [.t compare insert <= promptEnd] {
d83 1
a83 1
    if [.t compare insert < promptEnd] {
d88 1
a88 1
    if [.t compare insert < promptEnd] {
d93 1
a93 1
    if [.t compare insert < promptEnd] {
d98 1
a98 1
    if [.t compare insert < promptEnd] {
d103 1
a103 1
    if [.t compare insert <= promptEnd] {
d108 1
a108 1
    if [.t compare insert <= promptEnd] {
d112 4
a115 3
auto_load tkTextInsert
proc tkTextInsert {w s} {
    if {$s == ""} {
d119 3
a121 2
	if {[$w compare sel.first <= insert]
		&& [$w compare sel.last >= insert]} {
d153 2
a154 2
    if [info complete $cmd] {
	if {$cmd == "!!\n"} {
d159 1
a159 1
	if {$app == "local"} {
d166 2
a167 4
	} else {
	    if {$msg != ""} {
		.t insert insert $msg\n
	    }
d185 1
a185 1
    if !$executing {
d192 1
a192 1
    return {}
@


1.2
log
@Replaced SCCS strings, fixed binary files
@
text
@d10 1
a10 1
# RCS: @@(#) $Id$
d35 7
a41 9
frame .menu -relief raised -bd 2
pack .menu -side top -fill x
menubutton .menu.file -text "File" -menu .menu.file.m -underline 0
menu .menu.file.m
.menu.file.m add cascade -label "Select Application" \
	-menu .menu.file.m.apps -underline 0
.menu.file.m add command -label "Quit" -command "destroy ." -underline 0
menu .menu.file.m.apps  -postcommand fillAppsMenu
pack .menu.file -side left
d47 3
a49 2
pack .s -side right -fill both
pack .t -side left
d125 1
d196 2
a197 1
    catch {.menu.file.m.apps delete 0 last}
d199 1
a199 1
	.menu.file.m.apps add command -label $i -command [list newApp $i]
d201 1
a201 1
    .menu.file.m.apps add command -label local -command {newApp local}
d207 4
@


1.2.20.1
log
@sync with head
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.3 2001/10/29 16:23:32 dkf Exp $
d35 9
a43 7
. configure -menu [menu .menu]
menu .menu.file
menu .menu.file.apps  -postcommand fillAppsMenu
.menu add cascade  -label "File"  -underline 0  -menu .menu.file
.menu.file add cascade  -label "Select Application"  -underline 0 \
	-menu .menu.file.apps
.menu.file add command  -label "Quit"  -command "destroy ."  -underline 0
d49 2
a50 3
grid .t .s -sticky nsew
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1
a125 1
.t configure -font {Courier 12}
d196 1
a196 2
    set m .menu.file.apps
    catch {$m delete 0 last}
d198 1
a198 1
	$m add command -label $i -command [list newApp $i]
d200 1
a200 1
    $m add command -label local -command {newApp local}
a205 4

# Local Variables:
# mode: tcl
# End:
@


1.2.24.1
log
@Merge with current TOT
Added support for the wm stackorder command
Fixed crash when selecting Menu items in the Application menu that we didn't
put there.
Added first bits of the use of CG for low-level drawing.  The line-drawing works,
the rest doesn't yet.  You have to set the file static useCGDrawing to 1 and
rebuild to activate this code.
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.2 1998/09/14 18:23:29 stanton Exp $
d35 9
a43 7
. configure -menu [menu .menu]
menu .menu.file
menu .menu.file.apps  -postcommand fillAppsMenu
.menu add cascade  -label "File"  -underline 0  -menu .menu.file
.menu.file add cascade  -label "Select Application"  -underline 0 \
	-menu .menu.file.apps
.menu.file add command  -label "Quit"  -command "destroy ."  -underline 0
d49 2
a50 3
grid .t .s -sticky nsew
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1
a125 1
.t configure -font {Courier 12}
d196 1
a196 2
    set m .menu.file.apps
    catch {$m delete 0 last}
d198 1
a198 1
	$m add command -label $i -command [list newApp $i]
d200 1
a200 1
    $m add command -label local -command {newApp local}
a205 4

# Local Variables:
# mode: tcl
# End:
@


1.2.18.1
log
@Updates to demos
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.2 1998/09/14 18:23:29 stanton Exp $
d35 9
a43 7
. configure -menu [menu .menu]
menu .menu.file
menu .menu.file.apps  -postcommand fillAppsMenu
.menu add cascade  -label "File"  -underline 0  -menu .menu.file
.menu.file add cascade  -label "Select Application"  -underline 0 \
	-menu .menu.file.apps
.menu.file add command  -label "Quit"  -command "destroy ."  -underline 0
d49 2
a50 3
grid .t .s -sticky nsew
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1
a125 1
.t configure -font {Courier 12}
d196 1
a196 2
    set m .menu.file.apps
    catch {$m delete 0 last}
d198 1
a198 1
	$m add command -label $i -command [list newApp $i]
d200 1
a200 1
    $m add command -label local -command {newApp local}
a205 4

# Local Variables:
# mode: tcl
# End:
@


1.1
log
@Initial revision
@
text
@d10 1
a10 1
# SCCS: @@(#) rmt 1.10 96/06/24 16:42:38
@


1.1.4.1
log
@Merged 8.0.3 changes into 8.1
@
text
@d10 1
a10 1
# RCS: @@(#) $Id: rmt,v 1.2 1998/09/14 18:23:29 stanton Exp $
@


