PCL
pcl::CodeEditor Class Reference

Client-side interface to a PixInsight CodeEditor control. More...

#include <CodeEditor.h>

+ Inheritance diagram for pcl::CodeEditor:

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)
 

Public Member Functions

 CodeEditor (Control &parent=Control::Null())
 
 ~CodeEditor () override
 
void ClearMatches ()
 
void ClearText ()
 
void Copy ()
 
int CursorColumn () const
 
int CursorLine () const
 
Point CursorPosition () const
 
void Cut ()
 
void Delete ()
 
IsoString EncodedText (const IsoString &encoding="UTF-8") const
 
String FilePath () const
 
bool Find (const String &toFind, FindModes mode)
 
bool GotoMatchedParenthesis ()
 
bool HasSelection () const
 
int HighlightAllMatches (const String &toFind, FindModes mode)
 
void InsertText (const String &text)
 
bool IsBlockSelectionMode () const
 
bool IsDynamicWordWrapMode () const
 
bool IsInsertMode () const
 
bool IsReadOnly () const
 
ControlLineNumbersControl ()
 
bool Load (const String &filePath, const IsoString &encoding="UTF-8")
 
bool LoadISO88591 (const String &filePath)
 
bool LoadUTF8 (const String &filePath)
 
int NumberOfCharacters () const
 
int NumberOfLines () const
 
void OnCursorPositionUpdated (cursor_event_handler handler, Control &receiver)
 
void OnDynamicWordWrapModeUpdated (state_event_handler handler, Control &receiver)
 
void OnOverwriteModeUpdated (state_event_handler handler, Control &receiver)
 
void OnSelectionModeUpdated (state_event_handler handler, Control &receiver)
 
void OnSelectionUpdated (selection_event_handler handler, Control &receiver)
 
void OnTextUpdated (editor_event_handler handler, Control &receiver)
 
void Paste ()
 
void Redo ()
 
int RedoSteps () const
 
int ReplaceAll (const String &toFind, const String &replaceWith, FindModes mode)
 
bool ReplaceSelection (const String &replaceWith)
 
bool Save (const String &filePath, const IsoString &encoding="UTF-8")
 
bool SaveISO88591 (const String &filePath)
 
bool SaveUTF8 (const String &filePath)
 
void SelectAll ()
 
String SelectedText () const
 
Rect Selection () const
 
void SetBlockSelectionMode (bool blockMode=true)
 
void SetCursorPosition (const Point &pos)
 
void SetCursorPosition (int line, int column)
 
void SetDynamicWordWrapMode (bool wrapMode=true)
 
void SetEncodedText (const IsoString &text, const IsoString &encoding="UTF-8")
 
void SetFilePath (const String &path)
 
void SetInsertMode (bool insert=true)
 
void SetLineSelectionMode (bool lineMode=true)
 
void SetReadOnly (bool readOnly=true)
 
void SetReplaceMode (bool replace=true)
 
void SetSelection (const Rect &r)
 
void SetSelection (int fromLine, int fromCol, int toLine, int toCol)
 
void SetText (const String &text)
 
void SetTextISO88591 (const IsoString &text)
 
void SetTextUTF8 (const IsoString &text)
 
String Text () const
 
IsoString TextISO88591 () const
 
IsoString TextUTF8 () const
 
void Undo ()
 
int UndoSteps () const
 
void Unselect ()
 
- Public Member Functions inherited from pcl::Control
 Control (const Control &)=delete
 
 Control (Control &&)=delete
 
 Control (Control &parent=Null(), uint32=0)
 
 ~Control () override
 
void ActivateRealTimePreview ()
 
void ActivateTrackView ()
 
void ActivateWindow ()
 
void AdjustToContents ()
 
RGBA AlternateCanvasColor () const
 
RGBA BackgroundColor () const
 
pcl::Rect BoundsRect () const
 
void BringToFront ()
 
RGBA ButtonColor () const
 
RGBA ButtonTextColor () const
 
bool CanUpdate () const
 
RGBA CanvasColor ()
 
ControlChildByPos (const pcl::Point &p) const
 
ControlChildByPos (int x, int y) const
 
pcl::Rect ChildrenRect () const
 
