Move the Cursor

<< Click to Display Table of Contents >>

Navigation:  Programming > Move cursor / select text >

Move the Cursor

Please use the CP.. properties. CPPosition is the current character position, assign 0 to go to the start, MaxInt to go to the end. Also procedure MovePosition is very useful. When the user changes the cursor position the event OnChangeCursorPos is triggered.

 

This property can be used to read and set the cursor position as index counted from the start of the document.

Paragraph breaks are counted as one.

 

 property CPPosition: Integer;

 

 Please do not use CPPosition := CPPoition +1 to move through the text. This is not effective. Please use CPMoveNext instead.

 

The following functions move the cursor by one character, line or paragraph.

 

 function CPMoveNext: Boolean;

 function CPMoveBack: Boolean;

 function CPMoveDownLine: Boolean;

 function CPMoveDownPar: Boolean;

 function CPMoveUpLine: Boolean;

 function CPMoveUpPar: Boolean;

 

Check for cursor to be at start or end of document:

 function Bof : Boolean

 function Eof: Boolean

 

 

Reads the CharAttr index at cursor position. If the cursor is at the end of a paragraph the next following character will be searched.

 property CPCharAttr : Cardinal

 

 

This property allows direct manipulation of the character at the cursor position - except for the #13 character which marks the end of a paragraph.

 property CPChar: Char;

 

This property allows direct manipulation of the character BEFORE the cursor position - except for the #13 character which marks the end

     of a paragraph.

 

 property CPPrevChar: Char;

 

This are the wide char variants fro above properties:

 property CPWideChar: WideChar;

 property CPPrevWideChar: WideChar;

 

This property can be used to read the characters starting with the cursor position plus a certain index. This property is only provided to make it easier to convert code which was using pointers. (We suggest to work directly with ActiveParagraph and ActivePosInPar.)

 

 property CPChars[index: Integer]: WideChar;