[Molby Document Home] [Contents]

Module: | Kernel

### Description

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.

### Constant

MolbyResourcePath

A String describing the full path of the directory containing `Scripts` and `amber11` resources. On Windows, it is something like `"C:\\Program Files\\Molby"`. On Mac, it is something like `"/Applications/Molby/Molby.app/Contents/Resources"`.

### Public Instance methods

ask(prompt, default = nil) → string

Open a modal dialog and get a line of text.

call_subprocess(cmdline, cmdname) → Integer

Call a subprocess by the given command line. A progress window is shown, and the argument `cmdname` is used to show an appropriate message. Returns an integer value with the same meaning as `Kernel.system`.

check_interrupt → Integer

Returns 1 if interrupted, 0 if not, -1 if interrupt is disabled.

document_home → String

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.

error_message_box(str)

Show an error message box.

execute_script_file(fname)

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.

get_global_settings(key) → value

Get a setting data for key from the application preferences.

get_interrupt_flag → boolean

Get the current interrupt flag. If interrupt is enabled, true is returned. Otherwise, false is returned.

hide_progress_panel

Hide the progress panel. If the panel is not yet shown or already dismissed, do nothing.

See Also: show_progress_panel

message_box(str, title, button = nil, icon = :info)

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.

register_menu(title, method)

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_global_settings(key, value)

Set a setting data for key to the application preferences.

set_interrupt_flag(value) → old_value

Set the current interrupt flag (true to enable interrupt, false to disable interrupt). Returns the old interrupt flag.

set_progress_message(message)

Set the message for the progress panel. If the progress panel is not shown, do nothing.

set_progress_value(value)

Set the progress value. 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.

show_progress_panel

Show the progress panel. The panel can be dismissed by pressing the escape key, in which case Interrupt exception is thrown.

See Also: hide_progress_panel