Virtual Text Views
PBVirtualTextView
Opaque object handle:
This is a subclass of PBElement. You can safely cast from PBVirtualTextView to PBElement. To cast from PBElement to PBVirtualTextView, call PBVirtualTextViewCast; this performs a runtime assertion to check the cast is possible. This function is thread-safe.
This object maintains an internal reference count. When the reference count reaches zero, the object will be automatically deallocated. To increment the reference count, call PBElementRetain; to decrement the reference count, call PBElementRelease. These functions are thread-safe.
PBMessageVirtualTextGetLineInfo
Structure:
Fields
[in] lineIndex (uint64_t
):
stringLength (uint32_t
):
drawOffsetX (int16_t
):
[in] regionIndex (uint8_t
):
PBVirtualTextGetStringRequest
Structure:
Fields
[in] lineIndex (uint64_t
):
[in] offsetIntoString (uint32_t
):
[in] regionIndex (uint8_t
):
PBMessageVirtualTextGetString
Structure:
Fields
[in] [indirect] request (PBVirtualTextGetStringRequest):
buffer (string buffer):
PBVirtualTextGetPlanRequest
Structure:
Fields
[in] lineIndex (uint64_t
):
[in] regionIndex (uint8_t
):
[in] textStyle (referenced PBTextStyle):
caretColor (PBColor):
PBMessageVirtualTextGetPlan
Structure:
Fields
[in] [indirect] request (PBVirtualTextGetPlanRequest):
textPlan (nullable owned PBTextPlan):
PBMessageVirtualTextAdjustMenu
Structure:
Fields
[in] lineIndex (uint64_t
):
[in] commandList (referenced PBCommandList):
PBMessageVirtualTextDrawLine
Structure:
Fields
[in] lineIndex (uint64_t
):
[in] painter (referenced PBPainter):
[in] [indirect] lineBounds (PBRectangle):
PBVirtualTextDrawRegionRequest
Structure:
Fields
[in] lineIndex (uint64_t
):
[in] painter (referenced PBPainter):
[in] regionIndex (uint8_t
):
[in] regionBounds (PBRectangle):
[in] selFrom (int32_t
):
[in] selTo (int32_t
):
PBMessageVirtualTextDrawRegion
Structure:
Fields
[in] [indirect] request (PBVirtualTextDrawRegionRequest):
PBMessageVirtualTextSelectionChanged
Structure:
Fields
[in] fromRegionSwitch (bool
):
PBVirtualTextViewFlags
Enumeration/bitset of type uint32_t:
Constants
PBVirtualTextView_ALLOW_SELECTION
PBVirtualTextView_ALLOW_SELECTION = 1<<7
Allow the user to select and copy the text in the view.
PBVirtualTextView_USE_CARET
PBVirtualTextView_USE_CARET = 1<<0
Show a caret and allow it to be moved without creating a selection.
PBVirtualTextView_SCROLL_ACCESSORIES
PBVirtualTextView_SCROLL_ACCESSORIES = 1<<1
Horizontally scroll the accessory elements along with the main content.
Or any of the values from PBElementFlags.
PBVirtualTextViewAccessory
Enumeration/bitset of type int32_t:
Constants
PBVirtualTextViewAccessory_HEADER
PBVirtualTextViewAccessory_HEADER = 1
Shown at the top of the view, regardless of scroll position.
PBVirtualTextViewAccessory_FOOTER
PBVirtualTextViewAccessory_FOOTER = 2
Shown at the bottom of the view, regardless of scroll position.
PBVirtualTextViewAccessory_PREAMBLE
PBVirtualTextViewAccessory_PREAMBLE = 3
Shown before the start of the main text content.
PBVirtualTextViewAccessory_POSTAMBLE
PBVirtualTextViewAccessory_POSTAMBLE = 4
Shown after the end of the main text content.
PBVirtualTextViewRegionFlags
Enumeration/bitset of type uint32_t:
Constants
PBVirtualTextViewRegion_AUTO_GROW
PBVirtualTextViewRegion_AUTO_GROW = 1<<0
PBVirtualTextViewRegion_RIGHT_ALIGN_CELLS
PBVirtualTextViewRegion_RIGHT_ALIGN_CELLS = 1<<1
PBVirtualTextViewRegion_EXTEND_HIT_BOX
PBVirtualTextViewRegion_EXTEND_HIT_BOX = 1<<2
Extend the hit box of this region to the right side of the view. This flag is only valid on the last region in the view, and is ignored if the horizontal scroll bar is enabled.
PBVirtualTextViewRegion_FIXED
PBVirtualTextViewRegion_FIXED = 1<<3
Do not scroll this region horizontally. This flag can only be set on the first and last region. In the former case, the region is fixed on the left side of the view. In the latter case, it is fixed on the right side.
PBVirtualTextViewRegion_ALLOW_SELECTION
PBVirtualTextViewRegion_ALLOW_SELECTION = 1<<7
PBVirtualTextViewRegion
Structure:
Fields
flags (PBVirtualTextViewRegionFlags):
leftMarginDp (int32_t
):
leftMarginInMonospacedGlyphs (int32_t
):
rightMarginDp (int32_t
):
rightMarginInMonospacedGlyphs (int32_t
):
widthDp (int32_t
):
widthInMonospacedGlyphs (int32_t
):
PBVirtualTextViewCreate
Function:
Syntax (C/C++)
PBVirtualTextViewPtr _Nullable PBVirtualTextViewCreate(PBScrollViewRef parent,
PBVirtualTextViewFlags flags);
Syntax (Python)
VirtualTextViewCreate(parent, flags) -> (textView)
Parameters and Return Values
[in] parent (referenced PBScrollView):
[in] flags (PBVirtualTextViewFlags):
[out] textView (nullable owned PBVirtualTextView):
PBVirtualTextViewInsert
Function:
Syntax (C/C++)
void PBVirtualTextViewInsert(PBVirtualTextViewRef textView, uint64_t firstIndex,
uint64_t count);
Syntax (Python)
VirtualTextViewInsert(textView, firstIndex, count)
Parameters and Return Values
[in] textView (referenced PBVirtualTextView):
[in] firstIndex (uint64_t
):
[in] count (uint64_t
):
PBVirtualTextViewRemove
Function:
Syntax (C/C++)
void PBVirtualTextViewRemove(PBVirtualTextViewRef textView, uint64_t firstIndex,
uint64_t count);
Syntax (Python)
VirtualTextViewRemove(textView, firstIndex, count)
Parameters and Return Values
[in] textView (referenced PBVirtualTextView):
[in] firstIndex (uint64_t
):
[in] count (uint64_t
):
PBVirtualTextViewRemoveAll
Function:
Syntax (C/C++)
void PBVirtualTextViewRemoveAll(PBVirtualTextViewRef textView);
Syntax (Python)
VirtualTextViewRemoveAll(textView)
Parameters and Return Values
[in] textView (referenced PBVirtualTextView):
PBVirtualTextViewInvalidate
Function:
Syntax (C/C++)
void PBVirtualTextViewInvalidate(PBVirtualTextViewRef textView,
uint64_t firstIndex, uint64_t count);
Syntax (Python)
VirtualTextViewInvalidate(textView, firstIndex, count)
Parameters and Return Values
[in] textView (referenced PBVirtualTextView):
[in] firstIndex (uint64_t
):
[in] count (uint64_t
):
PBVirtualTextViewInvalidateAll
Function:
Syntax (C/C++)
void PBVirtualTextViewInvalidateAll(PBVirtualTextViewRef textView);
Syntax (Python)
VirtualTextViewInvalidateAll(textView)
Parameters and Return Values
[in] textView (referenced PBVirtualTextView):
PBVirtualTextViewSetTextStyle
Function:
Syntax (C/C++)
void PBVirtualTextViewSetTextStyle(PBVirtualTextViewRef view,
PBTextStyleRef textStyle);
Syntax (Python)
VirtualTextViewSetTextStyle(view, textStyle)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] textStyle (referenced PBTextStyle):
PBVirtualTextViewGetLineHeight
Function:
Syntax (C/C++)
int64_t PBVirtualTextViewGetLineHeight(PBVirtualTextViewRef view);
Syntax (Python)
VirtualTextViewGetLineHeight(view) -> (lineHeight)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[out] lineHeight (int64_t
):
PBVirtualTextViewSetLongestLine
Function:
Syntax (C/C++)
void PBVirtualTextViewSetLongestLine(PBVirtualTextViewRef view,
int32_t longestLineSizePx);
Syntax (Python)
VirtualTextViewSetLongestLine(view, longestLineSizePx)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] longestLineSizePx (int32_t
):
PBVirtualTextViewSetAccessory
Function:
Syntax (C/C++)
void PBVirtualTextViewSetAccessory(PBVirtualTextViewRef view,
PBElementRef childElement, PBVirtualTextViewAccessory accessory);
Syntax (Python)
VirtualTextViewSetAccessory(view, childElement, accessory)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] childElement (referenced PBElement):
[in] accessory (PBVirtualTextViewAccessory):
PBVirtualTextViewSetRegions
Function:
Syntax (C/C++)
void PBVirtualTextViewSetRegions(PBVirtualTextViewRef view,
const PBVirtualTextViewRegion *_Nullable regions, size_t regionsCount);
Syntax (Python)
VirtualTextViewSetRegions(view, regions)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] regions (referenced array of PBVirtualTextViewRegion):
PBVirtualTextViewGetSelection
Function:
Syntax (C/C++)
uint8_t PBVirtualTextViewGetSelection(PBVirtualTextViewRef view,
/* output */ uint64_t * _Nullable __restrict anchorLine,
/* output */ uint32_t * _Nullable __restrict anchorByte,
/* output */ uint64_t * _Nullable __restrict caretLine,
/* output */ uint32_t * _Nullable __restrict caretByte);
Syntax (Python)
VirtualTextViewGetSelection(view) -> (regionIndex, anchorLine, anchorByte, caretLine, caretByte)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[out] regionIndex (uint8_t
):
[optional-out] anchorLine (uint64_t
):
[optional-out] anchorByte (uint32_t
):
[optional-out] caretLine (uint64_t
):
[optional-out] caretByte (uint32_t
):
PBVirtualTextViewSetSelection
Function:
Syntax (C/C++)
void PBVirtualTextViewSetSelection(PBVirtualTextViewRef view,
uint8_t regionIndex, uint64_t anchorLine, uint32_t anchorByte,
uint64_t caretLine, uint32_t caretByte, bool sendSelectionChangedMessage,
PBEnsureVisibleMode ensureCaretVisible);
Syntax (Python)
VirtualTextViewSetSelection(view, regionIndex, anchorLine, anchorByte, caretLine, caretByte, sendSelectionChangedMessage, ensureCaretVisible)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] regionIndex (uint8_t
):
[in] anchorLine (uint64_t
):
[in] anchorByte (uint32_t
):
[in] caretLine (uint64_t
):
[in] caretByte (uint32_t
):
[in] sendSelectionChangedMessage (bool
):
[in] ensureCaretVisible (PBEnsureVisibleMode):
PBVirtualTextViewHitTest
Function:
Syntax (C/C++)
int64_t PBVirtualTextViewHitTest(PBVirtualTextViewRef view, int32_t x, int32_t y,
/* output */ uint8_t * _Nullable __restrict region);
Syntax (Python)
VirtualTextViewHitTest(view, x, y) -> (line, region)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] x (int32_t
):
[in] y (int32_t
):
[out] line (int64_t
):
[optional-out] region (uint8_t
):
PBTextSelectionAdjustment
Enumeration/bitset of type uint32_t: Modes for adjusting a selection.
Constants
PBTextSelectionAdjustment_WORD_GRANULARITY
PBTextSelectionAdjustment_WORD_GRANULARITY = 1<<0
Move by words at a time instead of characters.
PBTextSelectionAdjustment_LINE_GRANULARITY
PBTextSelectionAdjustment_LINE_GRANULARITY = 1<<1
Move by lines at a time instead of characters.
PBTextSelectionAdjustment_ALL_GRANULARITY
PBTextSelectionAdjustment_ALL_GRANULARITY = 1<<2
Move to the very start and end of the document.
PBTextSelectionAdjustment_BACKWARDS
PBTextSelectionAdjustment_BACKWARDS = 1<<3
If set, move backwards. If clear, move forwards.
PBTextSelectionAdjustment_MAKE_SELECTION
PBTextSelectionAdjustment_MAKE_SELECTION = 1<<4
If set, the caret is moved and the anchor stays fixed. If not set, the anchor is afterwards moved to the same position as the caret.
PBTextSelectionAdjustment_IN_LINE_GRANULARITY
PBTextSelectionAdjustment_IN_LINE_GRANULARITY = 1<<5
Move to the start of end of the line.
PBTextSelectionAdjustment_LINE_ENDS_GRANULARITY
PBTextSelectionAdjustment_LINE_ENDS_GRANULARITY = 1<<7
Move between the far ends of each line.
PBVirtualTextViewAdjustSelection
Function: Adjust the selection in a virtual text view.
Syntax (C/C++)
void PBVirtualTextViewAdjustSelection(PBVirtualTextViewRef view,
PBTextSelectionAdjustment mode, bool sendSelectionChangedMessage,
PBEnsureVisibleMode ensureCaretVisible);
Syntax (Python)
VirtualTextViewAdjustSelection(view, mode, sendSelectionChangedMessage, ensureCaretVisible)
Parameters and Return Values
[in] view (referenced PBVirtualTextView):
[in] mode (PBTextSelectionAdjustment):
[in] sendSelectionChangedMessage (bool
):
[in] ensureCaretVisible (PBEnsureVisibleMode):
Discussion
The caret and anchor are moved as specified by the mode flags.