Improve smart wrapping - wrap lines without spaces.
authorDarko Koruga <darko@users.sourceforge.net>
Wed, 17 Oct 2001 07:59:31 +0000 (07:59 +0000)
committerDarko Koruga <darko@users.sourceforge.net>
Wed, 17 Oct 2001 07:59:31 +0000 (07:59 +0000)
Don't wrap URLs.

ChangeLog.claws
configure.in
src/compose.c

index 669937b2dab7f1e6019b34e28ac118a10f6184e4..d07add64a5c05302ddce1a520633a3379bf241ad 100644 (file)
@@ -1,3 +1,9 @@
+2001-10-17 [darko]
+
+       * src/compose.c
+               wrap long lines without spaces
+               don't wrap URLs
+
 2001-10-16 [paul]
 
        * po/es.po, po/nl.po, po/pt_BR.po
 2001-10-16 [paul]
 
        * po/es.po, po/nl.po, po/pt_BR.po
index 75fd22c05bc20b635ce7461032ad36fc6110e761..c7dd7f181b31092982cd6a7c6fa41e2140d7e3fa 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws18
+EXTRA_VERSION=claws19
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index bf88e88f78700198891d7fc216c8c0f8406a6775..fe12cde6d663b91160d38ca7e66381fa23636c07 100644 (file)
@@ -2257,6 +2257,24 @@ static gint gtkstext_strncmp(GtkSText *text, guint pos1, guint pos2, guint len,
        return i;
 }
 
        return i;
 }
 
+/* return true if text at pos is URL */
+static guint is_url_string(GtkSText *text, guint start_pos, guint text_len)
+{
+       guint len;
+
+       len = gtkstext_str_strcmp(text, start_pos, text_len, "ftp://");
+       if (len == 6)
+               return 1;
+       len = gtkstext_str_strcmp(text, start_pos, text_len, "http://");
+       if (len == 7)
+               return 1;
+       len = gtkstext_str_strcmp(text, start_pos, text_len, "https://");
+       if (len == 8)
+               return 1;
+
+       return 0;
+}
+
 static void compose_wrap_line_all(Compose *compose)
 {
        GtkSText *text = GTK_STEXT(compose->text);
 static void compose_wrap_line_all(Compose *compose)
 {
        GtkSText *text = GTK_STEXT(compose->text);
@@ -2409,9 +2427,17 @@ static void compose_wrap_line_all(Compose *compose)
                        line_len = cur_len + ch_len;
                }
 
                        line_len = cur_len + ch_len;
                }
 
-               if (cur_len + ch_len > linewrap_len && line_len > 0) {
+               if (cur_len + ch_len > linewrap_len) {
                        gint tlen;
 
                        gint tlen;
 
+                       if (line_len == 0) {
+                               /* don't wrap URLs */
+                               if (is_url_string(text, line_pos, text_len))
+                                       continue;
+                               line_len = cur_pos - line_pos;
+                               line_pos = cur_pos;
+                       }
+
                        if (text->use_wchar)
                                tlen = wctomb(cbuf, (wchar_t)GTK_STEXT_INDEX(text, line_pos - 1));
                        else {
                        if (text->use_wchar)
                                tlen = wctomb(cbuf, (wchar_t)GTK_STEXT_INDEX(text, line_pos - 1));
                        else {