summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cameron <bcameron@src.gnome.org>2001-06-01 13:36:33 +0000
committerBrian Cameron <bcameron@src.gnome.org>2001-06-01 13:36:33 +0000
commit71ac8b14920478ef8ca3ac11cb4c6a791feae0d2 (patch)
tree7da11bb73a61ba7eb392bbbcc64273f2ee69a417
parent136522fb7340f6d68368ba48f2789a8317ec7875 (diff)
downloadatk-71ac8b14920478ef8ca3ac11cb4c6a791feae0d2.tar.gz
Added new logic for handling multiple select regions to atktext.[ch].
Removed redundant logic from atkeditabletext.[ch].
-rwxr-xr-xatk/atkeditabletext.c28
-rwxr-xr-xatk/atkeditabletext.h6
-rwxr-xr-xatk/atktext.c142
-rwxr-xr-xatk/atktext.h42
4 files changed, 131 insertions, 87 deletions
diff --git a/atk/atkeditabletext.c b/atk/atkeditabletext.c
index 43d2096..228db16 100755
--- a/atk/atkeditabletext.c
+++ b/atk/atkeditabletext.c
@@ -47,34 +47,6 @@ atk_editable_text_get_type ()
return type;
}
-
-/**
- * atk_editable_text_select_text:
- * @text: an #AtkEditableText
- * @start_pos: start position
- * @end_pos: end position
- *
- * Select text between @start_pos and @end_pos. The characters that are selected
- * are those characters at positions from @start_pos up to, but not including
- * @end_pos. If @end_pos is negative, then the characters selected
- * will be those characters from start_pos to the end of the text.
- **/
-void
-atk_editable_text_select_text (AtkEditableText *text,
- gint start_pos,
- gint end_pos)
-{
- AtkEditableTextIface *iface;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
-
- iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
-
- if (iface->select_text)
- (*(iface->select_text)) (text, start_pos, end_pos);
-}
-
/**
* atk_editable_text_set_attributes:
* @text: an #AtkEditableText
diff --git a/atk/atkeditabletext.h b/atk/atkeditabletext.h
index 46ce9e5..e4fd654 100755
--- a/atk/atkeditabletext.h
+++ b/atk/atkeditabletext.h
@@ -47,9 +47,6 @@ struct _AtkEditableTextIface
{
GTypeInterface parent_interface;
- void (* select_text) (AtkEditableText *text,
- gint start_pos,
- gint end_pos);
void (* set_attributes) (AtkEditableText *text,
gint start_pos,
gint end_pos,
@@ -74,9 +71,6 @@ struct _AtkEditableTextIface
};
GType atk_editable_text_get_type (void);
-void atk_editable_text_select_text (AtkEditableText *text,
- gint start_pos,
- gint end_pos);
void atk_editable_text_set_attributes (AtkEditableText *text,
gint start_pos,
gint end_pos,
diff --git a/atk/atktext.c b/atk/atktext.c
index a1798c3..18bd2d5 100755
--- a/atk/atktext.c
+++ b/atk/atktext.c
@@ -430,15 +430,48 @@ atk_text_get_offset_at_point (AtkText *text,
}
/**
- * atk_text_get_selected_text
+ * atk_text_get_n_selections
* @text: an #AtkText
*
- * Gets the selected text.
+ * Gets the number of selected regions.
+ *
+ * Returns: The number of selected regions, or -1 if a failure
+ * occurred.
+ **/
+gint
+atk_text_get_n_selections (AtkText *text)
+{
+ AtkTextIface *iface;
+
+ g_return_val_if_fail (text != NULL, -1);
+ 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 corrispond 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_selected_text (AtkText *text)
+atk_text_get_selection (AtkText *text, gint selection_num,
+ gint *start_offset, gint *end_offset)
{
AtkTextIface *iface;
@@ -447,57 +480,57 @@ atk_text_get_selected_text (AtkText *text)
iface = ATK_TEXT_GET_IFACE (text);
- if (iface->get_selected_text)
- return (*(iface->get_selected_text)) (text);
+ if (iface->get_selection)
+ {
+ return (*(iface->get_selection)) (text, selection_num,
+ start_offset, end_offset);
+ }
else
return NULL;
}
/**
- * atk_text_get_selection_bounds
+ * atk_text_add_selection
* @text: an #AtkText
- * @start_offset: start position
- * @end_offset: end position
+ * @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.
*
- * @start_offset and @end_offset are filled with the
- * current selection bounds.
+ * Returns: %TRUE if success, %FALSE otherwise
**/
-void
-atk_text_get_selection_bounds (AtkText *text,
- gint *start_offset,
- gint *end_offset)
+gboolean
+atk_text_add_selection (AtkText *text, gint start_offset,
+ gint end_offset)
{
AtkTextIface *iface;
- g_return_if_fail (text != NULL);
- g_return_if_fail (ATK_IS_TEXT (text));
+ g_return_val_if_fail (text != NULL, FALSE);
+ g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
iface = ATK_TEXT_GET_IFACE (text);
- if (iface->get_selection_bounds)
- (*(iface->get_selection_bounds)) (text, start_offset, end_offset);
+ if (iface->add_selection)
+ return (*(iface->add_selection)) (text, start_offset, end_offset);
else
- {
- *start_offset = 0;
- *end_offset = 0;
- }
+ return FALSE;
}
/**
- * atk_text_set_selection_bounds
+ * atk_text_remove_selection
* @text: an #AtkText
- * @start_offset: start position
- * @end_offset: end position
+ * @selection_num: The selection number. The selected regions are
+ * assigned numbers that corrispond 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.
*
- * The selection bounds are set to the specified @start_offset
- * and @end_offset values.
- *
- * Returns: %TRUE if success, %FALSE otherwise.
+ * Removes the specified selection
+ *
+ * Returns: %TRUE if success, %FALSE otherwise
**/
gboolean
-atk_text_set_selection_bounds (AtkText *text,
- gint start_offset,
- gint end_offset)
+atk_text_remove_selection (AtkText *text, gint selection_num)
{
AtkTextIface *iface;
@@ -506,14 +539,45 @@ atk_text_set_selection_bounds (AtkText *text,
iface = ATK_TEXT_GET_IFACE (text);
- if (iface->set_selection_bounds)
- {
- return (*(iface->set_selection_bounds)) (text, start_offset, end_offset);
- }
+ if (iface->remove_selection)
+ return (*(iface->remove_selection)) (text, selection_num);
else
- {
- return FALSE;
- }
+ return FALSE;
+}
+
+/**
+ * atk_text_set_selection
+ * @text: an #AtkText
+ * @selection_num: The selection number. The selected regions are
+ * assigned numbers that corrispond 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
+ **/
+gboolean
+atk_text_set_selection (AtkText *text, gint selection_num,
+ gint start_offset, gint end_offset)
+{
+ AtkTextIface *iface;
+
+ g_return_val_if_fail (text != NULL, FALSE);
+ 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;
}
/**
diff --git a/atk/atktext.h b/atk/atktext.h
index edd3801..ca07507 100755
--- a/atk/atktext.h
+++ b/atk/atktext.h
@@ -100,13 +100,20 @@ struct _AtkTextIface
gint (* get_offset_at_point) (AtkText *text,
gint x,
gint y);
- gchar* (* get_selected_text) (AtkText *text);
- void (* get_selection_bounds) (AtkText *text,
- gint *start_offset,
- gint *end_offset);
- gboolean (* set_selection_bounds) (AtkText *text,
- gint start_offset,
- gint end_offset);
+ gint (* get_n_selections) (AtkText *text);
+ gchar* (* get_selection) (AtkText *text,
+ gint selection_num,
+ gint *start_offset,
+ gint *end_offset);
+ gboolean (* add_selection) (AtkText *text,
+ gint start_offset,
+ gint end_offset);
+ gboolean (* remove_selection) (AtkText *text,
+ gint selection_num);
+ gboolean (* set_selection) (AtkText *text,
+ gint selection_num,
+ gint start_offset,
+ gint end_offset);
gboolean (* set_caret_offset) (AtkText *text,
gint offset);
void (* text_changed) (AtkText *text);
@@ -155,13 +162,20 @@ gint atk_text_get_character_count (AtkText *tex
gint atk_text_get_offset_at_point (AtkText *text,
gint x,
gint y);
-gchar* atk_text_get_selected_text (AtkText *text);
-void atk_text_get_selection_bounds (AtkText *text,
- gint *start_offset,
- gint *end_offset);
-gboolean atk_text_set_selection_bounds (AtkText *text,
- gint start_offset,
- gint end_offset);
+gint atk_text_get_n_selections (AtkText *text);
+gchar* atk_text_get_selection (AtkText *text,
+ gint selection_num,
+ gint *start_offset,
+ gint *end_offset);
+gboolean atk_text_add_selection (AtkText *text,
+ gint start_offset,
+ gint end_offset);
+gboolean atk_text_remove_selection (AtkText *text,
+ gint selection_num);
+gboolean atk_text_set_selection (AtkText *text,
+ gint selection_num,
+ gint start_offset,
+ gint end_offset);
gboolean atk_text_set_caret_offset (AtkText *text,
gint offset);