ControlChildToFocus () const
 
void ClearInfoText ()
 
int ClientHeight () const
 
pcl::Rect ClientRect () const
 
int ClientWidth () const
 
void ControlToLocal (const Control &, int &x, int &y) const
 
pcl::Point ControlToLocal (const Control &w, const pcl::Point &p) const
 
pcl::Cursor Cursor () const
 
void DeactivateRealTimePreview ()
 
void DeactivateTrackView ()
 
void Disable (bool disabled=true)
 
void DisableExpansion (bool horzDisable=true, bool vertDisable=true)
 
void DisableMouseTracking (bool disable=true)
 
void DisableUpdates (bool disable=true)
 
double DisplayPixelRatio () const
 
virtual void Enable (bool enabled=true)
 
void EnableExpansion (bool horzEnable=true, bool vertEnable=true)
 
void EnableMouseTracking (bool=true)
 
void EnableUpdates (bool enable=true)
 
void EnsureLayoutUpdated ()
 
void EnsureUnique () override
 
void Focus (bool focus=true)
 
ControlFocusedChild () const
 
FocusStyles FocusStyle () const
 
pcl::Font Font () const
 
RGBA ForegroundColor () const
 
int FrameHeight () const
 
pcl::Rect FrameRect () const
 
int FrameWidth () const
 
pcl::Cursor GetCursor () const
 
pcl::Font GetFont () const
 
void GetMaxSize (int &w, int &h) const
 
void GetMinSize (int &w, int &h) const
 
void GetScaledMaxSize (int &w, int &h) const
 
void GetScaledMinSize (int &w, int &h) const
 
pcl::Sizer GetSizer () const
 
pcl::Point GlobalToLocal (const pcl::Point &p) const
 
void GlobalToLocal (int &x, int &y) const
 
int Height () const
 
void Hide ()
 
RGBA HighlightColor () const
 
RGBA HighlightedTextColor () const
 
String InfoText () const
 
bool IsActiveWindow () const
 
bool IsAncestorOf (const Control &) const
 
virtual bool IsEnabled () const
 
bool IsFixedHeight () const
 
bool IsFixedWidth () const
 
bool IsFocused () const
 
bool IsHidden () const
 
bool IsHorizontalExpansionEnabled () const
 
bool IsMaximized () const
 
bool IsMinimized () const
 
bool IsModal () const
 
bool IsMouseTrackingEnabled () const
 
bool IsRealTimePreviewActive () const
 
bool IsTrackViewActive () const
 
bool IsUnderMouse () const
 
bool IsVerticalExpansionEnabled () const
 
bool IsVisible () const
 
bool IsWindow () const
 
void LocalToControl (const Control &, int &x, int &y) const
 
pcl::Point LocalToControl (const Control &w, const pcl::Point &p) const
 
pcl::Point LocalToGlobal (const pcl::Point &p) const
 
void LocalToGlobal (int &x, int &y) const
 
pcl::Point LocalToParent (const pcl::Point &p) const
 
void LocalToParent (int &x, int &y) const
 
int LogicalPixelsToPhysical (int size) const
 
int LogicalPixelsToResource (int size) const
 
int MaxHeight () const
 
int MaxWidth () const
 
int MinHeight () const
 
int MinWidth () const
 
void Move (const pcl::Point &p)
 
void Move (int x, int y)
 
ControlNextSiblingToFocus () const
 
void OnChildCreate (child_event_handler, Control &)
 
void OnChildDestroy (child_event_handler, Control &)
 
void OnClose (close_event_handler, Control &)
 
void OnDestroy (event_handler, Control &)
 
void OnEnter (event_handler, Control &)
 
void OnFileDrag (file_drag_event_handler, Control &)
 
void OnFileDrop (file_drop_event_handler, Control &)
 
void OnGetFocus (event_handler, Control &)
 
void OnHide (event_handler, Control &)
 
void OnKeyPress (keyboard_event_handler, Control &)
 
void OnKeyRelease (keyboard_event_handler, Control &)
 
void OnLeave (event_handler, Control &)
 
void OnLoseFocus (event_handler, Control &)
 
void OnMouseDoubleClick (mouse_event_handler, Control &)
 
