Rogue Wave Views
Gadgets Package API Reference Guide
Product Documentation:

Rogue Wave Views
Documentation Home
List of all members | Classes | Public Member Functions
IlvCodeEditor Class Reference

This class allows the edition of text contents with editing features and syntax coloring, autoindent, undo/redo etc... More...

#include <ilviews/gadgets/codeedit.h>

Inheritance diagram for IlvCodeEditor:
IlvScrolledGadget IlvGadget IlvSimpleGraphic IlvStylable IlvGraphic IlvValueInterface IlvDebuggerEditor

Classes

class  Binding
 Holds the key binding for the commands of a Code Editor . More...
 
class  CommandPerformedObserver
 This observer is notified when a command was executed in a Code Editor. More...
 
class  ContentChangedObserver
 This observer is notified when the content of a Code Editor is modified, or when the read-only state of the Code Editor is changed. More...
 
class  CursorMovedObserver
 This observer is notified when the location of the cursor of a Code Editor is modified. More...
 
class  Location
 The position of a logical character in the text managed by an IlvCodeEditor. More...
 
class  Observer
 Observers receive notifications when commands impact the Code Editor. More...
 
class  Parser
 A Parser can read the text content of a CodeEditor and decorate it. More...
 
class  SelectionChangedObserver
 This observer is notified when the selected area of a Code Editor is changed. More...
 
class  StyleSheet
 A style sheet is a container with several styles that holds palettes for the decorations and options like syntax highlighting, auto-indent mode, brace highlighting, tabulations shown has blank characters. More...
 
class  Trigger
 Triggers are invoked when a Code Editor handles key events that trigger actions that must be implemented on the application side. More...
 

Public Member Functions

 IlvCodeEditor (IlvDisplay *display, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, Binding::Mode mode=Binding::MSVCMode, StyleSheet *sheet=0)
 Constructor. More...
 
 IlvCodeEditor (IlvDisplay *display, const IlvRect &rect, const char *text, IlUShort thickness, StyleSheet *sheet, IlvDim marginWidth, Binding::Mode mode, Parser *parser=0)
 Constructor. More...
 
void adjustFromScrollBar (const IlvScrollBar *sb, IlvDirection dir)
 Is called to adjust the gadget to the scroll bars values. More...
 
void adjustScrollBarValue (IlvScrollBar *sb, IlvDirection dir)
 Is called to adjust the scroll bar values. More...
 
void appendText (const char *text)
 Appends the given text to the buffer. More...
 
IlBoolean appendToClipBoard ()
 Appends the current selection to the clipboard. More...
 
void blockUndoRedo ()
 Inhibits the undo/redo feature. More...
 
IlBoolean braceHighLight () const
 Tells if brace matching highlighting is activated. More...
 
IlInt breakLine (IlBoolean autoIndent)
 Breaks a line at the current cursor position. More...
 
IlBoolean centerOnCurrentLine ()
 Scrolls as needed to place the current line at the center of the editor view. More...
 
void clearEditSignal ()
 Sets the edition signal to IlFalse.
 
IlBoolean commentRegion ()
 Inserts a mono-line comment in the text. More...
 
IlBoolean completeWord ()
 Tries to complete the word preceding the cursor. More...
 
char * concatText (const Location &begin, const Location &end, IlBoolean tabAsBlanks) const
 Concatenates the text between two locations. More...
 
IlBoolean copyToClipBoard () const
 Copies the current selection to the clipboard. More...
 
IlBoolean cutLineToClipBoard ()
 Executes a partial cut from cursor to end of line and puts it into the clipboard. More...
 
IlBoolean cutToClipBoard ()
 Cuts the current selection to the clipboard. More...
 
virtual void drawGadgetContents (IlvPort *dst, const IlvTransformer *t=0, const IlvRegion *clip=0) const
 Draws the gadget contents. More...
 
IlBoolean find (IlBoolean forwardDir, IlBoolean limited, IlBoolean caseSensitive, IlBoolean wholeWord, const char *pattern, Location from, Location to, IlBoolean s=IlTrue)
 Finds the first occurence of the specified pattern from the current cursor position. More...
 
IlInt getCursorColumn () const
 Returns the column where the cursor is located. More...
 
IlInt getCursorLine () const
 Returns the index of the line where the cursor is located. More...
 
const LocationgetCursorLocation () const
 Returns the location of the cursor.
 
void getRedoCommandLabel (IlString &l) const
 Returns in its argument the label of the last redoable command. More...
 
char * getSelection () const
 Retrieves the text from the current selection. More...
 
void getSelection (Location &from, Location &to) const
 Returns the start and end locations of the current selection.
 
Location getSelectionEnd () const
 Returns the location of the end of the current selection. More...
 
IlInt getSelectionEndColumn () const
 Returns the index of the last column of the current selection. More...
 
IlInt getSelectionEndLine () const
 Returns the index of the last line of the current selection. More...
 
Location getSelectionStart () const
 Returns the location of the start of the current selection. More...
 
IlInt getSelectionStartColumn () const
 Returns the index of the first column of the current selection. More...
 
IlInt getSelectionStartLine () const
 Returns the index of the first line of the current selection. More...
 
