seSetCursorPos()
Sets the cursor on a specific position in the script editor.
Synopsis
int seSetCursorPos(int line, int column[, bool select = false]
);
Parameters
Parameter | Description |
---|---|
line | The new line number of the cursor position. |
column | The new column number of the cursor position. |
select | Selection acivated/not activated. Default value is "false". |
Return value
0, when the new cursor position has been set.
If an error occurs, -1 will be returned.
Description
Sets the cursor to a specific position in the script editor.
This function is an expansion to the script editor and cannot be used in another context. To retrieve the script from the Editor, use the existing function getScript() and to set it back, use the existing function setScript(). The extension scripts have to be located in the <proj_dir>/scripts/scriptEditor directory and have the extension "_ext.ctl". The Scripts can only be loaded and executed from this directory.
The first line and column number is set as position 0. This means if line = 3 and column = 3 are entered, the cursor will be set to the position [2,2]. To enforce a consistency of both positions, the parameters (line and column) have to be decremented by one.
The third, optional, argument specifies if the text between the current cursor position and the new cursor position shoud be selected. The default value is false, which means that nothing is selected. If it is set to true then the text between the current position and the position specified with seSetCursorPos() is selected.
Example
In the following example a new menu will be added to the script editor. The menu contains actions, which retrieve and execute the se* functions. This means that the functions can be retrieved via the script editor menu.
Figure: Result -> "MyTools" menu with executable se* functions
main()
{
int id = moduleAddMenu("MyTools");
int tb = moduleAddToolBar("toolbar1");
DebugN(id, tb);
int id1 = moduleAddAction("Return Cursor Position", "", "", id, tb, "GetCursorPosition");
int id2 = moduleAddAction("Set Cursor Position [3,3]", "", "", id, tb, "SetCursorPosition");
int id3 = moduleAddAction("Replace Line by 'Line removed'", "", "", id, tb, "SetLine");
int id4 = moduleAddAction("Read Content", "", "", id, tb, "GetLine");
int id5 = moduleAddAction("Insert Line with Text", "", "", id, tb, "InsertLi
int id6 = moduleAddAction("Remove Cursor Position Line ", "", "", id, tb, "RemoveLine");
}
void GetCursorPosition()
{
int line;
int column;
seGetCursorPos(line, column);
DebugN(line, column);
}
void SetCursorPosition()
{
int line = 3;
int column = 3;
seSetCursorPos(line - 1, column - 1);
DebugN("Cursor position set:", line, column);
}
void SetLine()
{
int line;
int column;
seGetCursorPos(line, colum
seSetLine(line, "Line removed");
DebugN("Line replaced:", line, column);
}
void GetLine()
{
int line;
int column;
seGetCursorPos(line, column);
DebugN(line, column);
DebugN("Line content: ", seGetLine(line));
}
void InsertLine()
{
int line;
int column;
string text = "New line with text";
seGetCursorPos(line, column);
seInsertLine(line, text);
DebugN(line, column);
DebugN("Text in line ", line, " added: ", text);
}
void RemoveLine()
{
int line;
int column;
seGetCursorPos(line, column);
DebugN(line, column);
seRemoveLine(line); DebugN("Removed line with the line number:", line);
}
Assignment
Script Editor Extensions
Availability
UI