[evolution/wip/webkit-composer: 272/372] Make functions that works with composer caret public.
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 272/372] Make functions that works with composer caret public.
- Date: Thu, 6 Feb 2014 11:46:22 +0000 (UTC)
commit 5ebf872b95ee29dd3d78bbd7799d1cfe4ad6f741
Author: Tomas Popela <tpopela redhat com>
Date: Tue Jul 2 11:21:05 2013 +0200
Make functions that works with composer caret public.
They will be utilized in other modules when we implement the savings of caret
position while switching composer modes.
e-util/e-editor-selection.c | 46 ++++++++++++++++++++++++++++++------------
e-util/e-editor-selection.h | 6 +++++
2 files changed, 39 insertions(+), 13 deletions(-)
---
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index 347f24d..c68f013 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -2506,8 +2506,14 @@ e_editor_selection_insert_image (EEditorSelection *selection,
g_object_unref (editor_widget);
}
-static void
-clear_caret_position_marker (EEditorSelection *selection)
+/**
+ * e_editor_selection_clear_caret_position_marker:
+ * @selection: an #EEditorSelection
+ *
+ * Removes previously set caret position marker from composer.
+ */
+void
+e_editor_selection_clear_caret_position_marker (EEditorSelection *selection)
{
EEditorWidget *widget;
WebKitDOMDocument *document;
@@ -2532,8 +2538,14 @@ clear_caret_position_marker (EEditorSelection *selection)
g_object_unref (widget);
}
-static void
-save_caret_position (EEditorSelection *selection)
+/**
+ * e_editor_selection_save_caret_position:
+ * @selection: an #EEditorSelection
+ *
+ * Saves current caret position in composer.
+ */
+void
+e_editor_selection_save_caret_position (EEditorSelection *selection)
{
EEditorWidget *widget;
WebKitDOMDocument *document;
@@ -2549,9 +2561,11 @@ save_caret_position (EEditorSelection *selection)
g_return_if_fail (widget != NULL);
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
- clear_caret_position_marker (selection);
+ e_editor_selection_clear_caret_position_marker (selection);
range = editor_selection_get_current_range (selection);
+ if (!range)
+ return;
start_offset = webkit_dom_range_get_start_offset (range, NULL);
start_offset_node = webkit_dom_range_get_end_container (range, NULL);
@@ -2599,8 +2613,14 @@ move_caret_into_element (WebKitDOMDocument *document,
webkit_dom_dom_selection_add_range (window_selection, new_range);
}
-static void
-restore_caret_position (EEditorSelection *selection)
+/**
+ * e_editor_selection_restore_caret_position:
+ * @selection: an #EEditorSelection
+ *
+ * Restores previously saved caret position in composer.
+ */
+void
+e_editor_selection_restore_caret_position (EEditorSelection *selection)
{
EEditorWidget *widget;
WebKitDOMDocument *document;
@@ -3048,7 +3068,7 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
if (!range)
return;
- save_caret_position (selection);
+ e_editor_selection_save_caret_position (selection);
start_offset = webkit_dom_range_get_start_offset (range, NULL);
/* Extend the range to include entire nodes */
@@ -3094,7 +3114,7 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
}
} else {
/* When some weird element is selected, return */
- clear_caret_position_marker (selection);
+ e_editor_selection_clear_caret_position_marker (selection);
return;
}
}
@@ -3119,14 +3139,14 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
if (g_utf8_strlen (e_editor_selection_get_string (selection), -1) <
selection->priv->word_wrap_length) {
if (return_pressed) {
active_paragraph = webkit_dom_document_get_element_by_id (document,
"-x-evo-active-paragraph");
- clear_caret_position_marker (selection);
+ e_editor_selection_clear_caret_position_marker (selection);
move_caret_into_element (document, active_paragraph);
webkit_dom_dom_selection_modify (window_selection, "move", "forward",
"character");
webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT
(active_paragraph), "id");
} else {
active_paragraph = webkit_dom_document_get_element_by_id (document,
"-x-evo-active-paragraph");
webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT
(active_paragraph), "id");
- restore_caret_position (selection);
+ e_editor_selection_restore_caret_position (selection);
}
return;
}
@@ -3193,11 +3213,11 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
/* We have to move caret on position where it was before modifying the text */
if (return_pressed) {
active_paragraph = webkit_dom_document_get_element_by_id (document,
"-x-evo-active-paragraph");
- clear_caret_position_marker (selection);
+ e_editor_selection_clear_caret_position_marker (selection);
move_caret_into_element (document, active_paragraph);
webkit_dom_dom_selection_modify (window_selection, "move", "forward", "character");
} else {
- restore_caret_position (selection);
+ e_editor_selection_restore_caret_position (selection);
}
/* Set paragraph as non-active */
diff --git a/e-util/e-editor-selection.h b/e-util/e-editor-selection.h
index ae4834a..4c97de4 100644
--- a/e-util/e-editor-selection.h
+++ b/e-util/e-editor-selection.h
@@ -154,6 +154,12 @@ void e_editor_selection_insert_image (EEditorSelection *selection,
const gchar *image_uri);
void e_editor_selection_insert_text (EEditorSelection *selection,
const gchar *plain_text);
+void e_editor_selection_clear_caret_position_marker
+ (EEditorSelection *selection);
+void e_editor_selection_save_caret_position
+ (EEditorSelection *selection);
+void e_editor_selection_restore_caret_position
+ (EEditorSelection *selection);
void e_editor_selection_wrap_lines (EEditorSelection *selection,
gboolean while_typing,
GdkEventKey *event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]