seGetCursorPos()

Returns the current cursor position in the script editor.

Synopsis

int seGetCursorPos(int &line, int &column);

Parameters

Parameter Description
line The line number of the cursor position (return value).
column The column number of the cursor position (return value).

Return value

Cursor position.

If an error occurs, -1 will be returned.

Description

Returns the current cursor position in the script editor.

This function allows to expand the script editor and it is not allowed to use it in another context. To retrieve the script from the Editor, use the existing function getScript() and to set it back, use the existing functionsetScript(). The extension scripts have to be located in <proj_dir>/scripts/scriptEditor directory and an saved with the extension "_ext.ctl". From there only they can be loaded and executed.

The first line and column number is on the position 0. That means that if the cursor position is [3,3], this function returns the position [2,2]. To enforce the agreement of both position specifications, the return values have to be incremented by one.

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. That means that the functions can retrieved via the script editor menu.

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, "InsertLine");
  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, column);
  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