Class Reference textEdit

The text editor main window. More...

Member

void addFunctionKey(int key,int function)
void addMacroKey(int key,string macroFileName, string title, string iconFileName)
void addMacroToolButton(string macroName,string parameter,string iconfilename)
void closeFile()
int countFiles()
textDisplay* drawing
string filename
int findFile(string filename)
void hideToolBar(string name)
string macroToolbarName
void menuAdd(string name,string entries )
void needLayoutEditor(bool newOne=false)
void needSchematicEditor(bool newOne=false)
void newDoc()
void newFile()
void open(string filename)
void reload()
void save()
void saveAs()
void setFile(int i)
void setLexer(string lexer)
void setText(string text)
void showToolBar(string name)
void toolBarAdd(string name,string buttons)

Detailed Description

graph LR te(textEdit)--drawing-->td(textDisplay) click te "/layoutscript/api/textedit" click td "/layoutscript/api/textdisplay" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class te thisClas class td clas

A textEdit window is the Text Editor: one or more files, menus and toolbars. The text of the visible file is text->drawing, a textDisplay. Macros started from the Text Editor use the name text for this window (not layout). If you need a layout from that macro, call needLayoutEditor() first so layout is valid. setFile chooses which open document is shown when several files are loaded. Save, reload and lexer (syntax highlighting) all go through this window or its drawing.

Example:

if (text->drawing->modified())
 text->save();
text->needLayoutEditor();
layout->executeMacro(text->drawing->fileName);

Member Function Documentation


void textEdit::addFunctionKey(int key,int function)

Set the feature of an extra keyboard. key is the number of the key. It is numbered from 0 to the amount of keys the keyboard has. function is the feature code of the featur you want to add. As toolbutton, modification of the extra keyboard are not store and it is recommended to set it with an autostart macro. (introduced with release 20210905)


void textEdit::addMacroKey(int key,string macroFileName, string title, string iconFileName)

Assigns one key of an external keyboard to a macro. key is the key number. macroFileName is the full path of the macro, title the caption, and iconFileName the full path of the icon file. (introduced with release 20210910)

Parameter:
key key index on the extra keyboard
macroFileName full path of the macro file
title caption shown for the key
iconFileName full path of the icon file

void textEdit::addMacroToolButton(string macroName,string parameter,string iconfilename)

Adds a button to the Macros toolbar (created if missing). macroName is the macro to run. iconfilename is the icon. Buttons are not stored at shutdown.

Parameter:
macroName macro to execute
parameter reserved; pass an empty string
iconfilename path to the button icon

void textEdit::closeFile()

Closes the current visible file.


int textEdit::countFiles()

Returns: number of open files within the text editor.


textDisplay* textEdit::drawing

The visible document: a textDisplay.


string textEdit::filename

This string hold the current filename.


int textEdit::findFile(string filename)

Returns: the number of the file in the list of file in the case the filename is open. Otherwise -1 is returned;


void textEdit::hideToolBar(string name)

Hides the named toolbar.


string textEdit::macroToolbarName

Holds the name of the toolbar containing custom macros. The name must be set before the first macro is added to the toolbar. (introduced with release 20211216)


void textEdit::menuAdd(string name,string entries )

Add a new entry to the main menu. The first parameter is the name of the menu. The second parameter contains last entries of the new menu separated with a semicolon. Next to the feature name the FeatureCode can be used to access a feature.

Parameter:
name name
entries entries

void textEdit::needLayoutEditor(bool newOne=false)

Calling the layout object from a macro will fail, if no layout window is associated with the textEdit class. Calling this feature will link the text edit window with a layout window. If newOne is true, a new empty layout window will be associated. Otherwise it will be looked for existing windows before creating a new one.


void textEdit::needSchematicEditor(bool newOne=false)

Calling the schematic object from a macro will fail, if no schematic window is associated with the textEdit class. Calling this feature will link the text edit window with a layout window. If newOne is true, a new empty schematic window will be associated. Otherwise it will be looked for existing windows before creating a new one.


void textEdit::newDoc()

Set the current file to a new empty file. A new file is created, if required.


void textEdit::newFile()

Open a new empty file for editing.


void textEdit::open(string filename)

opens the named file.


void textEdit::reload()

Reloads the current displayed file from disk. Unsaved modifications are removed.


void textEdit::save()

Saves the current text file. If the file is not store or have no file name set, it asked for a filename.


void textEdit::saveAs()

Ask for a file name and store the current file there.


void textEdit::setFile(int i)

Displayes the file on position i.


void textEdit::setLexer(string lexer)

Set the lexer for the current displayed text.


void textEdit::setText(string text)

Set the text for the current displayed text file.


void textEdit::showToolBar(string name)

Shows the named toolbar.


void textEdit::toolBarAdd(string name,string buttons)

Add a new tool bar, separate multiple buttons with a ';'. Next to the feature name the FeatureCode can be used to access a feature. {{{ text->toolBarAdd("my toolbar","New Layout;Zoom Mouse;Code 39;Quit"); }}}

Parameter:
name name
buttons buttons