TextBoundaryFinder
Base classes
⋔ Inheritance diagram
graph TD
616128446["core.TextBoundaryFinder"]
2514175802["QtCore.QTextBoundaryFinder"]
37984305["Shiboken.Object"]
2751680898["builtins.object"]
2514175802 --> 616128446
37984305 --> 2514175802
2751680898 --> 37984305
🛈 DocStrings
Bases: QTextBoundaryFinder
Way of finding Unicode text boundaries in a string.
Source code in prettyqt/core/textboundaryfinder.py
| class TextBoundaryFinder(QtCore.QTextBoundaryFinder):
"""Way of finding Unicode text boundaries in a string."""
def __init__(
self,
string_or_other: str | QtCore.QTextBoundaryFinder = "",
boundary_type: (
QtCore.QTextBoundaryFinder.BoundaryType | BoundaryTypeStr
) = "grapheme",
):
if isinstance(string_or_other, QtCore.QTextBoundaryFinder):
super().__init__(string_or_other)
else:
if isinstance(boundary_type, str):
typ = BOUNDARY_TYPES[boundary_type]
else:
typ = boundary_type
super().__init__(typ, string_or_other)
def __repr__(self):
return get_repr(self, self.string())
def __reduce__(self):
return type(self), (self.string(), self.type())
def __iter__(self):
pos = self.position()
self.setPosition(0)
p = 0
# if self.isAtBoundary():
# yield 0
while p != -1:
p = self.toNextBoundary()
if p != -1:
yield p
self.setPosition(pos)
def get_boundary_type(self) -> BoundaryTypeStr:
return BOUNDARY_TYPES.inverse[self.type()]
def get_boundary_reasons(self) -> list[BoundaryReasonStr]:
return BOUNDARY_REASONS.get_list(self.boundaryReasons())
|
:fa-brands-github: Show source on GitHub