+2003-03-12
+
+ * src/textview.c: textview_button_pressed(): corrected the range of
+ URI link.
+ * src/compose.c: compose_wrap_line_all_full(): treat UTF-8 characters
+ represented with more than 2 bytes as 2 character width and 2 bytes
+ one as a single character width as a workaround for wrapping problem.
+
+2003-03-12
+
+ * src/utils.c: subject_compare_for_sort(): allow null strings (fixes
+ summary sorting).
+
+2003-03-11
+
+ * implemented HTML link correctly.
+ * src/html.[ch]: HTMLAttr, HTMLTag: new structure for attributes /
+ tags.
+ html_get_tag(): new. It parses tag and returns HTMLTag object.
+ html_parse_tag(): also parses <a> tags and 'href' attributes.
+ * src/textview.c: textview_write_link(): new. It creates link string.
+
+2003-03-10
+
+ * src/compose.c: compose_wrap_line_all_full(): fixed an infinite
+ loop / crash bug (thanks to Darko Koruga).
+ compose_write_to_file(): put correct charset element when
+ conversion failed but want to send anyway.
+
2003-03-10
* src/headerview.c: headerview_show()
+2003-03-13 [paul] 0.8.11claws5
+
+ * sync with 0.8.11cvs5
+ see ChangeLog 2003-03-11, 2003-03-12
+
2003-03-12 [christoph] 0.8.11claws4
* src/folder.c
+2003-03-12
+
+ * src/textview.c: textview_button_pressed(): URI ¤Î¥ê¥ó¥¯¤ÎÈϰϤò
+ ÄûÀµ¡£
+ * src/compose.c: compose_wrap_line_all_full(): ÀÞ¤êÊÖ¤·¤ÎÌäÂê¤Ø¤Î
+ Âнè¤Î¤¿¤á¡¢ UTF-8 ¤Î3¥Ð¥¤¥È°Ê¾å¤Çɽ¸½¤µ¤ì¤ëʸ»ú¤ò2ʸ»úÉý¡¢2
+ ¥Ð¥¤¥Èʸ»ú¤ò1ʸ»úÉý¤È¤·¤Æ°·¤¦¤è¤¦¤Ë¤·¤¿¡£
+
+2003-03-12
+
+ * src/utils.c: subject_compare_for_sort(): ¥Ì¥ëʸ»úÎó¤òµö²Ä(¥µ¥Þ¥ê¤Î
+ ¥½¡¼¥È¤ò½¤Àµ)¡£
+
+2003-03-11
+
+ * HTML ¥ê¥ó¥¯¤òÀµ¤·¤¯¼ÂÁõ¡£
+ * src/html.[ch]: HTMLAttr, HTMLTag: °À / ¥¿¥°¤Î¤¿¤á¤Î¿·µ¬¹½Â¤ÂΡ£
+ html_get_tag(): ¿·µ¬¡£¥¿¥°¤ò²òÀϤ·¤Æ HTMLTag ¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¡£
+ html_parse_tag(): <a> ¥¿¥°¤È 'href' °À¤â¥Ñ¡¼¥¹¡£
+ * src/textview.c: textview_write_link(): ¿·µ¬¡£¥ê¥ó¥¯Ê¸»úÎó¤òºîÀ®¡£
+
+2003-03-10
+
+ * src/compose.c: compose_wrap_line_all_full(): ̵¸Â¥ë¡¼¥× /
+ ¥¯¥é¥Ã¥·¥å¥Ð¥°¤ò½¤Àµ(Darko Koruga ¤µ¤ó thanks)¡£
+ compose_write_to_file(): ÊÑ´¹¤Ë¼ºÇÔ¤·¤¿¤¬¤È¤Ë¤«¤¯Á÷¿®¤·¤¿¤¤¤È¤
+ ¤ËÀµ¤·¤¤ charset Í×ÁǤò½ÐÎϤ¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+
2003-03-10
* src/headerview.c: headerview_show()
MICRO_VERSION=11
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=claws4
+EXTRA_VERSION=claws5
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target
} \
}
+#define DISP_WIDTH(len) \
+ ((len > 2 && conv_get_current_charset() == C_UTF_8) ? 2 : \
+ (len == 2 && conv_get_current_charset() == C_UTF_8) ? 1 : len)
+
#define INDENT_CHARS ">|#"
#define SPACE_CHARS " \t"
line_len = cur_len + ch_len;
}
- if (cur_len + ch_len > prefs_common.linewrap_len &&
+ if (cur_len + DISP_WIDTH(ch_len) > prefs_common.linewrap_len &&
line_len > 0) {
gint tlen = ch_len;
p_end++;
cur_pos++;
line_pos++;
- cur_len = cur_len - line_len + ch_len;
+ cur_len = cur_len - line_len + DISP_WIDTH(ch_len);
line_len = 0;
continue;
}
if (ch_len > 1) {
line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
+ line_len = cur_len + DISP_WIDTH(ch_len);
}
- cur_len += ch_len;
+ cur_len += DISP_WIDTH(ch_len);
}
compose_end:
}
/* are we over wrapping length set in preferences ? */
- if (cur_len + ch_len > linewrap_len) {
+ if (cur_len + DISP_WIDTH(ch_len) > linewrap_len) {
gint clen;
#ifdef WRAP_DEBUG
if (ch_len > 1) {
line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
+ line_len = cur_len + DISP_WIDTH(ch_len);
}
/* advance to next character in buffer */
- cur_len += ch_len;
+ cur_len += DISP_WIDTH(ch_len);
}
if (frozen)
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
parser->str = g_string_new(NULL);
parser->buf = g_string_new(NULL);
parser->bufp = parser->buf->str;
+ parser->state = HTML_NORMAL;
+ parser->href = NULL;
parser->newline = TRUE;
parser->empty_line = TRUE;
parser->space = FALSE;
{
g_string_free(parser->str, TRUE);
g_string_free(parser->buf, TRUE);
+ g_free(parser->href);
g_free(parser);
}
parser->newline = FALSE;
}
+static HTMLTag *html_get_tag(const gchar *str)
+{
+ HTMLTag *tag;
+ gchar *tmp;
+ gchar *tmpp;
+
+ g_return_val_if_fail(str != NULL, NULL);
+
+ if (*str == '\0' || *str == '!') return NULL;
+
+ Xstrdup_a(tmp, str, return NULL);
+
+ tag = g_new0(HTMLTag, 1);
+
+ for (tmpp = tmp; *tmpp != '\0' && !isspace(*tmpp); tmpp++)
+ ;
+
+ if (*tmpp == '\0') {
+ g_strdown(tmp);
+ tag->name = g_strdup(tmp);
+ return tag;
+ } else {
+ *tmpp++ = '\0';
+ g_strdown(tmp);
+ tag->name = g_strdup(tmp);
+ }
+
+ while (*tmpp != '\0') {
+ HTMLAttr *attr;
+ gchar *attr_name;
+ gchar *attr_value;
+ gchar *p;
+ gchar quote;
+
+ while (isspace(*tmpp)) tmpp++;
+ attr_name = tmpp;
+ if ((p = strchr(attr_name, '=')) == NULL) {
+ g_warning("html_get_tag(): syntax error in tag: '%s'\n", str);
+ return tag;
+ }
+ tmpp = p;
+ *tmpp++ = '\0';
+ while (isspace(*tmpp)) tmpp++;
+
+ if (*tmpp == '\0') {
+ g_warning("html_get_tag(): syntax error in tag: '%s'\n", str);
+ return tag;
+ } else if (*tmpp == '"' || *tmpp == '\'') {
+ /* name="value" */
+ quote = *tmpp;
+ tmpp++;
+ attr_value = tmpp;
+ if ((p = strchr(attr_value, quote)) == NULL) {
+ g_warning("html_get_tag(): syntax error in tag: '%s'\n", str);
+ return tag;
+ }
+ tmpp = p;
+ *tmpp++ = '\0';
+ while (isspace(*tmpp)) tmpp++;
+ } else {
+ /* name=value */
+ attr_value = tmpp;
+ while (*tmpp != '\0' && !isspace(*tmpp)) tmpp++;
+ if (*tmpp != '\0')
+ *tmpp++ = '\0';
+ }
+
+ g_strchomp(attr_name);
+ g_strdown(attr_name);
+ attr = g_new(HTMLAttr, 1);
+ attr->name = g_strdup(attr_name);
+ attr->value = g_strdup(attr_value);
+ tag->attr = g_list_append(tag->attr, attr);
+ }
+
+ return tag;
+}
+
+static void html_free_tag(HTMLTag *tag)
+{
+ if (!tag) return;
+
+ g_free(tag->name);
+ while (tag->attr != NULL) {
+ HTMLAttr *attr = (HTMLAttr *)tag->attr->data;
+ g_free(attr->name);
+ g_free(attr->value);
+ g_free(attr);
+ tag->attr = g_list_remove(tag->attr, tag->attr->data);
+ }
+ g_free(tag);
+}
+
static HTMLState html_parse_tag(HTMLParser *parser)
{
gchar buf[HTMLBUFSIZE];
- gchar *p;
- static gboolean is_in_href = FALSE;
+ HTMLTag *tag;
html_get_parenthesis(parser, buf, sizeof(buf));
- for (p = buf; *p != '\0'; p++) {
- if (isspace(*p)) {
- *p = '\0';
- break;
- }
- }
+ tag = html_get_tag(buf);
parser->state = HTML_UNKNOWN;
- if (buf[0] == '\0') return parser->state;
+ if (!tag) return HTML_UNKNOWN;
- g_strdown(buf);
-
- if (!strcmp(buf, "br")) {
+ if (!strcmp(tag->name, "br")) {
parser->space = FALSE;
html_append_char(parser, '\n');
parser->state = HTML_BR;
- } else if (!strcmp(buf, "a")) {
- /* look for tokens separated by space or = */
- char* href_token = strtok(++p, " =");
- parser->state = HTML_NORMAL;
- while (href_token != NULL) {
- /* look for href */
- if (!strcmp(href_token, "href")) {
- /* the next token is the url, between double
- * quotes */
- char* url = strtok(NULL, "\"");
- if (url && url[0] == '\'')
- url = strtok(url,"\'");
-
- if (!url) break;
- html_append_str(parser, url, strlen(url));
- html_append_char(parser, ' ');
- /* start enforcing html link */
- parser->state = HTML_HREF;
- is_in_href = TRUE;
- break;
- }
- /* or get next token */
- href_token = strtok(NULL, " =");
+ } else if (!strcmp(tag->name, "a")) {
+ if (tag->attr && tag->attr->data &&
+ !strcmp(((HTMLAttr *)tag->attr->data)->name, "href")) {
+ g_free(parser->href);
+ parser->href =
+ g_strdup(((HTMLAttr *)tag->attr->data)->value);
+ parser->state = HTML_HREF;
}
- } else if (!strcmp(buf, "/a")) {
- /* stop enforcing html link */
- parser->state = HTML_NORMAL;
- is_in_href = FALSE;
- } else if (!strcmp(buf, "p")) {
+ } else if (!strcmp(tag->name, "/a")) {
+ g_free(parser->href);
+ parser->href = NULL;
+ parser->state = HTML_NORMAL;
+ } else if (!strcmp(tag->name, "p")) {
parser->space = FALSE;
if (!parser->empty_line) {
parser->space = FALSE;
html_append_char(parser, '\n');
}
parser->state = HTML_PAR;
- } else if (!strcmp(buf, "pre")) {
+ } else if (!strcmp(tag->name, "pre")) {
parser->pre = TRUE;
parser->state = HTML_PRE;
- } else if (!strcmp(buf, "/pre")) {
+ } else if (!strcmp(tag->name, "/pre")) {
parser->pre = FALSE;
parser->state = HTML_NORMAL;
- } else if (!strcmp(buf, "hr")) {
+ } else if (!strcmp(tag->name, "hr")) {
if (!parser->newline) {
parser->space = FALSE;
html_append_char(parser, '\n');
}
html_append_str(parser, HR_STR "\n", -1);
parser->state = HTML_HR;
- } else if (!strcmp(buf, "div") ||
- !strcmp(buf, "ul") ||
- !strcmp(buf, "li") ||
- !strcmp(buf, "table") ||
- !strcmp(buf, "tr") ||
- (buf[0] == 'h' && isdigit(buf[1]))) {
+ } else if (!strcmp(tag->name, "div") ||
+ !strcmp(tag->name, "ul") ||
+ !strcmp(tag->name, "li") ||
+ !strcmp(tag->name, "table") ||
+ !strcmp(tag->name, "tr") ||
+ (tag->name[0] == 'h' && isdigit(tag->name[1]))) {
if (!parser->newline) {
parser->space = FALSE;
html_append_char(parser, '\n');
}
parser->state = HTML_NORMAL;
- } else if (!strcmp(buf, "/table") ||
- (buf[0] == '/' && buf[1] == 'h' && isdigit(buf[1]))) {
+ } else if (!strcmp(tag->name, "/table") ||
+ (tag->name[0] == '/' &&
+ tag->name[1] == 'h' &&
+ isdigit(tag->name[1]))) {
if (!parser->empty_line) {
parser->space = FALSE;
if (!parser->newline) html_append_char(parser, '\n');
html_append_char(parser, '\n');
}
parser->state = HTML_NORMAL;
- } else if (!strcmp(buf, "/div") ||
- !strcmp(buf, "/ul") ||
- !strcmp(buf, "/li")) {
+ } else if (!strcmp(tag->name, "/div") ||
+ !strcmp(tag->name, "/ul") ||
+ !strcmp(tag->name, "/li")) {
if (!parser->newline) {
parser->space = FALSE;
html_append_char(parser, '\n');
}
parser->state = HTML_NORMAL;
- }
-
- if (is_in_href == TRUE) {
- /* when inside a link, everything will be written as
- * clickable (see textview_show_thml in textview.c) */
- parser->state = HTML_HREF;
- }
+ }
+
+ html_free_tag(tag);
return parser->state;
}
if (html_read_line(parser) == HTML_EOF) return;
strncpy2(buf, parser->bufp, MIN(p - parser->bufp + 1, len));
+ g_strstrip(buf);
parser->bufp = p + 1;
}
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
} HTMLState;
typedef struct _HTMLParser HTMLParser;
+typedef struct _HTMLAttr HTMLAttr;
+typedef struct _HTMLTag HTMLTag;
struct _HTMLParser
{
HTMLState state;
+ gchar *href;
+
gboolean newline;
gboolean empty_line;
gboolean space;
gboolean pre;
};
+struct _HTMLAttr
+{
+ gchar *name;
+ gchar *value;
+};
+
+struct _HTMLTag
+{
+ gchar *name;
+ GList *attr;
+};
+
HTMLParser *html_parser_new (FILE *fp,
CodeConverter *conv);
void html_parser_destroy (HTMLParser *parser);
static void textview_write_line (TextView *textview,
const gchar *str,
CodeConverter *conv);
-static void textview_write_link (TextView *textview,
- const gchar *url,
+static void textview_write_link (TextView *textview,
const gchar *str,
+ const gchar *uri,
CodeConverter *conv);
static GPtrArray *textview_scan_header (TextView *textview,
FILE *fp);
textview->msgfont = NULL;
tmp = g_strconcat("pgp: ", _("Check signature"), NULL);
- textview_write_link(textview, tmp, buf, NULL);
+ textview_write_link(textview, buf, tmp, NULL);
/* put things back */
textview->msgfont = (GdkFont *)oldfont;
charset = mimeinfo->charset;
textview_write_body(textview, mimeinfo, fp, charset);
}
-
+
gtk_stext_thaw(text);
}
textview_set_font(textview, NULL);
text = GTK_STEXT(textview->text);
textview_clear(textview);
-
+
gtk_stext_freeze(text);
TEXT_INSERT(_("To save this part, pop up the context menu with "));
} else {
TEXT_INSERT(partinfo->sigstatus_full);
}
-
+
gtk_stext_thaw(text);
}
#endif /* USE_GPGME */
textview->is_in_signature = FALSE;
if (tmpfp) {
-
if (mimeinfo->mime_type == MIME_TEXT_HTML)
textview_show_html(textview, tmpfp, conv);
else if (mimeinfo->mime_type == MIME_TEXT_ENRICHED)
{
HTMLParser *parser;
gchar *str;
- gchar* url = NULL;
parser = html_parser_new(fp, conv);
g_return_if_fail(parser != NULL);
while ((str = html_parse(parser)) != NULL) {
if (parser->state == HTML_HREF) {
/* first time : get and copy the URL */
- if (url == NULL) {
+ if (parser->href == NULL) {
/* ALF - the sylpheed html parser returns an empty string,
* if still inside an <a>, but already parsed past HREF */
str = strtok(str, " ");
if (str) {
- url = strdup(str);
+ parser->href = strdup(str);
/* the URL may (or not) be followed by the
* referenced text */
str = strtok(NULL, "");
}
}
- if (str != NULL) {
- textview_write_link(textview, url, str, NULL);
- }
- } else {
- if (url != NULL) {
- free(url);
- url = NULL;
- }
+ if (str != NULL)
+ textview_write_link(textview, str, parser->href, NULL);
+ } else
textview_write_line(textview, str, NULL);
- }
}
-
html_parser_destroy(parser);
}
#undef ADD_TXT_POS
-/* This function writes str as a double-clickable link with the given url. */
-static void textview_write_link(TextView *textview, const gchar *url,
- const gchar *str, CodeConverter *conv)
-{
- GdkColor *link_color = NULL;
- RemoteURI* uri;
- GtkSText *text = GTK_STEXT(textview->text);
- gchar buf[BUFFSIZE];
-
- /* this part is taken from textview_write_line. Right now the only place
- * that calls this function passes NULL for conv, but you never know. */
-#if 0
- if (!conv)
- strncpy2(buf, str, sizeof(buf));
- else if (conv_convert(conv, buf, sizeof(buf), str) < 0) {
- gtk_stext_insert(text, textview->msgfont,
- prefs_common.enable_color
- ? &error_color : NULL, NULL,
- "*** Warning: code conversion failed ***\n",
- -1);
- return;
- }
-#endif
-
- if (!conv || conv_convert(conv, buf, sizeof(buf), str) < 0)
- strncpy2(buf, str, sizeof(buf));
-
- strcrchomp(buf);
- gtk_stext_insert(text, textview->msgfont, NULL, NULL, " ", 1);
-
- /* this part is based on the code in make_clickable_parts */
- if (prefs_common.enable_color) {
- link_color = &uri_color;
- }
- uri = g_new(RemoteURI, 1);
- uri->uri = g_strdup(url);
- uri->start = gtk_stext_get_point(text);
- gtk_stext_insert(text, textview->msgfont, link_color, NULL, str,
- strlen(str));
- uri->end = gtk_stext_get_point(text);
- textview->uri_list = g_slist_append(textview->uri_list, uri);
-}
-
static void textview_write_line(TextView *textview, const gchar *str,
CodeConverter *conv)
{
fg_color, NULL, buf);
}
+void textview_write_link(TextView *textview, const gchar *str,
+ const gchar *uri, CodeConverter *conv)
+{
+ GdkColor *link_color = NULL;
+ GtkSText *text = GTK_STEXT(textview->text);
+ gchar buf[BUFFSIZE];
+ gchar *bufp;
+ RemoteURI *r_uri;
+
+ if (*str == '\0')
+ return;
+
+ if (!conv) {
+ if (textview->text_is_mb)
+ conv_localetodisp(buf, sizeof(buf), str);
+ else
+ strncpy2(buf, str, sizeof(buf));
+ } else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
+ conv_localetodisp(buf, sizeof(buf), str);
+ else if (textview->text_is_mb)
+ conv_unreadable_locale(buf);
+
+ strcrchomp(buf);
+
+ for (bufp = buf; isspace(*bufp); bufp++)
+ gtk_stext_insert(text, textview->msgfont, NULL, NULL, bufp, 1);
+
+ if (prefs_common.enable_color) {
+ link_color = &uri_color;
+ }
+ r_uri = g_new(RemoteURI, 1);
+ r_uri->uri = g_strdup(uri);
+ r_uri->start = gtk_stext_get_point(text);
+ gtk_stext_insert(text, textview->msgfont, link_color, NULL, bufp, -1);
+ r_uri->end = gtk_stext_get_point(text);
+ textview->uri_list = g_slist_append(textview->uri_list, r_uri);
+}
+
void textview_clear(TextView *textview)
{
GtkSText *text = GTK_STEXT(textview->text);
} else
procheader_header_array_destroy(headers);
+
return sorted_headers;
}
}
if (text_len - pos == len) break;
}
+
g_free(wcs);
return found;
}
RemoteURI *uri = (RemoteURI *)cur->data;
if (textview->cur_pos >= uri->start &&
- textview->cur_pos < uri->end) {
+ textview->cur_pos <= uri->end) {
/* single click: display url in statusbar */
if (event->button == 1 && textview->last_buttonpress != GDK_2BUTTON_PRESS) {
if (textview->messageview->mainwin) {