void OnMouseMove (mouse_event_handler, Control &)
 
void OnMousePress (mouse_button_event_handler, Control &)
 
void OnMouseRelease (mouse_button_event_handler, Control &)
 
void OnMouseWheel (mouse_wheel_event_handler, Control &)
 
void OnMove (move_event_handler, Control &)
 
void OnPaint (paint_event_handler, Control &)
 
void OnResize (resize_event_handler, Control &)
 
void OnShow (event_handler, Control &)
 
void OnViewDrag (view_drag_event_handler, Control &)
 
void OnViewDrop (view_drop_event_handler, Control &)
 
Controloperator= (const Control &)=delete
 
Controloperator= (Control &&)=delete
 
ControlParent () const
 
pcl::Point ParentToLocal (const pcl::Point &p) const
 
void ParentToLocal (int &x, int &y) const
 
int PhysicalPixelsToLogical (int size) const
 
pcl::Point Position () const
 
void Repaint ()
 
void Repaint (const pcl::Rect &r)
 
void Repaint (int x0, int y0, int x1, int y1)
 
void Resize (int w, int h)
 
double ResourcePixelRatio () const
 
int ResourcePixelsToLogical (int size) const
 
void Restyle ()
 
Point ScaledCursorHotSpot (const Point &hotSpot) const
 
Point ScaledCursorHotSpot (int xHot, int yHot) const
 
int ScaledMaxHeight () const
 
int ScaledMaxWidth () const
 
int ScaledMinHeight () const
 
int ScaledMinWidth () const
 
template<class R >
String ScaledResource (R resource) const
 
template<class S >
String ScaledStyleSheet (S cssCode, int fontDPI=0) const
 
void Scroll (const pcl::Point &d)
 
void Scroll (const pcl::Point &d, const pcl::Rect &r)
 
void Scroll (int dx, int dy)
 
void Scroll (int dx, int dy, int x0, int y0, int x1, int y1)
 
void SendToBack ()
 
void SetAlternateCanvasColor (RGBA)
 
void SetBackgroundColor (RGBA)
 
void SetButtonColor (RGBA)
 
void SetButtonTextColor (RGBA)
 
void SetCanvasColor (RGBA)
 
void SetChildToFocus (Control &)
 
void SetClientRect (const pcl::Rect &r)
 
void SetClientRect (int x0, int y0, int x1, int y1)
 
void SetCursor (const pcl::Cursor &)
 
void SetCursorToParent ()
 
void SetFixedHeight ()
 
void SetFixedHeight (int h)
 
void SetFixedSize ()
 
void SetFixedSize (int w, int h)
 
void SetFixedWidth ()
 
void SetFixedWidth (int w)
 
void SetFocusStyle (FocusStyles)
 
void SetFont (const pcl::Font &)
 
void SetForegroundColor (RGBA)
 
void SetHighlightColor (RGBA)
 
void SetHighlightedTextColor (RGBA)
 
void SetInfoText (const String &)
 
void SetMaxHeight ()
 
void SetMaxHeight (int h)
 
void SetMaxSize ()
 
void SetMaxSize (int w, int h)
 
void SetMaxWidth ()
 
void SetMaxWidth (int w)
 
void SetMinHeight ()
 
void SetMinHeight (int h)
 
void SetMinSize ()
 
void SetMinSize (int w, int h)
 
void SetMinWidth ()
 
void SetMinWidth (int w)
 
void SetNextSiblingToFocus (Control &)
 
void SetParent (Control &)
 
void SetRealTimePreviewActive (bool=true)
 
void SetScaledFixedHeight (int h)
 
void SetScaledFixedSize (int w, int h)
 
void SetScaledFixedWidth (int w)
 
void SetScaledMaxHeight (int h)
 
void SetScaledMaxSize (int w, int h)
 
void SetScaledMaxWidth (int w)
 
void SetScaledMinHeight (int h)
 
void SetScaledMinSize (int w, int h)
 
void SetScaledMinWidth (int w)
 
void SetSizer (pcl::Sizer &)
 
void SetStyleSheet (const String &css)
 
void SetTextColor (RGBA)
 
void SetToolTip (const String &)
 
void SetTrackViewActive (bool=true)
 
