rwlogo

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 IlvStyleable IlvGraphic 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 *txt)
 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 caseSens, IlBoolean wholeWord, const char *pattern, Location from, Location to, IlBoolean s=IlTrue)
 Finds the first occurence of the specified patern 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 *txt, 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 *txt, 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 *txt)
 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 &from, const Location &to, IlBoolean retStr=IlTrue)
 Removes the text and the lines between two locations. More...
 
void replaceSelection (const char *by, 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 *txt)
 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 *txt)
 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 IlvCodeEditor::Line 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 IlvCodeEditor::Parser::associate(), it uses this IlvCodeEditor::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 IlvCodeEditor::StyleSheet as a style sheet for coloration, and tabulation size.

The undo and redo chain management is delegated to an instance of the IlvCodeEditor::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::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::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.

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

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

Member Function Documentation

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.

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

Is called to adjust the scroll bar values.

Is called by the member function IlvScrolledGadget::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.

void IlvCodeEditor::appendText ( const char *  txt)

Appends the given text to the buffer.

Parameters
textThe text to append.
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.
void IlvCodeEditor::blockUndoRedo ( )

Inhibits the undo/redo feature.

This function delegates the actual processing to the command processor.

IlBoolean IlvCodeEditor::braceHighLight ( ) const

Tells if brace matching highlighting is activated.

Returns
IlTrue if the brace matching highlighting feature is enabled.
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.
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.
IlBoolean IlvCodeEditor::commentRegion ( )

Inserts a mono-line comment in the text.

