rmt revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
# the next line restarts using wish \
exec wish "$0" "$@"
# 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.
#
# SCCS: @(#) rmt 1.9 96/02/16 10:49:22
# 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.
# Create text window and scrollbar.
scrollbar .s -command ".t yview"
# 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).
break
}
break
}
}
}
break
}
}
}
break
}
}
}
}
break
}
}
break
}
}
break
}
}
break
}
}
if {$s == ""} {
return
}
catch {
}
}
}
# 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).
}
# 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".
set cmd $lastCommand
} else {
set lastCommand $cmd
}
} else {
}
if {$result != 0} {
} else {
}
}
}
}
# 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).
if !$executing {
}
return {}
}
# The procedure below will fill in the applications sub-menu with a list
# of all the applications that currently exist.
.menu.file.m.apps add command -label $i -command [list newApp $i]
}
.menu.file.m.apps add command -label local -command {newApp local}
}
focus .t