void SetVariableHeight ()
 
void SetVariableSize ()
 
void SetVariableWidth ()
 
void SetVisible (bool visible)
 
void SetWindowOpacity (double)
 
void SetWindowTitle (const String &)
 
void Show ()
 
pcl::Sizer Sizer () const
 
void StackUnder (Control &)
 
String StyleSheet () const
 
RGBA TextColor () const
 
String ToolTip () const
 
void Unfocus ()
 
void Update ()
 
void Update (const pcl::Rect &r)
 
void Update (int x0, int y0, int x1, int y1)
 
pcl::Rect VisibleRect () const
 
int Width () const
 
ControlWindow () const
 
double WindowOpacity () const
 
String WindowTitle () const
 
int X () const
 
int Y () const
 
- Public Member Functions inherited from pcl::UIObject
virtual ~UIObject () noexcept(false)
 
bool IsAlias () const
 
bool IsGarbage () const
 
bool IsNull () const
 
bool IsSameObject (const UIObject &o) const
 
bool IsUnique () const
 
String ObjectId () const
 
IsoString ObjectType () const
 
bool operator< (const UIObject &o) const
 
bool operator== (const UIObject &o) const
 
size_type RefCount () const
 
void SetObjectId (const String &id)
 

Additional Inherited Members

- Static Public Member Functions inherited from pcl::Control
static void HideToolTip ()
 
static ControlNull ()
 
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 UIObjectNull ()
 
- Protected Member Functions inherited from pcl::UIObject
 UIObject ()=default
 
 UIObject (const UIObject &x)
 
 UIObject (UIObject &&x)
 
UIObjectoperator= (const UIObject &x)
 
UIObjectoperator= (UIObject &&x)
 

Detailed Description

TODO: Write a detailed description for CodeEditor.

Definition at line 118 of file CodeEditor.h.

Constructor & Destructor Documentation

◆ CodeEditor()

pcl::CodeEditor::CodeEditor ( Control parent = Control::Null())

Constructs a CodeEditor control.

Parameters
parentThe parent control of this object. The default value is a null control.

◆ ~CodeEditor()

pcl::CodeEditor::~CodeEditor ( )
inlineoverride

Destroys a CodeEditor control.

Definition at line 133 of file CodeEditor.h.

Member Function Documentation

◆ ClearMatches()

void pcl::CodeEditor::ClearMatches ( )

Clears all text highlightings. This function does not remove the highlighted text; it simply clears the visual highlight indications.

◆ ClearText()

void pcl::CodeEditor::ClearText ( )

Clears all the text in this code editor. Also clears all undo/redo buffers, so this action is irreversible.

◆ Copy()

void pcl::CodeEditor::Copy ( )

Copies the current text selection to the clipboard. If no selection is defined, this function has no effect.

◆ CursorColumn()

int pcl::CodeEditor::CursorColumn ( ) const
inline

Returns the column number of the current cursor position.

Definition at line 400 of file CodeEditor.h.

◆ CursorLine()

int pcl::CodeEditor::CursorLine ( ) const
inline

Returns the line number of the current cursor position.

Definition at line 392 of file CodeEditor.h.

◆ CursorPosition()

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.

◆ Cut()

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.

◆ Delete()

void pcl::CodeEditor::Delete ( )

Removes the currently selected text. If there is no text selection defined, this function has no effect.

◆ EncodedText()

IsoString pcl::CodeEditor::EncodedText ( const IsoString encoding = "UTF-8") const

Returns an encoded 8-bit representation of the text in this code editor.

Parameters
encodingThe desired text encoding. Currently only the "UTF-8" and "ISO-8859-1" encodings are supported. The default value is "UTF-8".

◆ FilePath()

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.

◆ Find()

bool pcl::CodeEditor::Find ( const String toFind,
FindModes  mode 
)

Finds an occurrence of a literal text string or a regular expression.

Parameters
toFindThe text or regular expression to search for, depending on the specified mode flags.
modeAn 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.

◆ GotoMatchedParenthesis()

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.

◆ HasSelection()

bool pcl::CodeEditor::HasSelection ( ) const

Returns true iff this code editor has a text selection defined.

◆ HighlightAllMatches()

