aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
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/e-msg-composer.c
parent9573b501a807c22010a9ed50825db146296995eb (diff)
downloadgsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar
gsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar.gz
gsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar.bz2
gsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar.lz
gsoc2013-evolution-870e780ce28ddf39ea25009878201464f4c5a8ea.tar.xz
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/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c24
1 files changed, 19 insertions, 5 deletions
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';
}