The comment is inserted at the cursor line.

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.
Warning
[note] This action is undoable.
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.

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.
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.
Warning
[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.
IlBoolean IlvCodeEditor::cutToClipBoard ( )

Cuts the current selection to the clipboard.

Returns
IlTrue if the command processor succeeded; IlFalse if there is no current selection.
Warning
[note] This action cannot be undone.
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.

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

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

Parameters
forwardDirWill the search proceed forward or backward.
limitedWill the search proceed only between valid start and end locations.
caseSensCase sensitivity of the search.
wholeWordShould only find whole words.
fromLocStart location of the search.
toLocEnd location of the search.
sShould the selection be extended if the pattern spans several lines.
Returns
IlTrue if the pattern is found.
IlInt IlvCodeEditor::getCursorColumn ( ) const

Returns the column where the cursor is located.

Warning
[note] If the cursor is before the first character of a line, then this method returns 0.
IlInt IlvCodeEditor::getCursorLine ( ) const

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

Warning
[note] The first line has an index of 0.
void IlvCodeEditor::getRedoCommandLabel ( IlString l) const

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

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

This function delegates the actual processing to the command processor.

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.
Warning
[note] The tabs are copied as blank characters.
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.
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.
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.
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.
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.
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.
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.
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.

void IlvCodeEditor::gotoEnd ( )

Moves the cursor to the end of the buffer.

Warning
[note] If the buffer is empty, the cursor will be set at its begining.
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.
virtual IlBoolean IlvCodeEditor::handleGadgetEvent ( IlvEvent event)
virtual

Handles the gadget events.

Is called by IlvScrolledGadget::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.

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.

IlBoolean IlvCodeEditor::hasSelection ( ) const

Tells whether there is an active selection or not.

Returns
IlTrue is some text is selected.

CM: Needs elaboration

IlInt IlvCodeEditor::indentLine ( IlInt  line)

indents the specified line.

Parameters
linethe line index.
Returns
always 0.
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.
IlInt IlvCodeEditor::insertTabulation ( )

Inserts a tabulation at the current cursor location.

Returns
Always 0.
void IlvCodeEditor::insertText ( const char *  txt,
IlInt  line,
IlInt  column,
IlBoolean  reDraw = IlFalse 
)

Inserts the given text at the given location.

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

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.

Warning
[note] The action of this function is not undoable.
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.
void IlvCodeEditor::insertTextReversible ( const char *  txt,
IlInt  line,
IlInt  column,
IlBoolean  reDraw 
)

Inserts the given text at the given location.

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

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.

Warning
[note] The action of this function is reversible that is can be undone.
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.
IlBoolean IlvCodeEditor::isMultilineSelection ( ) const

Indicates if the current selection spans several lines.

Returns
IlTrue if there is a selection that spans across several lines.
IlBoolean IlvCodeEditor::isReadOnly ( ) const

Returns the editor read-only state.

Returns
IlTrue if the editor is read only, IlFalse otherwise.
IlBoolean IlvCodeEditor::isRedoable ( ) const

Tells if the redo feature is usable.

This function delegates the actual processing to the command processor.

IlBoolean IlvCodeEditor::isSaveNeeded ( ) const

Tells if the buffer has been changed.

Returns
IlTrue if the text was changed; IlFalse otherwise.
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.
IlBoolean IlvCodeEditor::isUndoable ( ) const

Tells if the undo feature is usable.

This function delegates the actual processing to the command processor.

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.

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

Loads text from given file into the buffer.

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.

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

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

Warning
[note] The buffer previous contents will be lost.
void IlvCodeEditor::loadText ( const char *  txt)

Loads the given text into the buffer.

Parameters
textThe text to load.

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

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

Warning
[note] The buffer previous contents will be lost.
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.
Warning
[note] This action is undoable.
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.

IlBoolean IlvCodeEditor::redo ( )

Replays the last undone command.

Returns
the result from the command processor action.

This function delegates the actual processing to the command processor.

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.

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.

void IlvCodeEditor::removeOneLogicalCharacter ( )

Removes one logical character just before the cursor.

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

char* IlvCodeEditor::removeText ( const Location from,
const Location to,
IlBoolean  retStr = IlTrue 
)

Removes the text and the lines between two locations.

Parameters
fromthe start location.
endthe end location.
retStrshould the removed text be returned.
Returns
If requested, the removed text.

Tabs are translated to blank characters in the returned string.

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

Replaces the selected text by the new value.

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

The function will do nothing if the cursor is not in a valide position or there is no text selected.

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

void IlvCodeEditor::resetSaveNeeded ( )

Resets the buffer changed indicator.

The change is propagated to the observers.

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.

IlBoolean IlvCodeEditor::selectAll ( )

Selects all text from the buffer.

Returns
always IlTrue.
void IlvCodeEditor::setCursorLocation ( IlInt  line,
IlInt  column 
)

Moves the cursor to the location given by its arguments.

Warning
[note] To move the cursor before the first character of the first line, line and column should be set to 0.
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.

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.
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.
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.
void IlvCodeEditor::setLine ( IlInt  line,
const char *  txt 
)

Replaces the text at line by the new value.

Parameters
lineThe line number.
txtThe new contents for the line
IlBoolean IlvCodeEditor::setMark ( )

Sets the selection mark.

Returns
Always IlTrue.
Warning
[note] This function only makes sense when in Binding::Emacs mode.
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.

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.
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.
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.
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.
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.
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.
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.
IlBoolean IlvCodeEditor::setSelection ( IlInt  startOffset,
IlInt  endOffset 
)

Selects part of the text on current line.

Parameters
startOffset.
endOffset.
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.
void IlvCodeEditor::setText ( const char *  txt)

Loads the given text into the buffer.

Parameters
textThe text to set.

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

IlBoolean IlvCodeEditor::syntaxHighLight ( ) const

Tells if syntax highlighting is activated.

Returns
IlTrue if the syntax highlighting feature is enabled.
IlBoolean IlvCodeEditor::undo ( )

Reverses the effects of the last run command.

Returns
the result from the command processor action.

This function delegates the actual processing to the command processor.

IlInt IlvCodeEditor::unindentLine ( IlInt  line)

Outdents the specified line.

Parameters
linethe line index.
Returns
always 0.
void IlvCodeEditor::unsetMark ( )

Removes the selection mark.

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

Warning
[note] This function only makes sense when in Binding::Emacs mode.

© Copyright 2014, 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.