int pcl::CodeEditor::HighlightAllMatches ( const String toFind,
FindModes  mode 
)

Highlights all occurrences of a literal text string or a regular expression.

Parameters
toFindThe text or regular expression to search for, depending on the specified mode flags.
modeAn 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.

◆ InsertText()

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.

◆ IsBlockSelectionMode()

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.

◆ IsDynamicWordWrapMode()

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.

◆ IsInsertMode()

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.

◆ IsReadOnly()

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.

◆ LineNumbersControl()

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.

◆ Load()

bool pcl::CodeEditor::Load ( const String filePath,
const IsoString encoding = "UTF-8" 
)

Reads an encoded 8-bit text file and loads it in this code editor.

Parameters
filePathPath to the source file.
encodingThe 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.

◆ LoadISO88591()

bool pcl::CodeEditor::LoadISO88591 ( const String filePath)
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:

Load( filePath, "ISO-8859-1" );
bool Load(const String &filePath, const IsoString &encoding="UTF-8")

Definition at line 361 of file CodeEditor.h.

◆ LoadUTF8()

bool pcl::CodeEditor::LoadUTF8 ( const String filePath)
inline

Reads a text file encoded in UTF-8 format, and loads it in this code editor.

This is a convenience function, equivalent to:

Load( filePath, "UTF-8" );

Definition at line 348 of file CodeEditor.h.

◆ NumberOfCharacters()

int pcl::CodeEditor::NumberOfCharacters ( ) const

Returns the total number of characters in the current text of this code editor.

◆ NumberOfLines()

int pcl::CodeEditor::NumberOfLines ( ) const

Returns the number of text lines (including empty lines) in this code editor.

◆ Paste()

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.

◆ Redo()

void pcl::CodeEditor::Redo ( )

Redoes the last editor action. If no action can be redone, this function has no effect.

◆ RedoSteps()

int pcl::CodeEditor::RedoSteps ( ) const

Returns the number of redo steps available for this code editor.

◆ ReplaceAll()

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.

Parameters
toFindThe text or regular expression to search for, depending on the specified mode flags.
replaceWithThe text that will replace all matches found. Can be an empty string (to delete all matched occurrences).
modeAn 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.

◆ ReplaceSelection()

bool pcl::CodeEditor::ReplaceSelection ( const String replaceWith)

Replaces the current selection with the specified text.

Parameters
replaceWithThe 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.

◆ Save()

bool pcl::CodeEditor::Save ( const String filePath,
const IsoString encoding = "UTF-8" 
)

Writes the text in this code editor to the specified file, encoded in an 8-bit format.

Parameters
filePathPath to the destination file.
encodingThe 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.

Warning
Upon successful completion, this function will overwrite an existing file at the specified path, whose previous contents will be lost.

◆ SaveISO88591()

bool pcl::CodeEditor::SaveISO88591 ( const String filePath)
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:

Save( filePath, "ISO-8859-1" );
bool Save(const String &filePath, const IsoString &encoding="UTF-8")

Definition at line 321 of file CodeEditor.h.

◆ SaveUTF8()

bool pcl::CodeEditor::SaveUTF8 ( const String filePath)
inline

Writes the text in this code editor to the specified file, encoded in UTF-8 format.

This is a convenience function, equivalent to:

Save( filePath, "UTF-8" );

Definition at line 308 of file CodeEditor.h.

◆ SelectAll()

void pcl::CodeEditor::SelectAll ( )

Selects all the text in this code editor.

◆ SelectedText()

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.

◆ Selection()

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:

  • Rect::y0 - Starting line of the current text selection.
  • Rect::x0 - Starting column of the current text selection.
  • Rect::y1 - Ending line of the current text selection.
  • Rect::x1 - Ending column of the current text selection.

◆ SetBlockSelectionMode()

void pcl::CodeEditor::SetBlockSelectionMode ( bool  blockMode = true)

Enables the block selection mode for this code editor.

Parameters
blockModeWhether to enable the block selection mode (if true) or the line selection mode (if false). The default value is true.

◆ SetCursorPosition() [1/2]

void pcl::CodeEditor::SetCursorPosition ( const Point pos)
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.