char * getText (IlBoolean blanks)
 Gets the text from the buffer. More...
 
void getUndoCommandLabel (IlString &l) const
 Returns in its argument the label of the last undoable command. More...
 
void gotoEnd ()
 Moves the cursor to the end of the buffer. More...
 
IlBoolean gotoLine (IlInt line)
 Moves the cursor to the given line. More...
 
virtual IlBoolean handleGadgetEvent (IlvEvent &event)
 Handles the gadget events. More...
 
virtual IlBoolean handleScrollBarsEvent (IlvEvent &event)
 Handles the internal scroll bars event. More...
 
IlBoolean hasSelection () const
 Tells whether there is an active selection or not. More...
 
IlInt indentLine (IlInt line)
 indents the specified line. More...
 
IlInt insertCharacter (char key, IlBoolean bckIndent=IlTrue)
 Inserts the given charater at the current cursor location. More...
 
IlInt insertTabulation ()
 Inserts a tabulation at the current cursor location. More...
 
void insertText (const char *text, IlInt line, IlInt column, IlBoolean reDraw=IlFalse)
 Inserts the given text at the given location. More...
 
Location insertText (const char *text, const Location &at, IlBoolean reDraw=IlFalse)
 Concatenates the text between two locations. More...
 
void insertTextReversible (const char *text, IlInt line, IlInt column, IlBoolean reDraw)
 Inserts the given text at the given location. More...
 
IlBoolean isBlockCloser (char character) const
 tells if the given charater is a block closer. More...
 
IlBoolean isMultilineSelection () const
 Indicates if the current selection spans several lines. More...
 
IlBoolean isReadOnly () const
 Returns the editor read-only state. More...
 
IlBoolean isRedoable () const
 Tells if the redo feature is usable. More...
 
IlBoolean isSaveNeeded () const
 Tells if the buffer has been changed. More...
 
IlBoolean isTabulation (const Location &l) const
 Tells if the character at location is a tabulation. More...
 
IlBoolean isUndoable () const
 Tells if the undo feature is usable. More...
 
IlBoolean killComment ()
 Removes a mono-line comment in the text. More...
 
IlBoolean loadFile (const IlPathName &filePath, IlBoolean redraw=IlTrue)
 Loads text from given file into the buffer. More...
 
void loadText (const char *text)
 Loads the given text into the buffer. More...
 
IlBoolean pasteFromClipBoard ()
 Pastes the clipboard contents replacing the current selection if any. More...
 
void propagateSheet (const StyleSheet *s=0)
 Propagates style sheet modifications. More...
 
IlBoolean redo ()
 Replays the last undone command. More...
 
void removeMarker (IlvCEdtMarker &marker, IlInt line)
 Removes a marker from the margin of a line. More...
 
void removeMarkers (IlInt line=-1)
 Removes all markers from the margin of a given line or all lines. More...
 
void removeOneLogicalCharacter ()
 Removes one logical character just before the cursor. More...
 
char * removeText (const Location &start, const Location &end, IlBoolean retStr=IlTrue)
 Removes the text and the lines between two locations. More...
 
void replaceSelection (const char *replacement, IlBoolean autoRedraw, IlBoolean forwardDir)
 Replaces the selected text by the new value. More...
 
void resetAll ()
 Empties the buffer and releases the internal memory.
 
void resetSaveNeeded ()
 Resets the buffer changed indicator. More...
 
virtual void scrollableSize (IlvDim &w, IlvDim &h) const
 Returns the size of the scrollable area of the gadget. More...
 
IlBoolean selectAll ()
 Selects all text from the buffer. More...
 
void setCursorLocation (const Location &loc)
 Sets the location of the cursor.
 
void setCursorLocation (IlInt line, IlInt column)
 Moves the cursor to the location given by its arguments. More...
 
void setEditable (IlBoolean mode)
 Sets the editor to be editable or read-only. More...
 
void setFindTrigger (Trigger *trigger)
 Sets the Find trigger. More...
 
void setGotoTrigger (Trigger *trigger)
 Sets the Goto trigger. More...
 
void setKillBufferTrigger (Trigger *trigger)
 Sets the Kill Buffer trigger. More...
 
void setLine (IlInt line, const char *text)
 Replaces the text at line by the new value. More...
 
IlBoolean setMark ()
 Sets the selection mark. More...
 
void setMarker (IlvCEdtMarker &marker, IlInt line)
 Adds a marker to the margin of a line. More...
 
void setOpenTrigger (Trigger *trigger)
 Sets the Open trigger. More...
 
void setQuitTrigger (Trigger *trigger)
 Sets the Quit trigger. More...
 
void setReadOnlyTrigger (Trigger *trigger)
 Sets the Read Only trigger. More...
 
void setReplaceTrigger (Trigger *trigger)
 Sets the Replace trigger. More...
 
void setSaveAllTrigger (Trigger *trigger)
 Sets the Save All trigger. More...
 
void setSaveAsTrigger (Trigger *trigger)
 Sets the Save As trigger. More...
 
void setSaveTrigger (Trigger *trigger)
 Sets the Save trigger. More...
 
