PCL
|
Client-side interface to a PixInsight CodeEditor control. More...
#include <CodeEditor.h>
Public Types | |
using | cursor_event_handler = void(Control::*)(CodeEditor &sender, int line, int col) |
using | editor_event_handler = void(Control::*)(CodeEditor &sender) |
using | selection_event_handler = void(Control::*)(CodeEditor &sender, int fromLine, int fromCol, int toLine, int toCol) |
using | state_event_handler = void(Control::*)(CodeEditor &sender, bool state) |
Public Types inherited from pcl::Control | |
using | child_event_handler = void(Control::*)(Control &sender, Control &child) |
using | close_event_handler = void(Control::*)(Control &sender, bool &allowClose) |
using | event_handler = void(Control::*)(Control &sender) |
using | file_drag_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers, bool &wantsFiles) |
using | file_drop_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers) |
using | keyboard_event_handler = void(Control::*)(Control &sender, int key, unsigned modifiers, bool &wantsKey) |
using | mouse_button_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, int button, unsigned buttons, unsigned modifiers) |
using | mouse_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, unsigned buttons, unsigned modifiers) |
using | mouse_wheel_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, int delta, unsigned buttons, unsigned modifiers) |
using | move_event_handler = void(Control::*)(Control &sender, const pcl::Point &newPos, const pcl::Point &oldPos) |
using | paint_event_handler = void(Control::*)(Control &sender, const pcl::Rect &updateRect) |
using | resize_event_handler = void(Control::*)(Control &sender, int newWidth, int newHeight, int oldWidth, int oldHeight) |
using | view_drag_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers, bool &wantsView) |
using | view_drop_event_handler = void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers) |
Additional Inherited Members | |
Static Public Member Functions inherited from pcl::Control | |
static void | HideToolTip () |
static Control & | Null () |
static void | ShowToolTip (const Point &pos, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0)) |
static void | ShowToolTip (int x, int y, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0)) |
static String | ToolTipText () |
Static Public Member Functions inherited from pcl::UIObject | |
static UIObject & | Null () |
Protected Member Functions inherited from pcl::UIObject | |
UIObject ()=default | |
UIObject (const UIObject &x) | |
UIObject (UIObject &&x) | |
UIObject & | operator= (const UIObject &x) |
UIObject & | operator= (UIObject &&x) |
Definition at line 118 of file CodeEditor.h.
pcl::CodeEditor::CodeEditor | ( | Control & | parent = Control::Null() | ) |
Constructs a CodeEditor control.
parent | The parent control of this object. The default value is a null control. |
|
inlineoverride |
Destroys a CodeEditor control.
Definition at line 133 of file CodeEditor.h.
void pcl::CodeEditor::ClearMatches | ( | ) |
Clears all text highlightings. This function does not remove the highlighted text; it simply clears the visual highlight indications.
void pcl::CodeEditor::ClearText | ( | ) |
Clears all the text in this code editor. Also clears all undo/redo buffers, so this action is irreversible.
void pcl::CodeEditor::Copy | ( | ) |
Copies the current text selection to the clipboard. If no selection is defined, this function has no effect.
|
inline |
Returns the column number of the current cursor position.
Definition at line 400 of file CodeEditor.h.
|
inline |
Returns the line number of the current cursor position.
Definition at line 392 of file CodeEditor.h.
Point pcl::CodeEditor::CursorPosition | ( | ) | const |
Returns the current cursor position in visual coordinates. The returned object stores the current line and column of the cursor in its Point::y and Point::x public data members, respectively.
Line and column coordinates are counted from zero. Line numbers range from zero to the number of existing text lines minus one. There is no specific limit for the number of text characters in a text line.
void pcl::CodeEditor::Cut | ( | ) |
Copies the current text selection to the clipboard and removes the selected text. If no selection is defined, this function has no effect.
void pcl::CodeEditor::Delete | ( | ) |
Removes the currently selected text. If there is no text selection defined, this function has no effect.
Returns an encoded 8-bit representation of the text in this code editor.
encoding | The desired text encoding. Currently only the "UTF-8" and "ISO-8859-1" encodings are supported. The default value is "UTF-8". |
String pcl::CodeEditor::FilePath | ( | ) | const |
Returns the absolute file path associated with this code editor, or an empty string if this object has not been associated with a file.
Finds an occurrence of a literal text string or a regular expression.
toFind | The text or regular expression to search for, depending on the specified mode flags. |
mode | An OR'ed combination of flags to control the text find operation. Valid flags are enumerated in the pcl::FindMode namespace. |
Returns true iff a match was found.
bool pcl::CodeEditor::GotoMatchedParenthesis | ( | ) |
If the cursor points to a bracket or parenthesis character, look for a matching pair and move the cursor to the corresponding location.
Returns true iff a matching pair could be found. If there is no bracket or parenthesis at the current cursor location, or if a matched pair couldn't be found, this function returns false and the cursor is not moved.
bool pcl::CodeEditor::HasSelection | ( | ) | const |
Returns true iff this code editor has a text selection defined.
Highlights all occurrences of a literal text string or a regular expression.
toFind | The text or regular expression to search for, depending on the specified mode flags. |
mode | An OR'ed combination of flags to control the text find operation. Valid flags are enumerated in the pcl::FindMode namespace. |
The operation takes place on the whole text document, ignoring the FindMode::Backward and FindMode::SelectionOnly flags. Returns the number of matches found.
void pcl::CodeEditor::InsertText | ( | const String & | text | ) |
Inserts the specified text at the current cursor location.
If there is a selection defined, the selected text is replaced with the inserted text.
bool pcl::CodeEditor::IsBlockSelectionMode | ( | ) | const |
Returns true iff this code editor is in block selection mode; false if it is in line selection mode.
In block selection mode, the user can select rectangular areas of text across multiple text lines. In line selection mode, text selections can only include entire text lines except for the first and last lines in a selection. The line selection mode is always enabled by default.
bool pcl::CodeEditor::IsDynamicWordWrapMode | ( | ) | const |
Returns true iff this code editor is in dynamic word wrap mode.
In dynamic word wrap mode, long text lines extending beyond the visible width of the editor's viewport are automatically truncated and continued on successive editor lines, so that the user can always see the entire contents of all text lines, and a horizontal scroll bar is never shown.
When the dynamic word wrap mode is disabled, long text lines are never truncated and the editor shows a horizontal scroll bar when necessary. The dynamic word wrap mode is always disabled by default.
bool pcl::CodeEditor::IsInsertMode | ( | ) | const |
Returns true iff this code editor is in insert text mode. Returns false if the editor is in replace text mode.
In insert mode, newly generated text by direct user interaction is inserted at the current cursor location. In replace mode, newly generated text replaces existing characters starting at the current cursor location. The insert text mode is always enabled by default.
bool pcl::CodeEditor::IsReadOnly | ( | ) | const |
Returns true iff this code editor is in read-only mode. A read-only editor does not allow any command that can modify its text contents as a result of a direct user interaction. The text can only be changed programmatically for a read-only code editor.
Control& pcl::CodeEditor::LineNumbersControl | ( | ) |
Returns a reference to a line numbers control for this code editor.
A line numbers control provides a visual index of the text lines currently displayed by a code editor. Typically, a code editor and its line numbers control are packed side by side in a HorizontalSizer.
Reads an encoded 8-bit text file and loads it in this code editor.
filePath | Path to the source file. |
encoding | The text encoding. Currently only the "UTF-8" and "ISO-8859-1" encodings are supported. The default value is "UTF-8". |
Returns true if the file was successfully read; false in the event of error.
|
inline |
Reads a text file encoded in ISO 8859-1 format, and loads it in this code editor.
This is a convenience function, equivalent to:
Definition at line 361 of file CodeEditor.h.
|
inline |
Reads a text file encoded in UTF-8 format, and loads it in this code editor.
This is a convenience function, equivalent to:
Definition at line 348 of file CodeEditor.h.
int pcl::CodeEditor::NumberOfCharacters | ( | ) | const |
Returns the total number of characters in the current text of this code editor.
int pcl::CodeEditor::NumberOfLines | ( | ) | const |
Returns the number of text lines (including empty lines) in this code editor.
void pcl::CodeEditor::Paste | ( | ) |
Inserts the contents of the clipboard at the current cursor location. If the clipboard is empty, or if its contents cannot be converted to plain text, this function has no effect.
void pcl::CodeEditor::Redo | ( | ) |
Redoes the last editor action. If no action can be redone, this function has no effect.
int pcl::CodeEditor::RedoSteps | ( | ) | const |
Returns the number of redo steps available for this code editor.
int pcl::CodeEditor::ReplaceAll | ( | const String & | toFind, |
const String & | replaceWith, | ||
FindModes | mode | ||
) |
Replaces all occurrences of a literal text string or a regular expression with the specified text.
toFind | The text or regular expression to search for, depending on the specified mode flags. |
replaceWith | The text that will replace all matches found. Can be an empty string (to delete all matched occurrences). |
mode | An OR'ed combination of flags to control the text find and replace operation. Valid flags are enumerated in the pcl::FindMode namespace. |
Returns the number of matches found and replaced.
bool pcl::CodeEditor::ReplaceSelection | ( | const String & | replaceWith | ) |
Replaces the current selection with the specified text.
replaceWith | The text that will replace the current selection. Can be an empty string (to delete the current selection). |
If there is some text selected in this editor, this function returns true after performing the replacement operation. If there is no text currently selected, this function is ignored and false is returned.
Writes the text in this code editor to the specified file, encoded in an 8-bit format.
filePath | Path to the destination file. |
encoding | The desired text encoding. Currently only the "UTF-8" and "ISO-8859-1" encodings are supported. The default value is "UTF-8". |
Returns true if the file was successfully written; false in the event of error.
|
inline |
Writes the text in this code editor to the specified file, encoded in ISO 8859-1 format.
This is a convenience function, equivalent to:
Definition at line 321 of file CodeEditor.h.
|
inline |
Writes the text in this code editor to the specified file, encoded in UTF-8 format.
This is a convenience function, equivalent to:
Definition at line 308 of file CodeEditor.h.
void pcl::CodeEditor::SelectAll | ( | ) |
Selects all the text in this code editor.
String pcl::CodeEditor::SelectedText | ( | ) | const |
Returns the currently selected text in this code editor, or an empty string if this editor has no selection currently defined.
Rect pcl::CodeEditor::Selection | ( | ) | const |
Returns the visual coordinates of the current selection in this code editor. The selection coordinates are stored in the returned rectangle as follows:
void pcl::CodeEditor::SetBlockSelectionMode | ( | bool | blockMode = true | ) |
Enables the block selection mode for this code editor.
blockMode | Whether to enable the block selection mode (if true) or the line selection mode (if false). The default value is true. |
|
inline |
Sets the current cursor position in this code editor through the coordinates of a Point object. The new cursor line will be set to pos.y and the new cursor column to pos.x, respectively.
Definition at line 417 of file CodeEditor.h.
References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.
void pcl::CodeEditor::SetCursorPosition | ( | int | line, |
int | column | ||
) |
Sets the current cursor position in this code editor to the specified line and column. See CursorPosition() for more information on visual text coordinates.
void pcl::CodeEditor::SetDynamicWordWrapMode | ( | bool | wrapMode = true | ) |
Enables the dynamic word wrap mode for this code editor.
wrapMode | Whether to enable the dynamic word wrap mode. |
void pcl::CodeEditor::SetEncodedText | ( | const IsoString & | text, |
const IsoString & | encoding = "UTF-8" |
||
) |
Sets the current text in this code editor, encoded in an 8-bit format.
text | The encoded 8-bit text. |
encoding | The text encoding. Currently only the "UTF-8" and "ISO-8859-1" encodings are supported. The default value is "UTF-8". |
void pcl::CodeEditor::SetFilePath | ( | const String & | path | ) |
Sets the file path associated with this code editor.
If the specified path includes a file name suffix (also known as file name extension), the control will use it to identify a programming language to perform automatic syntax highlighting of the text in the editor. Currently the following file suffixes and source code languages are supported:
.js .jsh | JavaScript source files |
.scp | Command-line script files |
.cpp .h .cxx .hpp .hxx .c .cc | C/C++ source files |
.py | Python source files |
.xml .xhtml .html .xosm .xpsm (among others) | XML source files |
.pidoc | PixInsight documentation source files |
.pm .pmath | PixelMath source files |
Unrecognized (or absent) file suffixes effectively disable the automatic syntax highlighting feature. The default value of this parameter is an empty string.
void pcl::CodeEditor::SetInsertMode | ( | bool | insert = true | ) |
Enables the insert text mode for this code editor.
insert | Whether to enable the insert text mode (if true) or the replace text mode (if false). The default value is true. |
|
inline |
Enables the line selection mode for this code editor.
lineMode | Whether to enable the line selection mode (if true) or the block selection mode (if false). The default value is true. |
Definition at line 480 of file CodeEditor.h.
void pcl::CodeEditor::SetReadOnly | ( | bool | readOnly = true | ) |
Enables the read-only mode for this code editor. A read-only editor does not allow any command that can modify its text contents as a result of a direct user interaction. The text can only be changed programmatically for a read-only code editor.
readOnly | Whether to enable or disable the read-only mode for this code editor. |
|
inline |
Enables the replace text mode for this code editor.
replace | Whether to enable the replace text mode (if true) or the insert text mode (if false). The default value is true. |
Definition at line 447 of file CodeEditor.h.
|
inline |
Sets a new text selection defined by its visual coordinates.
This is a convenience function, equivalent to:
Definition at line 550 of file CodeEditor.h.
References pcl::GenericRectangle< T >::x0, pcl::GenericRectangle< T >::x1, pcl::GenericRectangle< T >::y0, and pcl::GenericRectangle< T >::y1.
void pcl::CodeEditor::SetSelection | ( | int | fromLine, |
int | fromCol, | ||
int | toLine, | ||
int | toCol | ||
) |
Sets a new text selection defined by its visual coordinates.
fromLine | Starting line of the new text selection. |
fromCol | Starting column of the new text selection. |
toLine | Ending line of the new text selection. |
toCol | Ending column of the new text selection. |
void pcl::CodeEditor::SetText | ( | const String & | text | ) |
Sets the current text in this code editor in UTF-16 format.
|
inline |
Sets the current text in this code editor, encoded in ISO 8859-1 format.
This is a convenience function, equivalent to:
Definition at line 251 of file CodeEditor.h.
|
inline |
Sets the current text in this code editor, encoded in UTF-8 format.
This is a convenience function, equivalent to:
Definition at line 239 of file CodeEditor.h.
String pcl::CodeEditor::Text | ( | ) | const |
Returns the current text in this code editor in UTF-16 format.
|
inline |
Returns the text in this code editor encoded in ISO 8859-1 format.
This is a convenience function, equivalent to:
Definition at line 216 of file CodeEditor.h.
|
inline |
Returns the text in this code editor encoded in UTF-8 format.
This is a convenience function, equivalent to:
Definition at line 204 of file CodeEditor.h.
void pcl::CodeEditor::Undo | ( | ) |
Undoes the last editor action. If no action can be undone, this function has no effect.
int pcl::CodeEditor::UndoSteps | ( | ) | const |
Returns the number of undo steps available for this code editor.
void pcl::CodeEditor::Unselect | ( | ) |
Clears the current text selection, if any. This function simply unselects the text; it does not remove the selected text.