Engine

Engine

The engine for scripting the editor. To access the engine for scripting a particular Guppy instance, say called "guppy1", do Guppy("guppy1").engine.

At that point, you can, for example, move that editor's cursor one spot to the left with Guppy("guppy1").engine.left().

Constructor

new Engine()

Source:

Methods

add_symbol(name, symbol, templateopt)

Source:

Add a symbol to this instance of the editor.

Parameters:
Name Type Attributes Description
name string

param

symbol Object

If template is present, this is the template arguments. Otherwise, it is a complete specification of the symbol, the format for which can be found in the documentation for Guppy.add_global_symbol.

template string <optional>

The name of the template to use.

backspace()

Source:

Simulate the "backspace" key press

delete_key()

Source:

Simulate the "delete" key press

done()

Source:

Execute the "done" callback

down()

Source:

Simulate a down arrow key press

end()

Source:

Move the cursor to the end of the document

get_content(t)

Source:

Get the content of the editor

Parameters:
Name Type Description
t string

The type of content to render ("latex", "text", or "xml").

home()

Source:

Move the cursor to the beginning of the document

insert_doc(doc)

Source:

Insert a copy of the given document into the editor at the current cursor position.

Parameters:
Name Type Description
doc Doc

The document to insert.

insert_string(s)

Source:

Insert a string into the document at the current cursor position.

Parameters:
Name Type Description
s string

The string to insert.

insert_symbol(sym_name)

Source:

Insert a symbol into the document at the current cursor position.

Parameters:
Name Type Description
sym_name string

The name of the symbol to insert. Should match one of the keys in the symbols JSON object

left()

Source:

Simulate the left arrow key press

list_extend(direction, copy)

Source:

Add an element to a list (or row/column to a matrix) in the specified direction. Can optionally copy the current element/row/column to the new one.

Parameters:
Name Type Description
direction string

One of "up", "down", "left", or "right".

copy boolean

Whether or not to copy the current element/row/column into the new one.

list_remove()

Source:

Remove the current element from a list (or column from a matrix)

list_remove_col()

Source:

Remove the current column from a matrix

list_remove_row()

Source:

Remove the current row from a matrix

list_vertical_move(down)

Source:

Move the cursor by one row up or down in a matrix.

Parameters:
Name Type Description
down boolean

If true, move down in the matrix; otherwise, up.

redo()

Source:

Redo the last undone action

remove_symbol(name)

Source:

Remove a symbol from this instance of the editor.

Parameters:
Name Type Description
name string

The name of the symbol to remove.

Source:

Simulate the right arrow key press

sel_all()

Source:

Select the entire contents of the editor.

sel_clear()

Source:

Clear the current selection, leaving the document unchanged and nothing selected.

sel_copy()

Source:

Copy the current selection, leaving the document unchanged but placing the contents of the current selection on the clipboard.

sel_cut()

Source:

Cut the current selection, removing it from the document and placing it in the clipboard.

sel_delete()

Source:

Delete the current selection.

sel_left()

Source:

Move the cursor to the left, adjusting the selection along with the cursor.

sel_paste()

Source:

Paste the current contents of the clipboard.

sel_right(name)

Source:

function

Parameters:
Name Type Description
name string

param

set_content(xml_data)

Source:

Set the XML content of the editor

Parameters:
Name Type Description
xml_data string

An XML string of the content to place in the editor

set_doc(doc)

Source:

Set the document of the editor

Parameters:
Name Type Description
doc Doc

The Doc that will be the editor's source

spacebar()

Source:

Simulate the spacebar key press

tab()

Source:

Simulate a tab key press

undo()

Source:

Undo the last action

up()

Source:

Simulate an up arrow key press