Document object
Previous Top Next

The document object let you get access to the current document. All you have to do is to type "Document." and all the properties and methods available are listed in a listbox. They are also listed below.

Properties

CanRedo

Syntax
CanRedo: Boolean   (read-only)

Description
True if changes can be re-done.


CanUndo

Syntax
CanUndo: Boolean   (read-only)

Description
True if changes can be undone.


CursorX

Syntax
CursorX: Integer

Description
Get or set the text cursor character position starting with 0.


CursorY

Syntax
CursorY: Integer

Description
Get or set the text cursor line position starting with 0.


FileName

Syntax
FileName: WideString   (read-only)

Description
Get the file name and complete path of the current document.


LineCount

Syntax
LineCount: Integer   (read-only)

Description
Number of lines in the document.


Lines

Syntax
Lines(Index: Integer): WideString

Description
Get or set the text of the line at the pasted index.


Modified

Syntax
Modified: Boolean   (read-only)

Description
True if the document has changed since it was last saved.


SelLength

Syntax
SelLength: Integer

Description
Get or set the length of the current selection.


SelStart

Syntax
SelStart: Integer

Description
Get or set the start of the current selection.


SelText

Syntax
SelText: WideString

Description
Get or set the text in the current selection.

Example
// PascalScript
var
   w: WideString;
begin
   Document.CursorLineStart(false);   // Move cursor to the beginning of the line
   Document.CursorWordRight(true);  // Select the first word
   w := Document.SelText;                // Get the selected word
   ...
end.


Text

Syntax
Text: WideString

Description
Get or set the document text.


Wordwrap

Syntax
Wordwrap: Boolean

Description
Get or set wordwrap mode. Could be used at the beginning of a script to ensure that the document is not word wrapped.


Methods

BeginUpdate

Syntax
BeginUpdate()

Description
Turn off screen updating for the current document. To turn it on again, use EndUpdate().


Clear

Syntax
Clear()

Description
Clear the current document.


Close

Syntax
Close(): Boolean

Description
Close the current document. The user may be prompted to save the document first. When the document is closed, the function returns true. Otherwise false.


CursorLeft, CursorRight, CursorWordLeft, CursorWordRight, CursorDown, CursorUp, CursorPageDown, CursorPageUp, CursorDocStart, CursorDocEnd, CursorLineStart, CursorLineEnd

Syntax
Cursor...(bSelect: Boolean)

Description
Position the cursor. If bSelect is True then the current selection is extended to the new position.

Example
Document.CursorLineStart(False);
Document.CursorLineEnd(True);   // Move the cursor to the end of line and select from the previous position.


DeleteBlankLines

Syntax
DeleteBlankLines()

Description
Delete all blank lines in a selection.


DuplicateLineNTimes

Syntax
DuplicateLineNTimes(const nr: Integer)

Description
Duplicate the current line nr times.


EndUpdate

Syntax
EndUpdate()

Description
Turn on screen updating for the current document and update and refresh the display.


FoldAll

Syntax
FoldAll()

Description
Fold all foldable sections in the text.


FoldNode

Syntax
FoldNode()

Description
Fold the nearest foldable section in the text.

FoldRegion

Syntax
FoldRegion()

Description
Fold the nearest foldable region in the text.


GetMethodAtCursor

Syntax
GetMethodAtCursor(bSelect: Boolean): WideString

Description
Return the method in which the cursor is currently located in. Select it by setting bSelect to True. Returns False if no method is found.


GetTagAtCursor

Syntax
GetTagAtCursor(bSelect: Boolean): WideString;

Description
Return the tag in which the cursor is currently located in. The method returns False if a tag could not be found at the cursor.

Set bSelect to True in order to select the tag.


GotoNextEndTag

Syntax
GotoNextEndTag(bSelect: Boolean): Boolean

Description
Move the cursor to the next end tag. Select it by setting bSelect to True. Returns False if no tag is found.


GotoNextMethod

Syntax
GotoNextMethod(bSelect: Boolean): Boolean

Description
Move the cursor to the next method. Select it by setting bSelect to True. Returns False if no method is found.


GotoNextStartTag

Syntax
GotoNextStartTag(bSelect: Boolean): Boolean

Description
Move the cursor to the next start tag. Select it by setting bSelect to True. Returns False if no tag is found.


