Couple of comments(by Mihail and Jonathan) on my earlier post about programming in Ruby using SciTE editor brought this to my notice: When using SciTE to develop Ruby programs on Windows platform, there are a few issues that one needs to be aware of.

  1. To run the ruby interactive interpreter (or any other ruby command-line tool) from within SciTE editor on Windows, use full file name of the command, like irb.bat. If not already visible, open the output pane from View -> Output and type irb.bat in it. You should be dropped in the ruby shell; type ‘exit’ to exit the shell. You can any ruby command in this way, e.g. irb.bat, ri.bat. You can also run windows commands that are in the system path in the same way.
  2. When you run a Ruby program either using Tools -> Go menu item or using F5 key command, SciTE spawns a shell process to run ruby.exe in it. This may result in a DOS box popping up when you run a ruby program. You never will have to deal with this DOS command window directly, if it comes in your way, just minimize it and go back to the SciTE editor. All the output will be visible in the output window(View -> Output if it is not visible) and any input needed by your Ruby program should also be entered in the same output window. To reduce such confusion, it is always a good practice to print a prompt string whenever reading input from the user; if such a prompt string shouldn’t be a part of the interface, keep it anyway in the development version:
    [ruby]
    print “Enter a number between 5 and 55:”; STDOUT.flush
    num = gets.to_i
    [/ruby]

Adding a Menu Entry to Invoke irb Command

If you use the Ruby interactive shell frequently and don’t want to type seven characters each time you want to invoke it, then create a menu entry/keyboard shortcut for it. To do this, open the Ruby properties file by selecting Options -> Open ruby.properties menu item and search for Windows-specific settings(PLAT_WIN section).

Ruby Properties file in SciTE Editor

Add the following lines in that section:

command.name.0.*.rb=irb
command.0.*.rb=irb.bat
command.is.filter.0.*.rb=1
command.0.subsystem.*.rb=1

Use another number in place of ’0′ if you have already bound it to something else. The first line(command.name.0) defines the name to be used in as the menu entry. The second line(command.0) defines the command to be invoked when this menu entry is selected. A value of ’1′ in the third line(command.is.filter.0) indicates to SciTE that the command may modify the contents of the current file(file is reloaded based on the value of load.on.activate setting).

The section in the properties file should look like this:

Add New Menu Item in SciTE Editor

You can now invoke irb from Tools -> irb or by using Ctrl-0 key command. Note that this menu item will be visible only when editing .rb files. Ctrl-F6 will switch you between the file pane and the output pane.

What about GNU/Linux?

You can add a similar section in PLAT_GTK section if you are using SciTE on GNU/Linux platform, but use irb in the second line in place of irb.bat:

command.name.0.*.rb=irb
command.0.*.rb=irb
command.is.filter.0.*.rb=1
command.0.subsystem.*.rb=1

Add menu items to other frequently used commands in the same way(even links to help documents). For more information, refer to help document available from Help -> SciTE Help.