seGetSelectedText()

Fetches the text selected in the script editor.

Synopsis

string seGetSelectedText();

Parameters

-

Return value

The selected text

Description

Fetches the text selected in the script editor and returns it as a UTF8 encoded text. This function allows to expand the script editor (see function seGetCursorPos()). Therefore, only use the function to expand the script editor.

This function can also use multiple line selection.

Example

In the following example, a new menu is added to the script editor. The menu contains options which execute the se* functions. This means that you can access the functions via the menu in the script editor. The function seGetSelectedText() fetches the selected text in the script editor. In order to use the function, save the following example as <name>_ext.ctl file under project_path/scripts/scriptEditor. When you open the script editor, the menu myTools is shown.

Figure 1. Menu "MyTools" with the 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, "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);
}
  
void ShowSelectedText()
{
  string selectedText = seGetSelectedText();
  DebugN("Selected text: ", selectedText);
}

Assignment

Script Editor Extensions

Availability

UI