Return to Index

TextEditor

Parent class: Widget

A heavy-duty multi-line text editor that can display large text files. The editor provides its own scrollbars in both the horizontal and vertical directions. The widget also provides methods for saving and loading text files, as well as for searching for text strings. The text is rendered in a fixed monospace typeface.


Object Events:
ChangedAn event generated when the text changes. The number of characters inserted is stored in pEvt.getPoint().x, the number of characters deleted in pEvt.getPoint().y, the text that was deleted in pEvt.getString(), and the current insertion position in pEvt.getIndex().

Method Summary:
TextEditor::TextEditor();
void TextEditor::setText(const String& pText);
String TextEditor::getText();
String TextEditor::getText(int pStart, int pEnd);
char TextEditor::getCharAt(int pPos);
void TextEditor::clear();
void TextEditor::insert(const String& pText);
void TextEditor::insert(int pStart, const String& pText);
void TextEditor::remove(int pStart, int pEnd);
void TextEditor::replace(int pStart, int pEnd, const String& pText);
void TextEditor::replaceSelection(const String& pText);
void TextEditor::append(const String& pText);
int TextEditor::getLength();
bool TextEditor::loadFile(const String& pFileName);
bool TextEditor::saveFile(const String& pFileName);
void TextEditor::setCursorPos(int pPos);
int TextEditor::getCursorPos();
void TextEditor::cut();
void TextEditor::copy();
void TextEditor::paste();
int TextEditor::getLineStartPos(int pPos);
int TextEditor::getLineEndPos(int pPos);
void TextEditor::select(int pStart, int pEnd);
void TextEditor::selectAll();
void TextEditor::unselect();
bool TextEditor::searchForward(int pStart, const String& pStr, int* pPos, bool (=false) pMatchCase);
bool TextEditor::searchBackward(int pStart, const String& pStr, int* pPos, bool (=false) pMatchCase);
void TextEditor::showInsertPos();
int TextEditor::getTabWidth();
void TextEditor::setTabWidth(int pWidth);



TextEditor::TextEditor
TextEditor::TextEditor();

Constructs a new text editor widget.

void TextEditor::setText
void TextEditor::setText(const String& pText);

Sets the text in the editor.
Parameters:
const String& pTextThe text string.

String TextEditor::getText
String TextEditor::getText();

Returns the entire text in the editor.

String TextEditor::getText
String TextEditor::getText(int pStart, int pEnd);

Returns the text between the specified start and end positions.
Parameters:
int pStartThe starting position.
int pEndThe ending position.

char TextEditor::getCharAt
char TextEditor::getCharAt(int pPos);

Returns the character at the specified position.
Parameters:
int pPosThe position.

void TextEditor::clear
void TextEditor::clear();

Removes all the text from the editor.

void TextEditor::insert
void TextEditor::insert(const String& pText);

Inserts text at the current insertion position.
Parameters:
const String& pTextThe text to insert.

void TextEditor::insert
void TextEditor::insert(int pStart, const String& pText);

Inserts text at the given insertion position.
Parameters:
int pStartThe insertion position.
const String& pTextThe text to insert.

void TextEditor::remove
void TextEditor::remove(int pStart, int pEnd);

Removes a range of text between the given positions.
Parameters:
int pStartThe starting position.
int pEndThe ending position.

void TextEditor::replace
void TextEditor::replace(int pStart, int pEnd, const String& pText);

Replaces the range of text between the given positions with new text.
Parameters:
int pStartThe starting position.
int pEndThe ending position.
const String& pTextThe new text.

void TextEditor::replaceSelection
void TextEditor::replaceSelection(const String& pText);

Replaces the current selection with new text.
Parameters:
const String& pTextThe new text.

void TextEditor::append
void TextEditor::append(const String& pText);

Appends some text to the end of the buffer.
Parameters:
const String& pTextThe text to append.

int TextEditor::getLength
int TextEditor::getLength();

Returns the length of the text stored in the editor.

bool TextEditor::loadFile
bool TextEditor::loadFile(const String& pFileName);

Attempts to load the text file specified, returning true on success.
Parameters:
const String& pFileNameThe file name.

bool TextEditor::saveFile
bool TextEditor::saveFile(const String& pFileName);

Attempts to save the text to the file specified, returning true on success.
Parameters:
const String& pFileNameThe file name.

void TextEditor::setCursorPos
void TextEditor::setCursorPos(int pPos);

Changes the current insertion position.
Parameters:
int pPosThe new position.

int TextEditor::getCursorPos
int TextEditor::getCursorPos();

Returns the current insertion position.

void TextEditor::cut
void TextEditor::cut();

Cuts the selected text to the clipboard.

void TextEditor::copy
void TextEditor::copy();

Copies the selected text to the clipboard.

void TextEditor::paste
void TextEditor::paste();

Pastes any text on the system clipboard into the editor, replacing any selection.

int TextEditor::getLineStartPos
int TextEditor::getLineStartPos(int pPos);

Returns the position of the start of the line containing the specified position.
Parameters:
int pPosThe position.

int TextEditor::getLineEndPos
int TextEditor::getLineEndPos(int pPos);

Returns the position of the end of the line containing the specified position.
Parameters:
int pPosThe position.

void TextEditor::select
void TextEditor::select(int pStart, int pEnd);

Selects the text in the specified range.
Parameters:
int pStartThe starting position.
int pEndThe ending position.

void TextEditor::selectAll
void TextEditor::selectAll();

Selects all of the text in the editor.

void TextEditor::unselect
void TextEditor::unselect();

Unselects the current selection.

bool TextEditor::searchForward
bool TextEditor::searchForward(int pStart, const String& pStr, int* pPos, bool (=false) pMatchCase);

Searches for text starting from the given position forward.

Returns: Returns whether the text was found or not.
Parameters:
int pStartThe starting position for the search.
const String& pStrThe text to search for.
int* pPosAn integer to assign the starting position of the found text, if the text was found.
bool (=false) pMatchCaseWhether to match case or not. Defaults to false.

bool TextEditor::searchBackward
bool TextEditor::searchBackward(int pStart, const String& pStr, int* pPos, bool (=false) pMatchCase);

Searches for text starting from the given position backwards.

Returns: Returns whether the text was found or not.
Parameters:
int pStartThe starting position for the search.
const String& pStrThe text to search for.
int* pPosAn integer to assign the starting position of the found text, if the text was found.
bool (=false) pMatchCaseWhether to match case or not. Defaults to false.

void TextEditor::showInsertPos
void TextEditor::showInsertPos();

Ensures that the insertion position is visible.

int TextEditor::getTabWidth
int TextEditor::getTabWidth();

Returns the current tab width.

void TextEditor::setTabWidth
void TextEditor::setTabWidth(int pWidth);

Sets the display width of tabs.
Parameters:
int pWidthThe tab width.


Generated automatically by docgen 0.0.1
© 2003 Aron Dobos