atk.Textthe ATK interface implemented by components with text
content.Synopsisatk.Textgobject.GInterfaceget_textstart_offsetend_offsetget_character_at_offsetoffsetget_text_after_offsetoffsetboundary_typeget_text_at_offsetoffsetboundary_typeget_text_before_offsetoffsetboundary_typeget_caret_offsetget_character_extentsoffsetcoordsget_run_attributesoffsetget_default_attributesget_character_countget_offset_at_pointxycoordsget_n_selectionsget_selectionselection_numadd_selectionstart_offsetend_offsetremove_selectionselection_numset_selectionselection_numstart_offsetend_offsetset_caret_offsetoffsetget_range_extentsstart_offsetend_offsetcoord_typeget_bounded_rangesrectcoord_typex_clip_typey_clip_typeFunctionsatk.text_attribute_get_nameattratk.text_attribute_get_valueattrindexatk.text_attribute_registernameatk.text_attribute_for_namenameatk.Text Signal Prototypes"text-attributes-changed"callbackatktextuser_param1..."text-caret-moved"callbackatktextpositionuser_param1..."text-changed"callbackatktextpositionlengthuser_param1..."text-selection-changed"callbackatktextuser_param1...Descriptionatk.Text should be
implemented by atk.Object
objects on behalf of widgets that have text content which is either
attributed or otherwise non-trivial. atk.Object
objects whose text content is simple, unattributed, and very brief may
expose that content via atk.Object.get_name
instead; however if the text is editable, multi-line, typically longer
than three or four words, attributed, selectable, or if the object
already uses the 'name' ATK property for other information, the atk.Text interface
should be used to expose the text content. In the case of editable text
content, atk.EditableText
(a subtype of the atk.Text
interface) should be implemented instead.atk.Text provides
not only traversal facilities and change notification for text content,
but also caret tracking and glyph bounding box calculations. Note that
the text strings are exposed as UTF-8, and are therefore potentially
multi-byte, and caret-to-byte offset mapping makes no assumptions about
the character length; also bounding box glyph-to-offset mapping may be
complex for languages which use ligatures.Methodsatk.Text.get_textget_textstart_offsetend_offsetstart_offset :start positionend_offset :end positionReturns :the text from
start_offset up to, but not including
end_offset.Gets the specified text.atk.Text.get_character_at_offsetget_character_at_offsetoffsetoffset :positionReturns :the character at
offset.Gets the specified text.atk.Text.get_text_after_offsetget_text_after_offsetoffsetboundary_typeoffset :positionboundary_type :one of the Returns :a 3-tuple containing the text after
offset bounded by the specified
boundary_type, the start offset of the
returned string and the offset of the first character after the
returned substring.Gets the specified text.If the boundary_type is
atk.TEXT_BOUNDARY_CHAR the character after the
offset is returned.If the boundary_type is
atk.TEXT_BOUNDARY_WORD_START the returned string is
from the word start after the offset to the next word start.The returned string will contain the word after the offset if
the offset is inside a word or if the offset is not inside a
word.If the boundary_type is
atk.TEXT_BOUNDARY_WORD_END the returned string is
from the word end at or after the offset to the next work end.The returned string will contain the word after the offset if
the offset is inside a word and will contain the word after the word
after the offset if the offset is not inside a word.If the boundary_type is
atk.TEXT_BOUNDARY_SENTENCE_START the returned
string is from the sentence start after the offset to the next
sentence start.The returned string will contain the sentence after the offset
if the offset is inside a sentence or if the offset is not inside a
sentence.If the boundary_type is atk.TEXT_BOUNDARY_SENTENCE_END the
returned string is from the sentence end at or after the offset to the
next sentence end.The returned string will contain the sentence after the offset
if the offset is inside a sentence and will contain the sentence after
the sentence after the offset if the offset is not inside a
sentence.If the boundary_type is
atk.TEXT_BOUNDARY_LINE_START the returned string is
from the line start after the offset to the next line start.If the boundary_type is
atk.TEXT_BOUNDARY_LINE_END the returned string is
from the line end at or after the offset to the next line
start.atk.Text.get_text_at_offsetget_text_at_offsetoffsetboundary_typeoffset :positionboundary_type :one of the Returns :a 3-tuple containing the text at
offset bounded by the specified
boundary_type, the start offset of the
returned string and the offset of the first character after the
returned substring.Gets the specified text.If the boundary_type if
atk.TEXT_BOUNDARY_CHAR the character at the offset
is returned.If the boundary_type is
atk.TEXT_BOUNDARY_WORD_START the returned string is
from the word start at or before the offset to the word start after
the offset.The returned string will contain the word at the offset if the
offset is inside a word and will contain the word before the offset if
the offset is not inside a word.If the boundary_type is
atk.TEXT_BOUNDARY_WORD_END the returned string is
from the word end before the offset to the word end at or after the
offset.The returned string will contain the word at the offset if the
offset is inside a word and will contain the word after to the offset
if the offset is not inside a word.If the boundary_type is
atk.TEXT_BOUNDARY_SENTENCE_START the returned
string is from the sentence start at or before the offset to the
sentence start after the offset.The returned string will contain the sentence at the offset if
the offset is inside a sentence and will contain the sentence before
the offset if the offset is not inside a sentence.If the boundary_type is
atk.TEXT_BOUNDARY_SENTENCE_END the returned string
is from the sentence end before the offset to the sentence end at or
after the offset.The returned string will contain the sentence at the offset if
the offset is inside a sentence and will contain the sentence after
the offset if the offset is not inside a sentence.If the boundary_type is
atk.TEXT_BOUNDARY_LINE_START the returned string is
from the line start at or before the offset to the line start after
the offset.If the boundary_type is
atk.TEXT_BOUNDARY_LINE_END the returned string is
from the line end before the offset to the line end at or after the
offset.atk.Text.get_text_before_offsetget_text_before_offsetoffsetboundary_typeoffset :positionboundary_type :one of the Returns :a 3-tuple containing the text before
offset bounded by the specified
boundary_type, the start offset of the
returned string and the offset of the first character after the
returned substring.Gets the specified text.If the boundary_type if
atk.TEXT_BOUNDARY_CHAR the character before the
offset is returned.If the boundary_type is
atk.TEXT_BOUNDARY_WORD_START the returned string is
from the word start before the word start before the offset to the
word start before the offset.The returned string will contain the word before the offset if
the offset is inside a word and will contain the word before the word
before the offset if the offset is not inside a word.If the boundary_type is
atk.TEXT_BOUNDARY_WORD_END the returned string is
from the word end before the word end at or before the offset to the
word end at or before the offset.The returned string will contain the word before the offset if
the offset is inside a word or if the offset is not inside a
word.If the boundary_type is
atk.TEXT_BOUNDARY_SENTENCE_START the returned
string is from the sentence start before the sentence start before the
offset to the sentence start before the offset.The returned string will contain the sentence before the offset
if the offset is inside a sentence and will contain the sentence
before the sentence before the offset if the offset is not inside a
sentence.If the boundary_type is
atk.TEXT_BOUNDARY_SENTENCE_END the returned string
is from the sentence end before the sentence end at or before the
offset to the sentence end at or before the offset.The returned string will contain the sentence before the offset
if the offset is inside a sentence or if the offset is not inside a
sentence.If the boundary_type is
atk.TEXT_BOUNDARY_LINE_START the returned string is
from the line start before the line start ar or before the offset to
the line start ar or before the offset.If the boundary_type is
atk.TEXT_BOUNDARY_LINE_END the returned string is
from the line end before the line end before the offset to the line
end before the offset.atk.Text.get_caret_offsetget_caret_offsetReturns :the offset position of the caret
(cursor).Gets the offset position of the caret (cursor).atk.Text.get_character_extentsget_character_extentsoffsetcoordsoffset :The offset of the text character for which
bounding information is required.coords :specify whether coordinates are relative to the
screen or widget window - one of the Returns :a 4-tuple containing the x, y position and
width and height of the bounding box.Get the bounding box containing the glyph representing the
character at a particular text offset.atk.Text.get_run_attributesget_run_attributesoffsetoffset :the offset at which to get the attributesstart_offset :the address to put end_offset :the address to put Returns :a 3-tuple containing an attribute set tuple,
the start offset of the range and the end offset of the range. The
attribute set tuple contains a 2-tuple of (name, value) strings
for each attribute explicitly set at
offset.Creates a 3=tuple containing an attribute set (which consists of
the attributes explicitly set at the position
offset in the text), the start and end of the
range around offset where the attributes are
invariant. Note that the end offset is the offset of the first
character after the range. See the for types of text
attributes that can be returned. Note that other attributes may also
be returned.atk.Text.get_default_attributesget_default_attributesReturns :a tuple containing the attribute set which
contains the default values of attributes. The attribute set tuple
contains a 2-tuple of (name, value) strings for each
attribute.Creates a tuple containing an attribute set which consists of
the default values of attributes for the text. The attribute set
tuple contains a 2-tuple of (name, value) strings for each attribute
See the for types of text
attributes that can be returned. Note that other attributes may also
be returned.atk.Text.get_character_countget_character_countReturns :the number of characters.Gets the character count.atk.Text.get_offset_at_pointget_offset_at_pointxycoordsx :screen x-position of
charactery :screen y-position of
charactercoords :specify whether coordinates are relative to the
screen or widget window - one of the Returns :the offset to the character which is located at
the specified x and
y coordinates.Gets the offset of the character located at coordinates
x and
y. x and
y are interpreted as being relative to the
screen or this widget's window depending on
coords.atk.Text.get_n_selectionsget_n_selectionsReturns :The number of selected regions, or -1 if a
failure occurred.Gets the number of selected regions.atk.Text.get_selectionget_selectionselection_numselection_num :The selection number. The selected regions are
assigned numbers that correspond to how far the region is from the
start of the text. The selected region closest to the beginning
of the text region is assigned the number 0, etc. Note that
adding, moving or deleting a selected region can change the
numbering.Returns :a 3-tuple containing the selected text, the
start position of the selected region and the end position of
(e.g. offset immediately past) the selected
region.Gets the text from the specified selection.atk.Text.add_selectionadd_selectionstart_offsetend_offsetstart_offset :the start position of the selected
regionend_offset :the offset of the first character after the
selected region.Returns :True if success,
False otherwiseAdds a selection bounded by the specified offsets.atk.Text.remove_selectionremove_selectionselection_numselection_num :The selection number. The selected regions are
assigned numbers that correspond to how far the region is from the
start of the text. The selected region closest to the beginning
of the text region is assigned the number 0, etc. Note that
adding, moving or deleting a selected region can change the
numbering.Returns :True if success,
False otherwiseRemoves the specified selection.atk.Text.set_selectionset_selectionselection_numstart_offsetend_offsetselection_num :The selection number. The selected regions are
assigned numbers that correspond to how far the region is from the
start of the text. The selected region closest to the beginning
of the text region is assigned the number 0, etc. Note that
adding, moving or deleting a selected region can change the
numbering.start_offset :the new start position of the
selectionend_offset :the new end position of (e.g. offset
immediately past) the selectionReturns :True if success,
False otherwiseChanges the start and end offset of the specified
selection.atk.Text.set_caret_offsetset_caret_offsetoffsetoffset :positionReturns :True if success,
False otherwise.Sets the caret (cursor) position to the specified
offset.atk.Text.get_range_extentsget_range_extentsstart_offsetend_offsetcoord_typestart_offset :The offset of the first text character for
which boundary information is required.end_offset :The offset of the text character after the last
character for which boundary information is
required.coord_type :Specify whether coordinates are relative to the
screen or widget window - one of the .Returns :a atk.Rectangle
containing the extents of the range.Get the bounding box for text within the specified range.atk.Text.get_bounded_rangesget_bounded_rangesrectcoord_typex_clip_typey_clip_typerect :An atk.Rectangle
giving the dimensions of the bounding box.coord_type :Specify whether coordinates are relative to the
screen or widget window - one of the .x_clip_type :Specify the horizontal clip type - one of the
.y_clip_type :Specify the vertical clip type - one of the
.Returns :a list of text ranges. The list contains a
4-tuple for each text range. The 4-tuple contains a atk.Rectangle
bounding the text range, the start and end offsets of the range
and the text in the range.Get the ranges of text in the specified bounding box.Functionsatk.text_attribute_get_nameatk.text_attribute_get_nameattrattr :a text attribute (one of the ) whose name is
requiredReturns :a string containing the nameGets the name corresponding to
attr.atk.text_attribute_get_valueatk.text_attribute_get_valueattrindexattr :a text attribute (one of the ) whose name is
requiredindex :The index of the required
valueReturns :a string containing the
value. None is returned if there are no values
maintained for the attr
value.Gets the value for the index of the text
attribute specified by attr.atk.text_attribute_registeratk.text_attribute_registernamename :a name stringReturns :a new one of the that is associated
with nameAssociate name with a new text
attribute.atk.text_attribute_for_nameatk.text_attribute_for_namenamename :a string which is the (non-localized) name of
an ATK text attribute.Returns :the text attribute (one of the ) corresponding to
the specified name, or
atk.TEXT_ATTRIBUTE_INVALID if no matching text
attribute is found.Get the text attribute type corresponding to a text attribute
name specified by name.SignalsThe "text-attributes-changed" atk.Text Signalcallbackatktextuser_param1...atktext :the object which received the
signal.user_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if any)The "text-attributes-changed" signal is emitted when the text
attributes of the text of an object which implements atk.Text
changes.The "text-caret-moved" atk.Text Signalcallbackatktextpositionuser_param1...atktext :the object which received the
signal.position :The new position of the text
caret.user_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if any)The "text-caret-moved" signal is emitted when the caret position
of the text of an object which implements atk.Text
changes.The "text-changed" atk.Text Signalcallbackatktextpositionlengthuser_param1...atktext :the object which received the signal.position :The position of the insertion or deletion.length :The length of text inserted or deleted.user_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if any)The "text-changed" signal is emitted when the text of the object
which implements the atk.Text
interface changes, This signal will have a detail which is either
"insert" or "delete" which identifies whether the text change was an
insertion or a deletionThe "text-selection-changed" atk.Text Signalcallbackatktextuser_param1...atktext :the object which received the signal.user_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if any)The "text-selection-changed" signal is emitted when the selected
text of an object which implements atk.Text
changes.