Carbon


ATSUNextCursorPosition

Header: ATSUnicode.h Carbon status: Supported

Obtains the edge offset corresponding to the next cursor position based on the type of cursor movement.

OSStatus ATSUNextCursorPosition (
    ATSUTextLayout iTextLayout, 
    UniCharArrayOffset iOldOffset, 
    ATSUCursorMovementType iMovementType, 
    UniCharArrayOffset *oNewOffset
);
Parameter descriptions
iTextLayout

A reference to an initialized text layout object in which the cursor has moved. You cannot pass NULL for this parameter.

iOldOffset

The edge offset corresponding to the initial cursor position. To specify the beginning of the text buffer, pass the constant kATSUFromTextBeginning, described in “Text Offset and Length Constants”. If the specified range of text is outside the text buffer, ATSUNextCursorPosition returns the result code kATSUInvalidTextRangeErr.

iMovementType

The cursor movement distance. See “Cursor Movement Constants” for a description of possible values. You must pass a value between 2 bytes and a word in length.

oNewOffset

On return, a pointer to the edge offset corresponding to the new cursor position. This offset may be outside the text buffer.

function result

A result code. The result code kATSUInvalidCacheErr indicates that an attempt was made to read in styled data from an invalid cache. In this case, either the format of the cached data does not match that used by ATSUI or the cached data is corrupt. The result code kATSUQuickDrawTextErr indicates that the QuickDraw function DrawText encountered an error while measuring a line of text.

DISCUSSION

The ATSUNextCursorPosition function determines the edge offset in backing store memory corresponding to the previous cursor position based on the type of cursor movement specified in the iMovementType parameter. You should call ATSUNextCursorPosition and the function ATSUPreviousCursorPosition if the initial edge offset is not at a line boundary. If the initial edge offset is at a line direction boundary, you should instead call the functions ATSURightwardCursorPosition and ATSULeftwardCursorPosition to calculate the next and previous cursor positions. Note that at a line boundary, the caret is split into a high and low caret.

Note that you may not be able to move the cursor 2-bytes, since doing so might place the cursor in the middle of a surrogate pair.

ATSUNextCursorPosition may allocate memory in your application heap, unless you designate a different heap by calling the function ATSUCreateMemorySetting.

VERSION NOTES

Available beginning with ATSUI 1.0.

AVAILABILITY

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.5 or later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)