GotoPreviousEndTag

Syntax
GotoPreviousEndTag(bSelect: Boolean): Boolean

Description
Move the cursor to the previous end tag. Select it by setting bSelect to True. Returns False if no tag is found.


GotoPreviousMethod

Syntax
GotoPreviousMethod(bSelect: Boolean; bSkipCurrentMethod: Boolean): Boolean

Description
Move the cursor to the previous method. Select it by setting bSelect to True. Set bSkipCurrentMethod to True if you don't want to stop at the top of the current method. Returns False if no method is found.


GotoPreviousStartTag

Syntax
GotoPreviousStartTag(bSelect: Boolean): Boolean

Description
Move the cursor to the previous start tag. Select it by setting bSelect to True. Returns False if no tag is found.


HighlightText

Syntax
HighlightText(const wsText: WideString; const bWords: Boolean = True)

Description
Highlight all occurrences of the text given in the argument. E.g. if you enter HighlightText('Dummy'); all instances of "Dummy" in the text will be highlighted. If the word flag is true, only whole words are highlighted. Otherwise the selected text is highlighted.
Words are highlighted with a red background, selections with a green background.


Indent

Syntax
Indent()

Description
Indents the current selection or insert a tab.


InsertTag

Syntax
InsertTag(sStartTag, sEndTag: WideString)

Description
Inserts the passed start and end tags at the current cursor position.

Example
Document.CursorDocEnd(False);
Document.InsertTag('<a href="http://www.rj-texted.se">', '</a>');

InsertText

Syntax
InsertText(wStr: WideString)

Description
Inserts the passed text at the current cursor position.


JoinLines

Syntax
JoinLines()

Description
Join selected lines into one line. If no selection is made, the current and the next lines are joined.


LastSavedDate

Syntax
LastSavedDate(): TDateTime

Description
Return the datetime value for the last save of the current document.


MoveLinesDown

Syntax
MoveLinesDown()

Description
Move the current line, or selection, downwards in the text.


MoveLinesUp

Syntax
MoveLinesUp()

Description
Move the current line, or selection, upwards in the text.


Print

Syntax
Print(bPrompt: Boolean)

Description
Prints the current document. If bPrompt is set to True, the user is prompted for print settings.


Redo

Syntax
Redo()

Description
Perform a redo operation.


Reload

Syntax
Reload(bPromptToSave: Boolean)

Description
Reloads the current document. Prompts the user to save if bPromptToSave is True.


ReplaceAll

Syntax
ReplaceAll(sFind, sReplace: WideString; bMatchCase, bWholeWords, bRegExp: Boolean): Integer

Description
Replace all found strings. Returns the number of replaced strings.


Save

Syntax
Save(): Boolean

Description
Saves the current document. Returns true if successful.


SaveAs

Syntax
SaveAs(sFileName: WideString): Boolean

Description
Save the current document to the file specified by sFileName. Returns true if successful.


SaveAsNoMRU

Syntax
SaveAsNoMRU(sFileName: WideString): Boolean

Description
Save the current document to the file specified by sFileName. The file will not show up in the list of recently opened files. Returns true if successful.

SelectAll

Syntax
SelectAll()

Description
Selects all text in the current document.


SelectCurrentLine

Syntax
SelectCurrentLine()

Description
Select the current line.


SelectLine

Syntax
SelectLine(Index: Integer)

Description
Select the passed line.


SplitLines

Syntax
SplitLines()

Description
Split the current line, or lines in a selection, at the word wrap margin.


Undo

Syntax
Undo()

Description
Perform an undo operation.


UnfoldAll

Syntax
UnfoldAll()

Description
Unfold all foldable sections in the text.


UnfoldNode

Syntax
UnfoldNode()

Description
Unfold the nearest foldable section in the text.


UnfoldRegion

Syntax
UnfoldRegion()

Description
Unfold the nearest foldable region in the text.


UnhighlightText

Syntax
UnhighlightText(const wsText: WideString; const bWords: Boolean = True)

Description
Unhighlight the given text. If the wsText argument is empty all highlighted text is unhighlighted. You can either cancel highlighting of words or selected text.


Unindent

Syntax
Unindent()

Description
Remove the indent in the current selection.