IlBoolean setSelection (IlInt startOffset, IlInt endOffset)
 Selects part of the text on current line. More...
 
void setSwitchBufferTrigger (Trigger *trigger)
 Sets the Switch Buffer trigger. More...
 
void setText (const char *text)
 Loads the given text into the buffer. More...
 
void stopBraceHighLighting ()
 Inhibits the brace matching highlight feature.
 
IlBoolean syntaxHighLight () const
 Tells if syntax highlighting is activated. More...
 
IlBoolean undo ()
 Reverses the effects of the last run command. More...
 
IlInt unindentLine (IlInt line)
 Outdents the specified line. More...
 
void unsetMark ()
 Removes the selection mark. More...
 
- Public Member Functions inherited from IlvScrolledGadget
 IlvScrolledGadget (IlvDisplay *display, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
virtual void adjustScrollBars (IlBoolean redraw=IlFalse)
 Recomputes the scroll bars. More...
 
void computeBBox (IlvRect &ibox, IlvRect &vs, IlvRect &hs, const IlvTransformer *t=0) const
 Computes the bounding boxes of the elements that compose the gadget. More...
 
void computeBBox (IlvRect &ibox, IlvRect &vbox, IlvRect &vs, IlvRect &hs, const IlvTransformer *t=0) const
 Computes the bounding boxes of the elements that compose the gadget. More...
 
virtual IlvScrollBarcreateScrollBar (const IlvRect &rect, IlvDirection direction, IlUShort thickness, IlvPalette *palette)
 Returns a new instance of the IlvScrollBar class. More...
 
virtual void drawBackground (IlvPort *dst, const IlvTransformer *t=0, const IlvRegion *clip=0) const
 Draws the gadget background. More...
 
virtual void drawFrame (IlvPort *dst, const IlvTransformer *t=0, const IlvRegion *clip=0) const
 Draws the gadget frame. More...
 
virtual void drawScrollBar (IlvPort *dst, IlvDirection direction, const IlvTransformer *t=0, const IlvRegion *clip=0) const
 Draws the specified internal scroll bar. More...
 
void fitToRect (const IlvRect &rect)
 Resizes the object so that the scrollable area fits the specified rectangle. More...
 
IlUShort getBottomMargin () const
 Returns the bottom margin. More...
 
IlvScrollBargetHorizontalScrollBar () const
 Returns a pointer to the internal horizontal scroll bar. More...
 
IlUShort getLeftMargin () const
 Returns the left margin. More...
 
IlUShort getRightMargin () const
 Returns the right margin. More...
 
IlvScrollBargetScrollBar (IlvDirection direction) const
 Returns a pointer to the specified internal scroll bar. More...
 
void getScrollBarShowAsNeeded (IlBoolean &vert, IlBoolean &hor) const
 Returns the scroll bar mode of the internal scroll bars. More...
 
IlUShort getTopMargin () const
 Returns the top margin. More...
 
IlvScrollBargetVerticalScrollBar () const
 Returns a pointer to the internal vertical scroll bar. More...
 
void hideScrollBar (IlvDirection direction, IlBoolean redraw=IlTrue)
 Hides the specified internal scroll bar. More...
 
virtual void internalBBox (IlvRect &bbox, const IlvTransformer *t=0) const
 Returns the internal bounding box of the gadget. More...
 
void moveScrollBar (IlvDirection direction, IlvPosition where, IlBoolean redraw=IlTrue)
 Moves the specified internal scroll bar to a new position. More...
 
virtual void scrollBarBBox (IlvDirection direction, IlvRect &bbox, const IlvTransformer *t=0) const
 Returns the bounding box of the specified internal scroll bar. More...
 
virtual void scrollBarHasMoved (IlvDirection direction)
 Is called when an internal scroll bar has moved. More...
 
void scrollBarShowAsNeeded (IlBoolean vertical, IlBoolean horizontal, IlBoolean redraw=IlTrue)
 Sets the scroll bar mode of the internal scroll bars. More...
 
virtual void scrollBarVisibilityChanged (IlvDirection direction)
 Is called when an internal scroll bar is shown or hidden. More...
 
void setBottomMargin (IlUShort margin)
 Sets the bottom margin. More...
 
void setLeftMargin (IlUShort margin)
 Sets the left margin. More...
 
void setMargin (IlUShort val)
 Sets the left, right, top, and bottom margins. More...
 
void setRightMargin (IlUShort margin)
 Sets the right margin. More...
 
void setTopMargin (IlUShort margin)
 Sets the top margin. More...
 
void showScrollBar (IlvDirection direction, IlBoolean redraw=IlTrue)
 Shows the specified internal scroll bar. More...
 
virtual void visibleBBox (IlvRect &bbox, const IlvTransformer *t=0) const
 Returns the visible bounding box of the gadget. More...
 
IlvPosition whereIsScrollBar (IlvDirection direction) const
 Returns the location of the specified internal scroll bar. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IlvScrolledGadget
static IlSymbolScrollBarMovedSymbol ()
 Returns the callback type for the Scroll Bar Moved callback. More...
 
static IlSymbolScrollBarVisibilitySymbol ()
 Returns the callback type for the Scroll Bar Visibility Changed callback. More...
 
- Protected Member Functions inherited from IlvScrolledGadget
IlvDim getLimitHeightValue () const
 Returns the limit value for the vertical scrolling. More...
 
IlvDim getLimitWidthValue () const
 Returns the limit value for the horizontal scrolling. More...
 
IlvDim getScrollableHeight () const
 Returns the height of the scrollable area. More...
 
IlvDim getScrollableWidth () const
 Returns the width of the scrollable area. More...
 
void setLimitHeightValue (IlvDim value)
 Sets the limit value for the vertical scrolling. More...
 
void setLimitWidthValue (IlvDim value)
 Sets the limit value for the horizontal scrolling. More...
 
void setScrollableHeight (IlvDim height)
 Sets the height of the scrollable area. More...
 
void setScrollableWidth (IlvDim width)
 Sets the width of the scrollable area. More...
 

Detailed Description

This class allows the edition of text contents with editing features and syntax coloring, autoindent, undo/redo etc...

Library: ilvadvgdt

It uses a series of Line objects as a fundamental data structure for representing source code.

It delegates to the lines the drawing. The lines themselves delegate to their margin and to their decorators the corresponding drawing actions. Most of the interactions (handleGadgetEvent()) are encapsulated in an IlvCodeEditor::Binding derived class, which is a kind of interactor, so that it is possible to switch at runtime between MSVC-like and EMACS-like key binding modes.

When a file is loaded and its extension has been associated to a parser with Parser::associate(), it uses this Parser for syntax coloring, autoindentation and word selection/navigation features. It delegates to the parser the decorator instantiation for each line of text.

It uses an StyleSheet as a style sheet for coloration, and tabulation size.

The undo and redo chain management is delegated to an instance of the CommandProcessor class. The instance is implicitly created when the editor is build. The command processor, in turn, implicitly creates a command factory.

An instance of this class knows when to notify observers for enabling/disabling outside menu items, buttons, modifier indicators, etc...

It manages a list of syntax error lines and allows to add markers in the margin.

It also has a mechanism for keyword online help.

Warning
[Limitations]
  • Only one font for the entire text.
  • No word-wrapping.
  • If "tabulation as blanks" is set to IlFalse then the tab stops calculation does not occur, resulting in fixed size tabulations.

Constructor & Destructor Documentation

§ IlvCodeEditor() [1/2]

IlvCodeEditor::IlvCodeEditor ( IlvDisplay display,
const IlvRect rect,
IlUShort  thickness = IlvDefaultGadgetThickness,
Binding::Mode  mode = Binding::MSVCMode,
StyleSheet sheet = 0 
)

Constructor.

Initializes a new empty Code Editor.

Parameters
displaythe display to attach to.
rectthe bounding box for the editor.
thicknessthe editor border thickness.
modethe editor key binding mode
sheetthe style sheet to use.

§ IlvCodeEditor() [2/2]

IlvCodeEditor::IlvCodeEditor ( IlvDisplay display,
const IlvRect rect,
const char *  text,
IlUShort  thickness,
StyleSheet sheet,
IlvDim  marginWidth,
Binding::Mode  mode,
Parser parser = 0 
)

Constructor.

Initializes a new Code Editor for the given style sheet, text, and parser.

The given text is split into lines, at the EoL characters. It is always copied.

Parameters
displaythe display to attach to.
rectthe bounding box for the editor.
textthe text to insert in the editor and colorize .
thicknessthe editor border thickness.
sheetthe style sheet to use.
marginWidththe width of the margin, set on one side.
modethe editor key binding mode
parserthe parser to scan the text

Member Function Documentation

§ adjustFromScrollBar()

void IlvCodeEditor::adjustFromScrollBar ( const IlvScrollBar scrollbar,
IlvDirection  direction 
)
virtual

Is called to adjust the gadget to the scroll bars values.

Is called each time the scroll bar scrollbar of direction direction moves. If you want to detect these events, you must redefine this member function in a subclass. The default implementation does nothing.

Parameters
scrollbarThe scroll bar object.
directionThe direction of the scroll bar. Valid values are: IlvHorizontal and IlvVertical.
See also
adjustScrollBarValue().

Reimplemented from IlvScrolledGadget.

§ adjustScrollBarValue()

void IlvCodeEditor::adjustScrollBarValue ( IlvScrollBar scrollbar,
IlvDirection  direction 
)
virtual

Is called to adjust the scroll bar values.

Is called by the member function adjustScrollBars() to adjust the values of the scroll bar scrollbar of direction direction. This member function must modify the scrollbar values to match the gadget scrolling mode. If you want to detect these events, you must redefine this member function in a subclass. The default implementation does nothing.

Parameters
scrollbarThe scroll bar object.
directionThe direction of the scroll bar. Valid values are: IlvHorizontal and IlvVertical.
See also
adjustFromScrollBar().

Reimplemented from IlvScrolledGadget.

§ appendText()

void IlvCodeEditor::appendText ( const char *  text)

Appends the given text to the buffer.

Parameters
textThe text to append.

§ appendToClipBoard()

IlBoolean IlvCodeEditor::appendToClipBoard ( )

Appends the current selection to the clipboard.

Returns
IlTrue if the selection was added to the clipboard; IlFalse if there is no current selection.

§ blockUndoRedo()

void IlvCodeEditor::blockUndoRedo ( )

Inhibits the undo/redo feature.

This function delegates the actual processing to the command processor.

§ braceHighLight()

IlBoolean IlvCodeEditor::braceHighLight ( ) const

Tells if brace matching highlighting is activated.

Returns
IlTrue if the brace matching highlighting feature is enabled.

§ breakLine()

IlInt IlvCodeEditor::breakLine ( IlBoolean  autoIndent)

Breaks a line at the current cursor position.

Parameters
autoIndentset the possibility to automatically indent the new line.
Returns
The indentation made.

§ centerOnCurrentLine()

IlBoolean IlvCodeEditor::centerOnCurrentLine ( )

Scrolls as needed to place the current line at the center of the editor view.

Returns
The result of the scrolling operation.

§ commentRegion()

IlBoolean IlvCodeEditor::commentRegion ( )

Inserts a mono-line comment in the text.

The comment is inserted at the cursor line.

§ completeWord()

IlBoolean IlvCodeEditor::completeWord ( )

Tries to complete the word preceding the cursor.

If a potential completion is found, it is inserted after the cursor location.

Returns
IlTrue if the command processor succeeded; IlFalse if there is no current selection.
Note
This action is undoable.

§ concatText()

char* IlvCodeEditor::concatText ( const Location begin,
const Location end,
IlBoolean  tabAsBlanks 
) const

Concatenates the text between two locations.

Parameters
beginthe start location.
endthe end location.
tabAsBlanksshould tabs be converted to blank charaters.
Returns
The concatenated text with line breaks inserted.

It is the caller responsibility to destroy the returned value.

§ copyToClipBoard()

IlBoolean IlvCodeEditor::copyToClipBoard ( ) const

Copies the current selection to the clipboard.

Returns
IlTrue if the selection was put to the clipboard; IlFalse if there is no current selection.

§ cutLineToClipBoard()

IlBoolean IlvCodeEditor::cutLineToClipBoard ( )

Executes a partial cut from cursor to end of line and puts it into the clipboard.

Returns
IlTrue if the command processor succeeded; IlFalse if the cursor is not in a valid location.
Note
  • This action is undoable.
  • There is a cumulative effect when a series of cut are made successively.
  • It's processing is similar to the Emacs one: that is the line end is not cut on first occurence but only when it is the only character after the cursor.

§ cutToClipBoard()

IlBoolean IlvCodeEditor::cutToClipBoard ( )

Cuts the current selection to the clipboard.

Returns
IlTrue if the command processor succeeded; IlFalse if there is no current selection.
Note
This action cannot be undone.

§ drawGadgetContents()

virtual void IlvCodeEditor::drawGadgetContents ( IlvPort dst,
const IlvTransformer t = 0,
const IlvRegion clip = 0 
) const
virtual

Draws the gadget contents.

Is called from the draw() method. The default implementation does nothing.

Parameters
dstThe destination drawing port.
tThe transformer applied to the gadget.
clipThe clipping area.
See also
drawBackground(), drawScrollBar(), drawFrame().

Reimplemented from IlvScrolledGadget.

§ find()

IlBoolean IlvCodeEditor::find ( IlBoolean  forwardDir,
IlBoolean  limited,
IlBoolean  caseSensitive,
IlBoolean  wholeWord,
const char *  pattern,
Location  from,
Location  to,
IlBoolean  s = IlTrue 
)

Finds the first occurence of the specified pattern from the current cursor position.

Parameters
forwardDirWill the search proceed forward or backward.
limitedWill the search proceed only between valid start and end locations.
caseSensitiveCase sensitivity of the search.
wholeWordShould only find whole words.
patternThe pattern to search.
fromStart location of the search.
toEnd location of the search.
sShould the selection be extended if the pattern spans several lines.
Returns
IlTrue if the pattern is found.

§ getCursorColumn()

IlInt IlvCodeEditor::getCursorColumn ( ) const

Returns the column where the cursor is located.

Note
If the cursor is before the first character of a line, then this method returns 0.

§ getCursorLine()

IlInt IlvCodeEditor::getCursorLine ( ) const

Returns the index of the line where the cursor is located.

Note
The first line has an index of 0.

§ getRedoCommandLabel()

void IlvCodeEditor::getRedoCommandLabel ( IlString l) const

Returns in its argument the label of the last redoable command.

This function delegates the actual processing to the command processor.

Parameters
lOn output, will contain the label of the command.

§ getSelection()

char* IlvCodeEditor::getSelection ( ) const

Retrieves the text from the current selection.

Returns
A copy of the selection text or null if there is no active selection.
Note
The tabs are copied as blank characters.

§ getSelectionEnd()

Location IlvCodeEditor::getSelectionEnd ( ) const

Returns the location of the end of the current selection.

Returns
The location of the end of current selection if there is one, Location(-1, -1) otherwise.

§ getSelectionEndColumn()

IlInt IlvCodeEditor::getSelectionEndColumn ( ) const

Returns the index of the last column of the current selection.

Returns
The index of the last column of the selection if there is one, -1 otherwise.

§ getSelectionEndLine()

IlInt IlvCodeEditor::getSelectionEndLine ( ) const

Returns the index of the last line of the current selection.

Returns
The index of the last line of the selection if there is one, -1 otherwise.

§ getSelectionStart()

Location IlvCodeEditor::getSelectionStart ( ) const

Returns the location of the start of the current selection.

Returns
The location of the start of current selection if there is one, Location(-1, -1) otherwise.

§ getSelectionStartColumn()

IlInt IlvCodeEditor::getSelectionStartColumn ( ) const

Returns the index of the first column of the current selection.

Returns
The index of the first column of the current selection if there is one, -1 otherwise.

§ getSelectionStartLine()

IlInt IlvCodeEditor::getSelectionStartLine ( ) const

Returns the index of the first line of the current selection.

Returns
The index of the first line of the current selection if there is one, -1 otherwise.

§ getText()

char* IlvCodeEditor::getText ( IlBoolean  blanks)

Gets the text from the buffer.

Parameters
blanksShould tabs be translated to blank chars.
Returns
The buffer contents as a string.

§ getUndoCommandLabel()

void IlvCodeEditor::getUndoCommandLabel ( IlString l) const

Returns in its argument the label of the last undoable command.

Parameters
lOn output, will contain the label of the command.

This function delegates the actual processing to the command processor.

§ gotoEnd()

void IlvCodeEditor::gotoEnd ( )

Moves the cursor to the end of the buffer.

Note
If the buffer is empty, the cursor will be set at its begining.

§ gotoLine()

IlBoolean IlvCodeEditor::gotoLine ( IlInt  line)

Moves the cursor to the given line.

Parameters
lineThe line number to move the cursor to.
Returns
IlTrue unless the line number is invalid.

§ handleGadgetEvent()

virtual IlBoolean IlvCodeEditor::handleGadgetEvent ( IlvEvent event)
virtual

Handles the gadget events.

Is called by handleEvent() when the member function handleScrollBarsEvent() returns IlFalse. Its default implementation does nothing. You can override this member function to implement your own gadget behavior.

Parameters
eventThe event.
See also
handleScrollBarsEvent().

Reimplemented from IlvScrolledGadget.

§ handleScrollBarsEvent()

virtual IlBoolean IlvCodeEditor::handleScrollBarsEvent ( IlvEvent event)
virtual

Handles the internal scroll bars event.

Is called from the handleEvent method. You can override this member function to implement your own scroll bar behavior.

Parameters
eventThe event.
Returns
IlFalse if the event has not been handled by the scroll bars. In this case, handleGadgetEvent() will be called.
See also
handleGadgetEvent().

Reimplemented from IlvScrolledGadget.

§ hasSelection()

IlBoolean IlvCodeEditor::hasSelection ( ) const

Tells whether there is an active selection or not.

Returns
IlTrue is some text is selected.

§ indentLine()

IlInt IlvCodeEditor::indentLine ( IlInt  line)

indents the specified line.

Parameters
linethe line index.
Returns
Always 0.

§ insertCharacter()

IlInt IlvCodeEditor::insertCharacter ( char  key,
IlBoolean  bckIndent = IlTrue 
)

Inserts the given charater at the current cursor location.

Parameters
keythe character to insert.
bckIndent.
Returns
The column index of the insertion.

§ insertTabulation()

IlInt IlvCodeEditor::insertTabulation ( )

Inserts a tabulation at the current cursor location.

Returns
Always 0.

§ insertText() [1/2]

void IlvCodeEditor::insertText ( const char *  text,
IlInt  line,
IlInt  column,
IlBoolean  reDraw = IlFalse 
)

Inserts the given text at the given location.

The function will do nothing if the given text is null or is an empty string.

If need be, the text may be converted to wide chars.

Parameters
textThe text to insert.
lineThe line at which the insertion is to be done.
columnThe column at which the insertion is to be done.
reDrawShould the buffer be redrawn.
Note
The action of this function is not undoable.

§ insertText() [2/2]

Location IlvCodeEditor::insertText ( const char *  text,
const Location at,
IlBoolean  reDraw = IlFalse 
)

Concatenates the text between two locations.

Parameters
textthe text to insert.
atthe insertion start location.
reDrawis re-drawing requested.
Returns
The end location of the insertion.

§ insertTextReversible()

void IlvCodeEditor::insertTextReversible ( const char *  text,
IlInt  line,
IlInt  column,
IlBoolean  reDraw 
)

Inserts the given text at the given location.

The function will do nothing if the given text is null or is an empty string.

If need be, the text may be converted to wide chars.

Parameters
textThe text to insert.
lineThe line at which the insertion is to be done.
columnThe column at which the insertion is to be done.
reDrawShould the buffer be redrawn.
Note
The action of this function is reversible that is can be undone.

§ isBlockCloser()

IlBoolean IlvCodeEditor::isBlockCloser ( char  character) const

tells if the given charater is a block closer.

Parameters
characterthe character to test.
Returns
IlTrue if there is a parser and the character is declared as a block closer.

§ isMultilineSelection()

IlBoolean IlvCodeEditor::isMultilineSelection ( ) const

Indicates if the current selection spans several lines.

Returns
IlTrue if there is a selection that spans across several lines.

§ isReadOnly()

IlBoolean IlvCodeEditor::isReadOnly ( ) const

Returns the editor read-only state.

Returns
IlTrue if the editor is read only, IlFalse otherwise.

§ isRedoable()

IlBoolean IlvCodeEditor::isRedoable ( ) const

Tells if the redo feature is usable.

This function delegates the actual processing to the command processor.

§ isSaveNeeded()

IlBoolean IlvCodeEditor::isSaveNeeded ( ) const

Tells if the buffer has been changed.

Returns
IlTrue if the text was changed; IlFalse otherwise.

§ isTabulation()

IlBoolean IlvCodeEditor::isTabulation ( const Location l) const

Tells if the character at location is a tabulation.

Returns
IlTrue if the character is a tabulation or a blank character part of one.

§ isUndoable()

IlBoolean IlvCodeEditor::isUndoable ( ) const

Tells if the undo feature is usable.

This function delegates the actual processing to the command processor.

§ killComment()

IlBoolean IlvCodeEditor::killComment ( )

Removes a mono-line comment in the text.

The comment is removed at the cursor line or in the lines selected. Only the first comment met is processed.

§ loadFile()

IlBoolean IlvCodeEditor::loadFile ( const IlPathName filePath,
IlBoolean  redraw = IlTrue 
)

Loads text from given file into the buffer.

The function will do nothing if the given pathanme is empty.

If need be, the file contents may be converted to wide chars.

Parameters
filePathThe file path that is loaded.
redrawif IlTrue, the Code Editor is redrawn.
Returns
IlTrue if the file was accessible and the load proceeded; IlFalse in all other cases.
Note
The buffer previous contents will be lost.

§ loadText()

void IlvCodeEditor::loadText ( const char *  text)

Loads the given text into the buffer.

The function will do nothing if the given text is null.

If need be, the text may be converted to wide chars.

Parameters
textThe text to load.
Note
The buffer previous contents will be lost.

§ pasteFromClipBoard()

IlBoolean IlvCodeEditor::pasteFromClipBoard ( )

Pastes the clipboard contents replacing the current selection if any.

Returns
IlTrue if the command processor succeeded; IlFalse if there is no current selection.
Note
This action is undoable.

§ propagateSheet()

void IlvCodeEditor::propagateSheet ( const StyleSheet s = 0)

Propagates style sheet modifications.

Parameters
sThe style sheet to propagate.

The function propagates the effect of the sheet modification, ensuring consistency of lines ans editor internal states. If the s sheet argument is null then it propagates the value of the current sheet. It copies the s sheet before propagating if it is not null.

§ redo()

IlBoolean IlvCodeEditor::redo ( )

Replays the last undone command.

This function delegates the actual processing to the command processor.

Returns
The result from the command processor action.

§ removeMarker()

void IlvCodeEditor::removeMarker ( IlvCEdtMarker &  marker,
IlInt  line 
)

Removes a marker from the margin of a line.

Parameters
markerthe marker to remove.
linethe line to remove the symbol from the margin.

The line number should be valid with respect to the contents of the editor. That is greater or equal to 0 and lesser than the number of lines in the editor text.

The line is redrawn.

§ removeMarkers()

void IlvCodeEditor::removeMarkers ( IlInt  line = -1)

Removes all markers from the margin of a given line or all lines.

Parameters
linethe line to remove the markers from the margin.

If given the line number should be valid with respect to the contents of the editor. That is greater or equal to 0 and lesser than the number of lines in the editor text. If no line number is given, all markers will be removed from all lines.

The editor is redrawn.

§ removeOneLogicalCharacter()

void IlvCodeEditor::removeOneLogicalCharacter ( )

Removes one logical character just before the cursor.

If the character is a tabulation represented with blanks, all are deleted.

§ removeText()

char* IlvCodeEditor::removeText ( const Location start,
const Location end,
IlBoolean  retStr = IlTrue 
)

Removes the text and the lines between two locations.

Parameters
startThe start location.
endThe end location.
retStrWhether or not the removed text should be returned.
Returns
If requested, the removed text.

Tabs are translated to blank characters in the returned string.

§ replaceSelection()

void IlvCodeEditor::replaceSelection ( const char *  replacement,
IlBoolean  autoRedraw,
IlBoolean  forwardDir 
)

Replaces the selected text by the new value.

Parameters
replacementThe text to replace the selection with.
autoRedrawShould the buffer be redrawn after insertion.
forwardDirIf false, the cursor will be set at the begining of the selection.

The function does nothing if the cursor is not in a valid position or there if is no selected text.

Actually the action is turned into two commands: one to remove the selected text and one to insert the new text.

§ resetSaveNeeded()

void IlvCodeEditor::resetSaveNeeded ( )

Resets the buffer changed indicator.

The change is propagated to the observers.

§ scrollableSize()

virtual void IlvCodeEditor::scrollableSize ( IlvDim width,
IlvDim height 
) const
virtual

Returns the size of the scrollable area of the gadget.

Puts the width and height of the scrollable area in width and height, respectively. These values are used to compute the values of the scroll bars. You can override this member function to change the scrollable area.

Reimplemented from IlvScrolledGadget.

§ selectAll()

IlBoolean IlvCodeEditor::selectAll ( )

Selects all text from the buffer.

Returns
Always IlTrue.

§ setCursorLocation()

void IlvCodeEditor::setCursorLocation ( IlInt  line,
IlInt  column 
)

Moves the cursor to the location given by its arguments.

Note
To move the cursor before the first character of the first line, line and column should be set to 0.

§ setEditable()

void IlvCodeEditor::setEditable ( IlBoolean  mode)

Sets the editor to be editable or read-only.

Parameters
modethe state to set the readOnly option to.

If the editor needs an input method, it is set when the mode is set to editable, removed if the opposite is true.

§ setFindTrigger()

void IlvCodeEditor::setFindTrigger ( Trigger trigger)

Sets the Find trigger.

When the Find action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Find trigger is removed.

§ setGotoTrigger()

void IlvCodeEditor::setGotoTrigger ( Trigger trigger)

Sets the Goto trigger.

When the Goto Line action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Goto trigger is removed.

§ setKillBufferTrigger()

void IlvCodeEditor::setKillBufferTrigger ( Trigger trigger)

Sets the Kill Buffer trigger.

When the Kill Buffer action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Kill Buffer trigger is removed.

§ setLine()

void IlvCodeEditor::setLine ( IlInt  line,
const char *  text 
)

Replaces the text at line by the new value.

Parameters
lineThe line number.
textThe new contents for the line

§ setMark()

IlBoolean IlvCodeEditor::setMark ( )

Sets the selection mark.

Returns
Always IlTrue.
Note
This method only makes sense when in Binding::Emacs mode.

§ setMarker()

void IlvCodeEditor::setMarker ( IlvCEdtMarker &  marker,
IlInt  line 
)

Adds a marker to the margin of a line.

Parameters
markerThe marker to add.
lineThe line to add the symbol to.

The line number should be valid with respect to the contents of the editor. That is greater or equal to 0 and lesser than the number of lines in the editor text.

The line is redrawn.

§ setOpenTrigger()

void IlvCodeEditor::setOpenTrigger ( Trigger trigger)

Sets the Open trigger.

When the Open action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Open trigger is removed.

§ setQuitTrigger()

void IlvCodeEditor::setQuitTrigger ( Trigger trigger)

Sets the Quit trigger.

When the Quit action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Quit trigger is removed.

§ setReadOnlyTrigger()

void IlvCodeEditor::setReadOnlyTrigger ( Trigger trigger)

Sets the Read Only trigger.

When the Code Editor cannot perform an action because it is read-only, this trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Read Only trigger is removed.

§ setReplaceTrigger()

void IlvCodeEditor::setReplaceTrigger ( Trigger trigger)

Sets the Replace trigger.

When the Replace action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Replace trigger is removed.

§ setSaveAllTrigger()

void IlvCodeEditor::setSaveAllTrigger ( Trigger trigger)

Sets the Save All trigger.

When the Save All action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Save All trigger is removed.

§ setSaveAsTrigger()

void IlvCodeEditor::setSaveAsTrigger ( Trigger trigger)

Sets the Save As trigger.

When the Save As action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Save As trigger is removed.

§ setSaveTrigger()

void IlvCodeEditor::setSaveTrigger ( Trigger trigger)

Sets the Save trigger.

When the Save action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Save trigger is removed.

§ setSelection()

IlBoolean IlvCodeEditor::setSelection ( IlInt  startOffset,
IlInt  endOffset 
)

Selects part of the text on current line.

Parameters
startOffsetThe start index of the new selection.
endOffsetThe end index of the new selection.

§ setSwitchBufferTrigger()

void IlvCodeEditor::setSwitchBufferTrigger ( Trigger trigger)

Sets the Switch Buffer trigger.

When the Switch Buffer action is invoked from the Code Editor, the trigger is invoked.

Parameters
triggerThe trigger to be set. If trigger is 0 then the Switch Buffer trigger is removed.

§ setText()

void IlvCodeEditor::setText ( const char *  text)

Loads the given text into the buffer.

The function is for compatibility with IlvText; it is strictly equivalent to loadText().

Parameters
textThe text to set.

§ syntaxHighLight()

IlBoolean IlvCodeEditor::syntaxHighLight ( ) const

Tells if syntax highlighting is activated.

Returns
IlTrue if the syntax highlighting feature is enabled.

§ undo()

IlBoolean IlvCodeEditor::undo ( )

Reverses the effects of the last run command.

This function delegates the actual processing to the command processor.

Returns
The result from the command processor action.

§ unindentLine()

IlInt IlvCodeEditor::unindentLine ( IlInt  line)

Outdents the specified line.

Parameters
linethe line index.
Returns
Always 0.

§ unsetMark()

void IlvCodeEditor::unsetMark ( )

Removes the selection mark.

The selection is completely released, hence the involved lines are redrawn.

Note
This method only makes sense when in Binding::Emacs mode.

© Copyright 2017, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.