[evolution/webkit-composer: 208/231] Fix caret handling after hitting the BackSpace key.
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 208/231] Fix caret handling after hitting the BackSpace key.
- Date: Fri, 13 Sep 2013 14:23:27 +0000 (UTC)
commit a7a8999c14ff2720a47df094fb0540b7bc70db87
Author: Tomas Popela <tpopela redhat com>
Date: Tue Jul 2 11:48:34 2013 +0200
Fix caret handling after hitting the BackSpace key.
e-util/e-editor-selection.c | 31 ++++++++++++++++++++++++++-----
1 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index 56f070b..2223156 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -3026,6 +3026,7 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
WebKitDOMDOMSelection *window_selection;
WebKitDOMElement *active_paragraph;
gboolean adding = FALSE;
+ gboolean backspace_pressed = FALSE;
gboolean return_pressed = FALSE;
gboolean delete_pressed = FALSE;
gboolean jump_to_previous_line = FALSE;
@@ -3049,6 +3050,9 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
if (return_pressed || (event->keyval == GDK_KEY_space))
adding = TRUE;
+
+ if (event->keyval == GDK_KEY_BackSpace)
+ backspace_pressed = TRUE;
}
web_view = WEBKIT_WEB_VIEW (editor_widget);
@@ -3130,24 +3134,41 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
if (!adding && start_offset > selection->priv->word_wrap_length)
jump_to_previous_line = TRUE;
} else {
+ WebKitDOMElement *caret_position;
+ gboolean parent_is_body = FALSE;
+
+ caret_position = webkit_dom_document_get_element_by_id (document,
"-x-evo-caret-position");
+
webkit_dom_dom_selection_select_all_children (
window_selection,
paragraph,
NULL);
+ if (WEBKIT_DOM_IS_HTML_BODY_ELEMENT (webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE
(caret_position))))
+ parent_is_body = TRUE;
+
+ if (backspace_pressed && parent_is_body) {
+ WebKitDOMElement *prev_sibling =
webkit_dom_element_get_previous_element_sibling (caret_position);
+ move_caret_into_element (document, prev_sibling);
+ e_editor_selection_clear_caret_position_marker (selection);
+ webkit_dom_dom_selection_modify (window_selection, "move", "forward",
"character");
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (paragraph), "id");
+
+ return;
+ }
+
/* If there is less than word_wrap_length characters do nothing */
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");
e_editor_selection_clear_caret_position_marker (selection);
- move_caret_into_element (document, active_paragraph);
+ move_caret_into_element (document, WEBKIT_DOM_ELEMENT (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");
e_editor_selection_restore_caret_position (selection);
}
+
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (paragraph), "id");
+
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]