Module: | Kernel |
The methods described here are the extension of the standard "Kernel" module. They can be accessed from the top level, e.g. directly from the Molby console.
Same as the built-in backquote operator, except that it does not show the console window on Windows platform.
Call a subprocess by the given command line. A progress window is shown, and the argument cmdname
is used to show an appropriate message. If callback
is given (as a Proc object), it will be called periodically during execution; if callback
returns nil
or false
, execution of the subprocess is interrupted.
The standard output/error stream is directed to the Ruby Console. If stdout_file or stderr_file is given as a filename, the stdout/stderr output will be directed to that file. (If the filename begins with ">>", then the output will be appended to the end of the file; otherwise, the existing file will be replaced.) If it is "/dev/null" or "NUL", then the output will be lost.
Returns an integer value with the same meaning as Kernel.system
.
See Also: Molecule#call_subprocess_async
Get the directory suitable for storing user documents. On Windows it is the home directory + "My Documents". On other platforms it is the home directory.
Execute the script in the given file. If a molecule is active, then the script is evaluated as Molecule.current.instance_eval(script). Before entering the script, the current directory is set to the parent directory of the script.
Stop the execution of the script and return to the Molby application. Only usable when the script is invoked from the file or from the Console. Internally, this method is equivalent to throw :molby_top, arg
. When a script is executed from file and from console, it is internally wrapped by catch(:molby_top) { ... }
.
Standard implementation of exit
(stop execution and quit) is not available, because it does not make much sense to stop execution of Molby application from inside the script.
Copy a string to the clipboard (so that it can be pasted in other applications).
Get the current interrupt flag. If interrupt is enabled, true is returned. Otherwise, false is returned.
Hide the progress panel with the given ID. If ID is not given, then the last panel created by show_progress_panel is hidden. If no progress panel is shown, an exception is raised.
See Also: show_progress_panel
Look up the title from the Script menu. If found, returns a non-negative integer. If not found, returns -1.
Show a message box. Button is nil ("OK" and "Cancel"), :ok ("OK" only) or :cancel ("Cancel" only). Icon is one of the following symbols; :info, :warning, :error.
Play the sound (a WAV file) in the file. Flag: 0, pause until sound ends; 1, play the sound asynchronously; 3, play the sound with loop asynchronously. If flag = 1 or 3, the sound can be stopped by stop_sound, which is mandatory for flag = 3 (otherwise the sound will continue forever!).
See Also: bell, stop_sound
Register the method (specified as a symbol) in the script menu. The method must be either an instance method of Molecule with no argument, or a class method of Molecule with one argument (the current molecule). The menu associated with the class method can be invoked even when no document is open (the argument is set to nil in this case). On the other hand, the menu associated with the instance method can only be invoked when at least one document is active.
Set the current interrupt flag (true to enable interrupt, false to disable interrupt). Returns the old interrupt flag.
Set the message for the progress panel with the given ID. If the ID is not given, then the last panel created by show_progress_panel is specified. If the progress panel is not shown, an exception is raised.
Set the progress value to the progress panel with the given ID. The value should be a Float. If 0 <= value <= 1, then the progress bar becomes determinant and shows the value as the length of the colored part (value 1 corresponds to 100% progress). If the value is negative, then the progress bar becomes indeterminant.
If the ID is not given, then the last panel created by show_progress_panel is specified. If the progress panel is not shown, an exception is raised.
Show the progress panel. The panel can be dismissed by pressing the escape key or pressing the cancel button, in which case Interrupt exception is raised.
The return value is an integer to specify the panel. On calling hide_progress_panel, set_progress_message and set_progress_value, this return value can be given as an ID.
See Also: hide_progress_panel