summaryrefslogtreecommitdiff
path: root/ext/tk/sample/demos-en/rmt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/sample/demos-en/rmt')
-rw-r--r--ext/tk/sample/demos-en/rmt68
1 files changed, 34 insertions, 34 deletions
diff --git a/ext/tk/sample/demos-en/rmt b/ext/tk/sample/demos-en/rmt
index 73f631180a..dcfb328fc8 100644
--- a/ext/tk/sample/demos-en/rmt
+++ b/ext/tk/sample/demos-en/rmt
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
-# 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.
+# 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.
require 'tk'
@@ -17,41 +17,41 @@ class Rmt
root = TkWinfo.toplevel(parent)
root.minsize(1,1)
- # The instance 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.
+ # The instance 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.
@app = 'local'
@mode = 'Ruby'
- # The instance variable below keeps track of whether we're in the
- # middle of executing a command entered via the text.
+ # The instance variable below keeps track of whether we're in the
+ # middle of executing a command entered via the text.
@executing = 0
- # The instance variable below keeps track of the last command executed,
- # so it can be re-executed in response to !! commands.
+ # The instance variable below keeps track of the last command executed,
+ # so it can be re-executed in response to !! commands.
@lastCommand = ""
- # Create menu bar. Arrange to recreate all the information in the
- # applications sub-menu whenever it is cascaded to.
+ # Create menu bar. Arrange to recreate all the information in the
+ # applications sub-menu whenever it is cascaded to.
TkFrame.new(root, 'relief'=>'raised', 'bd'=>2) {|f|
pack('side'=>'top', 'fill'=>'x')
TkMenubutton.new(f, 'text'=>'File', 'underline'=>0) {|mb|
TkMenu.new(mb) {|mf|
mb.menu(mf)
- TkMenu.new(mf) {|ma|
+ TkMenu.new(mf) {|ma|
postcommand proc{win.fillAppsMenu ma}
- mf.add('cascade', 'label'=>'Select Application',
+ mf.add('cascade', 'label'=>'Select Application',
'menu'=>ma, 'underline'=>0)
}
- add('command', 'label'=>'Quit',
+ add('command', 'label'=>'Quit',
'command'=>proc{root.destroy}, 'underline'=>0)
}
pack('side'=>'left')
}
}
- # Create text window and scrollbar.
+ # Create text window and scrollbar.
@txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
@@ -60,9 +60,9 @@ class Rmt
@promptEnd = TkTextMark.new(@txt, 'insert')
- # 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
+ # 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).
@txt.bindtags([@txt, TkText, root, 'all'])
@@ -151,8 +151,8 @@ class Rmt
w.see('insert')
end
- # The method below is used to print out a prompt at the
- # insertion point (which should be at the beginning of a line
+ # The method below is used to print out a prompt at the
+ # insertion point (which should be at the beginning of a line
# right now).
def prompt
@@ -162,8 +162,8 @@ class Rmt
@txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
end
- # The method below executes a command (it takes everything on the
- # current line after the prompt and either sends it to the remote
+ # The method 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".
def invoke
@@ -200,8 +200,8 @@ class Rmt
if complete
@lastCommand = cmd
begin
-# msg = Tk.appsend(@app, false,
-# 'ruby',
+# msg = Tk.appsend(@app, false,
+# 'ruby',
# '"(' + cmd.gsub(/[][$"]/, '\\\\\&') + ').to_s"')
msg = Tk.rb_appsend(@app, false, cmd)
rescue
@@ -218,10 +218,10 @@ class Rmt
end
# The following method 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).
+ # 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).
def newApp(appName, mode)
@app = appName
@@ -236,7 +236,7 @@ class Rmt
end
# The method below will fill in the applications sub-menu with a list
- # of all the applications that currently exist.
+ # of all the applications that currently exist.
def fillAppsMenu(menu)
win = self
@@ -251,14 +251,14 @@ class Rmt
else
mode = 'Ruby'
end
- menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
+ menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
'command'=>proc{win.newApp ip, mode})
rescue
- menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
+ menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
end
}
- menu.add('command', 'label'=>format("local (Ruby/Tk)"),
+ menu.add('command', 'label'=>format("local (Ruby/Tk)"),
'command'=>proc{win.newApp 'local', 'Ruby'})
end
end