[evolution] EHTMLEditorSelection - When wrapping the block take the Tab characters into account



commit b43b05b952e883aa5ed02053e418354963d65128
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Apr 3 10:26:15 2015 +0200

    EHTMLEditorSelection - When wrapping the block take the Tab characters into account

 e-util/e-html-editor-selection.c |   17 ++++++++++-------
 e-util/e-html-editor-view.c      |    7 -------
 e-util/e-html-editor-view.h      |    8 ++++++++
 3 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index eb90b0e..a41e035 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -39,13 +39,6 @@
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_HTML_EDITOR_SELECTION, EHTMLEditorSelectionPrivate))
 
-#define UNICODE_ZERO_WIDTH_SPACE "\xe2\x80\x8b"
-#define UNICODE_NBSP "\xc2\xa0"
-
-#define SPACES_PER_INDENTATION 4
-#define SPACES_PER_LIST_LEVEL 8
-#define MINIMAL_PARAGRAPH_WIDTH 5
-
 /**
  * EHTMLEditorSelection
  *
@@ -6011,6 +6004,16 @@ wrap_lines (EHTMLEditorSelection *selection,
                                continue;
                        }
 
+                       if (element_has_class (WEBKIT_DOM_ELEMENT (node), "Apple-tab-span")) {
+                               WebKitDOMNode *prev_sibling;
+
+                               prev_sibling = webkit_dom_node_get_previous_sibling (node);
+                               if (prev_sibling && WEBKIT_DOM_IS_ELEMENT (prev_sibling) &&
+                                   element_has_class (WEBKIT_DOM_ELEMENT (prev_sibling), "Applet-tab-span"))
+                                       line_length += TAB_LENGTH;
+                               else
+                                       line_length += TAB_LENGTH - line_length % TAB_LENGTH;
+                       }
                        /* When we are not removing user-entered BR elements (lines wrapped by user),
                         * we need to skip those elements */
                        if (!remove_all_br && WEBKIT_DOM_IS_HTMLBR_ELEMENT (node)) {
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 0f94027..35a1331 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -35,9 +35,6 @@
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_HTML_EDITOR_VIEW, EHTMLEditorViewPrivate))
 
-#define UNICODE_ZERO_WIDTH_SPACE "\xe2\x80\x8b"
-#define UNICODE_NBSP "\xc2\xa0"
-
 /* stephenhay from https://mathiasbynens.be/demo/url-regex */
 #define URL_PROTOCOLS "news|telnet|nntp|file|https?|s?ftp||webcal|localhost"
 #define URL_PATTERN "((((" URL_PROTOCOLS ")\\:\\/\\/)|(www\\.|ftp\\.))[^\\s\\/\\$\\.\\?#].[^\\s]*)"
@@ -52,10 +49,6 @@
 
 #define QUOTE_SYMBOL ">"
 
-/* Keep synchronized with the same value in EHTMLEditorSelection */
-#define SPACES_PER_LIST_LEVEL 8
-#define TAB_LENGTH 8
-
 #define HTML_KEY_CODE_BACKSPACE 8
 #define HTML_KEY_CODE_RETURN 13
 #define HTML_KEY_CODE_CONTROL 17
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index 2197aef..fbb7dd1 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -53,6 +53,14 @@
        (G_TYPE_INSTANCE_GET_CLASS \
        ((obj), E_TYPE_HTML_EDITOR_VIEW, EHTMLEditorViewClass))
 
+#define UNICODE_ZERO_WIDTH_SPACE "\xe2\x80\x8b"
+#define UNICODE_NBSP "\xc2\xa0"
+
+#define SPACES_PER_INDENTATION 4
+#define SPACES_PER_LIST_LEVEL 8
+#define MINIMAL_PARAGRAPH_WIDTH 5
+#define TAB_LENGTH 8
+
 G_BEGIN_DECLS
 
 typedef struct _EHTMLEditorView EHTMLEditorView;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]