# Script editor

This page explains how Python can be used within Inlage.

In this window you can write your own Python scripts that can control the editor window of Inlage. With the given instance cmd, you can call some actions of Inlage's editor:

• AddPackage: Adds a package to the document header like the Packages dialog.
• AddParameter: Adds a line to the paramters like the Additional options dialog.
• Dialog: Creates a dialog in Inlage for the insertion of text parameters.
• DialogFloat: Creates a dialog in Inlage for the insertion of float values.
• DialogInt: Creates a dialog in Inlage for the insertion of integer values.
• GetText: Returns the whole text of the active document.
• Insert: Inserts text at cursor position.
• Replace: Replace text with other text.
• SelectedText: Returns the selected text of the active document.
• SelectionStart: Returns the selected text of the active document.
• SetSelection: Sets the selected text of the active document.
• SetText: Sets the text of the active document.

The default example is a script that creates an insert dialog for labeled environments:

environment, label = cmd.Dialog("Environment", "Label")

start = "\\begin{" + environment + "}\r\n\t"
end = "\r\n\t\\label{" + label + "}\r\n\\end{" + environment + "}"

if environment == "align" or environment == "multline":

cmd.Insert(start + end)
cmd.SelectionStart -= len(end) + 1

This example script generates the following dialog:

The generated output will be:

\usepackage{amsmath}
[...]
\begin{align}

\label{eq1}
\end{align}

NOTE: The execution and management of the Python scripts can be done with the Scripts window.

script_editor.txt · Last modified: 2013/04/07 01:45 by nils