aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-13 02:41:59 +0800
committerDan Winship <danw@src.gnome.org>2000-06-13 02:41:59 +0800
commit870e780ce28ddf39ea25009878201464f4c5a8ea (patch)
treeb8aba1677f523cf738fd79283a888ba0b3dfcad9 /composer
parent9573b501a807c22010a9ed50825db146296995eb (diff)
downloadgsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar.gz
gsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar.zst
gsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.zip
Don't break on non-breaking spaces, don't keep non-breaking spaces that
* e-msg-composer.c (format_text): Don't break on non-breaking spaces, don't keep non-breaking spaces that fall after a line wrap, and translate non-breaking spaces to regular ones after wrapping. svn path=/trunk/; revision=3530
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog7
-rw-r--r--composer/e-msg-composer.c24
2 files changed, 26 insertions, 5 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 8a26689642..e5ed7fcb51 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,10 @@
+2000-06-12 Dan Winship <danw@helixcode.com>
+
+ * e-msg-composer.c (format_text): Don't break on non-breaking
+ spaces, don't keep non-breaking spaces that fall after a line
+ wrap, and translate non-breaking spaces to regular ones after
+ wrapping.
+
2000-06-05 Dan Winship <danw@helixcode.com>
* e-msg-composer.c (e_msg_composer_attach): New convenience
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 7be0994fa0..48eb7cf15b 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -161,19 +161,33 @@ format_text (char *text)
while (*s) {
len = strcspn (s, "\n");
if (len > LINE_LEN) {
+ /* If we can break anywhere between s and
+ * s + LINE_LEN, do that. We can break between
+ * space and anything but &nbsp;
+ */
space = s + LINE_LEN;
- while (*space != ' ' && space > s)
+ while (space > s && (*space != ' '
+ || (*(space + 1) == '\240')
+ || (*(space - 1) == '\240')))
space--;
if (space != s)
len = space - s;
}
- memcpy (d, s, len);
- s += len;
- if (*s)
+ /* Copy the line... */
+ while (len--) {
+ *d++ = (*s == '\240' ? ' ' : *s);
s++;
- d += len;
+ }
+
+ /* Eat whitespace... */
+ while (*s == ' ' || *s == '\240')
+ s++;
+ if (*s == '\n')
+ s++;
+
+ /* And end the line. */
*d++ = '\n';
}