aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-08-11 02:45:44 +0800
committerDan Winship <danw@src.gnome.org>2000-08-11 02:45:44 +0800
commit7df68b2c7da61c00327e54db57e38fcf60e9db2c (patch)
treee663e9e06c81112de07552f080875fe77520d1a9 /e-util
parent0ad5aaea8088200992598ee3be8b41416b0bee33 (diff)
downloadgsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.tar
gsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.tar.gz
gsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.tar.bz2
gsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.tar.lz
gsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.tar.xz
gsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.tar.zst
gsoc2013-evolution-7df68b2c7da61c00327e54db57e38fcf60e9db2c.zip
If converting both spaces and newlines, then convert tabs too. The joys of
* e-html-utils.c (e_text_to_html): If converting both spaces and newlines, then convert tabs too. The joys of pseudo-<PRE>. svn path=/trunk/; revision=4695
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog5
-rw-r--r--e-util/e-html-utils.c31
2 files changed, 33 insertions, 3 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 878adc70cd..27c2fa210c 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,8 @@
+2000-08-10 Dan Winship <danw@helixcode.com>
+
+ * e-html-utils.c (e_text_to_html): If converting both spaces and
+ newlines, then convert tabs too. The joys of pseudo-<PRE>.
+
2000-08-09 Christopher James Lahey <clahey@helixcode.com>
* e-popup-menu.c: Fix the bug where it truncates the last item
diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c
index 62eb4c5d53..7ff97371eb 100644
--- a/e-util/e-html-utils.c
+++ b/e-util/e-html-utils.c
@@ -113,6 +113,9 @@ url_extract (const unsigned char **text, gboolean check)
* which probably means you don't want to use this flag on
* pieces of data that aren't delimited by at least line breaks.
*
+ * If E_TEXT_TO_HTML_CONVERT_NL and E_TEXT_TO_HTML_CONVERT_SPACES
+ * are both defined, then TABs will also be converted to spaces.
+ *
* - E_TEXT_TO_HTML_CONVERT_URLS: wrap <a href="..."> </a> around
* strings that look like URLs.
**/
@@ -122,7 +125,7 @@ e_text_to_html (const char *input, unsigned int flags)
const unsigned char *cur = input, *end;
char *buffer = NULL;
char *out = NULL;
- int buffer_size = 0;
+ int buffer_size = 0, col;
/* Allocate a translation buffer. */
buffer_size = strlen (input) * 2 + 5;
@@ -132,6 +135,7 @@ e_text_to_html (const char *input, unsigned int flags)
if (flags & E_TEXT_TO_HTML_PRE)
out += sprintf (out, "<PRE>\n");
+ col = 0;
while (*cur) {
if (isalpha (*cur) && (flags & E_TEXT_TO_HTML_CONVERT_URLS)) {
char *tmpurl = NULL, *refurl = NULL, *dispurl = NULL;
@@ -162,6 +166,7 @@ e_text_to_html (const char *input, unsigned int flags)
out += sprintf (out,
"<a href=\"%s\">%s</a>",
refurl, dispurl);
+ col += strlen (tmpurl);
g_free (tmpurl);
g_free (refurl);
g_free (dispurl);
@@ -179,6 +184,7 @@ e_text_to_html (const char *input, unsigned int flags)
end - cur + 10);
memcpy (out, cur, end - cur);
out += end - cur;
+ col += end - cur;
if (!*end)
break;
@@ -188,37 +194,55 @@ e_text_to_html (const char *input, unsigned int flags)
case '<':
strcpy (out, "&lt;");
out += 4;
+ col++;
break;
case '>':
strcpy (out, "&gt;");
out += 4;
+ col++;
break;
case '&':
strcpy (out, "&amp;");
out += 5;
+ col++;
break;
case '"':
strcpy (out, "&quot;");
out += 6;
+ col++;
break;
case '\n':
- *out++ = *cur;
if (flags & E_TEXT_TO_HTML_CONVERT_NL) {
strcpy (out, "<br>");
out += 4;
}
+ *out++ = *cur;
+ col = 0;
break;
+ case '\t':
+ if (flags & (E_TEXT_TO_HTML_CONVERT_SPACES |
+ E_TEXT_TO_HTML_CONVERT_NL)) {
+ do {
+ strcpy (out, "&nbsp;");
+ out += 6;
+ col++;
+ } while (col % 8);
+ break;
+ }
+ /* otherwise, FALL THROUGH */
+
case ' ':
if (flags & E_TEXT_TO_HTML_CONVERT_SPACES) {
if (cur == (const unsigned char *)input ||
- *(cur + 1) == ' ') {
+ *(cur + 1) == ' ' || *(cur + 1) == '\t') {
strcpy (out, "&nbsp;");
out += 6;
+ col++;
break;
}
}
@@ -231,6 +255,7 @@ e_text_to_html (const char *input, unsigned int flags)
*out++ = *cur;
} else
out += g_snprintf(out, 9, "&#%d;", *cur);
+ col++;
break;
}