◆ SetCursorPosition() [2/2]

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.

◆ SetDynamicWordWrapMode()

void pcl::CodeEditor::SetDynamicWordWrapMode ( bool  wrapMode = true)

Enables the dynamic word wrap mode for this code editor.

Parameters
wrapModeWhether to enable the dynamic word wrap mode.

◆ SetEncodedText()

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.

Parameters
textThe encoded 8-bit text.
encodingThe text encoding. Currently only the "UTF-8" and "ISO-8859-1" encodings are supported. The default value is "UTF-8".

◆ SetFilePath()

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.

◆ SetInsertMode()

void pcl::CodeEditor::SetInsertMode ( bool  insert = true)

Enables the insert text mode for this code editor.

Parameters
insertWhether to enable the insert text mode (if true) or the replace text mode (if false). The default value is true.

◆ SetLineSelectionMode()

void pcl::CodeEditor::SetLineSelectionMode ( bool  lineMode = true)
inline

Enables the line selection mode for this code editor.

Parameters
lineModeWhether 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.

◆ SetReadOnly()

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.

Parameters
readOnlyWhether to enable or disable the read-only mode for this code editor.

◆ SetReplaceMode()

void pcl::CodeEditor::SetReplaceMode ( bool  replace = true)
inline

Enables the replace text mode for this code editor.

Parameters
replaceWhether 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.

◆ SetSelection() [1/2]

void pcl::CodeEditor::SetSelection ( const Rect r)
inline

Sets a new text selection defined by its visual coordinates.

This is a convenience function, equivalent to:

SetSelection( r.y0, r.x0, r.y1, r.x1 );
void SetSelection(int fromLine, int fromCol, int toLine, int toCol)

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.

◆ SetSelection() [2/2]

void pcl::CodeEditor::SetSelection ( int  fromLine,
int  fromCol,
int  toLine,
int  toCol 
)

Sets a new text selection defined by its visual coordinates.

Parameters
fromLineStarting line of the new text selection.
fromColStarting column of the new text selection.
toLineEnding line of the new text selection.
toColEnding column of the new text selection.

◆ SetText()

void pcl::CodeEditor::SetText ( const String text)

Sets the current text in this code editor in UTF-16 format.

◆ SetTextISO88591()

void pcl::CodeEditor::SetTextISO88591 ( const IsoString text)
inline

Sets the current text in this code editor, encoded in ISO 8859-1 format.

This is a convenience function, equivalent to:

SetEncodedText( text, "ISO-8859-1" );
void SetEncodedText(const IsoString &text, const IsoString &encoding="UTF-8")

Definition at line 251 of file CodeEditor.h.

◆ SetTextUTF8()

void pcl::CodeEditor::SetTextUTF8 ( const IsoString text)
inline

Sets the current text in this code editor, encoded in UTF-8 format.

This is a convenience function, equivalent to:

SetEncodedText( text, "UTF-8" );

Definition at line 239 of file CodeEditor.h.

◆ Text()

String pcl::CodeEditor::Text ( ) const

Returns the current text in this code editor in UTF-16 format.

◆ TextISO88591()

IsoString pcl::CodeEditor::TextISO88591 ( ) const
inline

Returns the text in this code editor encoded in ISO 8859-1 format.

This is a convenience function, equivalent to:

EncodedText( "ISO-8859-1" );
IsoString EncodedText(const IsoString &encoding="UTF-8") const

Definition at line 216 of file CodeEditor.h.

◆ TextUTF8()

IsoString pcl::CodeEditor::TextUTF8 ( ) const
inline

Returns the text in this code editor encoded in UTF-8 format.

This is a convenience function, equivalent to:

EncodedText( "UTF-8" );

Definition at line 204 of file CodeEditor.h.

◆ Undo()

void pcl::CodeEditor::Undo ( )

Undoes the last editor action. If no action can be undone, this function has no effect.

◆ UndoSteps()

int pcl::CodeEditor::UndoSteps ( ) const

Returns the number of undo steps available for this code editor.

◆ Unselect()

void pcl::CodeEditor::Unselect ( )

Clears the current text selection, if any. This function simply unselects the text; it does not remove the selected text.


The documentation for this class was generated from the following file: