📄 atktext.c
字号:
atk_text_get_text_before_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset){ AtkTextIface *iface; gint local_start_offset, local_end_offset; gint *real_start_offset, *real_end_offset; g_return_val_if_fail (ATK_IS_TEXT (text), NULL); if (start_offset) real_start_offset = start_offset; else real_start_offset = &local_start_offset; if (end_offset) real_end_offset = end_offset; else real_end_offset = &local_end_offset; if (offset < 0) return NULL; iface = ATK_TEXT_GET_IFACE (text); if (iface->get_text_before_offset) return (*(iface->get_text_before_offset)) (text, offset, boundary_type, real_start_offset, real_end_offset); else return NULL;}/** * atk_text_get_caret_offset: * @text: an #AtkText * * Gets the offset position of the caret (cursor). * * Returns: the offset position of the caret (cursor). **/gintatk_text_get_caret_offset (AtkText *text){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), 0); iface = ATK_TEXT_GET_IFACE (text); if (iface->get_caret_offset) return (*(iface->get_caret_offset)) (text); else return 0;}/** * atk_text_get_character_extents: * @text: an #AtkText * @offset: The offset of the text character for which bounding information is required. * @x: Pointer for the x cordinate of the bounding box. * @y: Pointer for the y cordinate of the bounding box. * @width: Pointer for the width of the bounding box * @height: Pointer for the height of the bounding box. * @coords: specify whether coordinates are relative to the screen or widget window * * Get the bounding box containing the glyph representing the character at * a particular text offset. **/voidatk_text_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords){ AtkTextIface *iface; gint local_x, local_y, local_width, local_height; gint *real_x, *real_y, *real_width, *real_height; g_return_if_fail (ATK_IS_TEXT (text)); if (x) real_x = x; else real_x = &local_x; if (y) real_y = y; else real_y = &local_y; if (width) real_width = width; else real_width = &local_width; if (height) real_height = height; else real_height = &local_height; *real_x = 0; *real_y = 0; *real_width = 0; *real_height = 0; if (offset < 0) return; iface = ATK_TEXT_GET_IFACE (text); if (iface->get_character_extents) (*(iface->get_character_extents)) (text, offset, real_x, real_y, real_width, real_height, coords); if (*real_width <0) { *real_x = *real_x + *real_width; *real_width *= -1; }}/** *atk_text_get_run_attributes: *@text: an #AtkText *@offset: the offset at which to get the attributes *@start_offset: the address to put the start offset of the range *@end_offset: the address to put the end offset of the range * *Creates an #AtkAttributeSet which consists of the attributes explicitly *set at the position @offset in the text. @start_offset and @end_offset are *set to the start and end of the range around @offset where the attributes are *invariant. See the enum AtkTextAttribute for types of text attributes that *can be returned. Note that other attributes may also be returned. * *Returns: an #AtkAttributeSet which contains the attributes explicitly set *at @offset. This #AtkAttributeSet should be freed by a call to *atk_attribute_set_free(). **/AtkAttributeSet* atk_text_get_run_attributes (AtkText *text, gint offset, gint *start_offset, gint *end_offset){ AtkTextIface *iface; gint local_start_offset, local_end_offset; gint *real_start_offset, *real_end_offset; g_return_val_if_fail (ATK_IS_TEXT (text), NULL); if (start_offset) real_start_offset = start_offset; else real_start_offset = &local_start_offset; if (end_offset) real_end_offset = end_offset; else real_end_offset = &local_end_offset; if (offset < 0) return NULL; iface = ATK_TEXT_GET_IFACE (text); if (iface->get_run_attributes) return (*(iface->get_run_attributes)) (text, offset, real_start_offset, real_end_offset); else return NULL;}/** *atk_text_get_default_attributes: *@text: an #AtkText * *Creates an #AtkAttributeSet which consists of the default values of *attributes for the text. See the enum AtkTextAttribute for types of text *attributes that can be returned. Note that other attributes may also be *returned. * *Returns: an #AtkAttributeSet which contains the default values of attributes. *at @offset. This #AtkAttributeSet should be freed by a call to *atk_attribute_set_free(). */AtkAttributeSet* atk_text_get_default_attributes (AtkText *text){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), NULL); iface = ATK_TEXT_GET_IFACE (text); if (iface->get_default_attributes) return (*(iface->get_default_attributes)) (text); else return NULL;}/** * atk_text_get_character_count: * @text: an #AtkText * * Gets the character count. * * Returns: the number of characters. **/gintatk_text_get_character_count (AtkText *text){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), -1); iface = ATK_TEXT_GET_IFACE (text); if (iface->get_character_count) return (*(iface->get_character_count)) (text); else return -1;}/** * atk_text_get_offset_at_point: * @text: an #AtkText * @x: screen x-position of character * @y: screen y-position of character * @coords: specify whether coordinates are relative to the screen or * widget window * * 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. * * Returns: the offset to the character which is located at * the specified @x and @y coordinates. **/gintatk_text_get_offset_at_point (AtkText *text, gint x, gint y, AtkCoordType coords){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), -1); iface = ATK_TEXT_GET_IFACE (text); if (iface->get_offset_at_point) return (*(iface->get_offset_at_point)) (text, x, y, coords); else return -1;}/** * atk_text_get_n_selections: * @text: an #AtkText * * Gets the number of selected regions. * * Returns: The number of selected regions, or -1 if a failure * occurred. **/gintatk_text_get_n_selections (AtkText *text){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), -1); iface = ATK_TEXT_GET_IFACE (text); if (iface->get_n_selections) return (*(iface->get_n_selections)) (text); else return -1;}/** * atk_text_get_selection: * @text: an #AtkText * @selection_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: passes back the start position of the selected region * @end_offset: passes back the end position of the selected region * * Gets the text from the specified selection. * * Returns: the selected text. **/gchar*atk_text_get_selection (AtkText *text, gint selection_num, gint *start_offset, gint *end_offset){ AtkTextIface *iface; gint local_start_offset, local_end_offset; gint *real_start_offset, *real_end_offset; g_return_val_if_fail (ATK_IS_TEXT (text), NULL); if (start_offset) real_start_offset = start_offset; else real_start_offset = &local_start_offset; if (end_offset) real_end_offset = end_offset; else real_end_offset = &local_end_offset; iface = ATK_TEXT_GET_IFACE (text); if (iface->get_selection) { return (*(iface->get_selection)) (text, selection_num, real_start_offset, real_end_offset); } else return NULL;}/** * atk_text_add_selection: * @text: an #AtkText * @start_offset: the start position of the selected region * @end_offset: the end position of the selected region * * Adds a selection bounded by the specified offsets. * * Returns: %TRUE if success, %FALSE otherwise **/gbooleanatk_text_add_selection (AtkText *text, gint start_offset, gint end_offset){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), FALSE); iface = ATK_TEXT_GET_IFACE (text); if (iface->add_selection) return (*(iface->add_selection)) (text, start_offset, end_offset); else return FALSE;}/** * atk_text_remove_selection: * @text: an #AtkText * @selection_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. * * Removes the specified selection. * * Returns: %TRUE if success, %FALSE otherwise **/gbooleanatk_text_remove_selection (AtkText *text, gint selection_num){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), FALSE); iface = ATK_TEXT_GET_IFACE (text); if (iface->remove_selection) return (*(iface->remove_selection)) (text, selection_num); else return FALSE;}/** * atk_text_set_selection: * @text: an #AtkText * @selection_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 selection * @end_offset: the new end position of the selection * * Changes the start and end offset of the specified selection. * * Returns: %TRUE if success, %FALSE otherwise **/gbooleanatk_text_set_selection (AtkText *text, gint selection_num, gint start_offset, gint end_offset){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), FALSE); iface = ATK_TEXT_GET_IFACE (text); if (iface->set_selection) { return (*(iface->set_selection)) (text, selection_num, start_offset, end_offset); } else return FALSE;}/** * atk_text_set_caret_offset: * @text: an #AtkText * @offset: position * * Sets the caret (cursor) position to the specified @offset. * * Returns: %TRUE if success, %FALSE otherwise. **/gbooleanatk_text_set_caret_offset (AtkText *text, gint offset){ AtkTextIface *iface; g_return_val_if_fail (ATK_IS_TEXT (text), FALSE); iface = ATK_TEXT_GET_IFACE (text); if (iface->set_caret_offset) { return (*(iface->set_caret_offset)) (text, offset); } else { return FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -