aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-13 04:40:16 +0800
committerDan Winship <danw@src.gnome.org>2000-06-13 04:40:16 +0800
commit3fbf50794936c9501e9761a738421eb3fe183799 (patch)
treed5cf7f66cd021db7d774e72ad1b9c9f0d08ce956
parentc845d685bb016bda4b87fe96d09aadf9b0a424e1 (diff)
downloadgsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.tar
gsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.tar.gz
gsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.tar.bz2
gsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.tar.lz
gsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.tar.xz
gsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.tar.zst
gsoc2013-evolution-3fbf50794936c9501e9761a738421eb3fe183799.zip
If a paragraph starts with TABs, indent the whole paragraph to that tab
* e-msg-composer.c (format_text): If a paragraph starts with TABs, indent the whole paragraph to that tab level. svn path=/trunk/; revision=3534
-rw-r--r--composer/ChangeLog5
-rw-r--r--composer/e-msg-composer.c40
2 files changed, 33 insertions, 12 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 70562a8ed9..41c9182d85 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,8 @@
+2000-06-12 Dan Winship <danw@helixcode.com>
+
+ * e-msg-composer.c (format_text): If a paragraph starts with TABs,
+ indent the whole paragraph to that tab level.
+
2000-06-12 Ettore Perazzoli <ettore@helixcode.com>
* e-msg-composer.c: Make the `attachment_scroll_frame' an
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 254274c48d..57fac7d38c 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -150,23 +150,31 @@ get_editor_text (BonoboWidget *editor, char *format)
static char *
format_text (char *text)
{
- char *out, *s, *d, *space;
- int len;
+ GString *out;
+ char *s, *space, *outstr;
+ int len, tabbing, i;
+ gboolean linestart = TRUE;
len = strlen (text);
- out = g_malloc (len + len / LINE_LEN + 3);
+ out = g_string_sized_new (len + len / LINE_LEN);
s = text;
- d = out;
-
while (*s) {
+ if (linestart) {
+ tabbing = 0;
+ while (*s == '\t') {
+ s++;
+ tabbing++;
+ }
+ }
+
len = strcspn (s, "\n");
- if (len > LINE_LEN) {
+ if (len > LINE_LEN - tabbing * 8) {
/* 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;
+ space = s + LINE_LEN - tabbing * 8;
while (space > s && (*space != ' '
|| (*(space + 1) == '\240')
|| (*(space - 1) == '\240')))
@@ -176,24 +184,32 @@ format_text (char *text)
len = space - s;
}
+ /* Do initial tabs */
+ for (i = 0; i < tabbing; i++)
+ g_string_append_c (out, '\t');
+
/* Copy the line... */
while (len--) {
- *d++ = (*s == '\240' ? ' ' : *s);
+ g_string_append_c (out, *s == '\240' ? ' ' : *s);
s++;
}
/* Eat whitespace... */
while (*s == ' ' || *s == '\240')
s++;
- if (*s == '\n')
+ if (*s == '\n') {
s++;
+ linestart = TRUE;
+ } else
+ linestart = FALSE;
/* And end the line. */
- *d++ = '\n';
+ g_string_append_c (out, '\n');
}
- *d++ = '\0';
- return out;
+ outstr = out->str;
+ g_string_free (out, FALSE);
+ return outstr;
}
typedef enum {