Improved wrapping on send to be smarter when quotation string is empty. Fix after...
authorDarko Koruga <darko@users.sourceforge.net>
Fri, 23 Nov 2001 11:42:50 +0000 (11:42 +0000)
committerDarko Koruga <darko@users.sourceforge.net>
Fri, 23 Nov 2001 11:42:50 +0000 (11:42 +0000)
ChangeLog.claws
configure.in
src/compose.c
src/gtkutils.c
src/gtkutils.h

index 22292838f186349410f6baf41f86b0dd343f73c8..af37ca8fa0e74e04f0c11ae6bddd9af387209b7e 100644 (file)
@@ -1,3 +1,10 @@
+2001-11-23 [darko]     0.6.5claws28
+
+       * src/compose.c
+               wrapping on send improvements
+               fix for GtkSText after last sync with main branch
+               GTK_TEXT -> GTK_STEXT
+
 2001-11-23 [paul]      0.6.5claws27
 
        * sync with sylpheed 0.6.5cvs14
index 62bb9609f2d798faf5f96bf7a8e66c1c31e91746..264b2c41f8699b507610d3b5af67a14aeb44521c 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws27
+EXTRA_VERSION=claws28
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 94ff07815f8f89170b2492e23db505d434c70464..aab357d525f34d25869410f5f5fb449bd131b154 100644 (file)
@@ -1053,6 +1053,10 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
        if (prefs_common.auto_sig)
                compose_insert_sig(compose);
+
+       if (prefs_common.linewrap_quote)
+               compose_wrap_line_all(compose);
+
        gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
        gtk_stext_set_point(GTK_STEXT(compose->text), 0);
 
@@ -1119,6 +1123,10 @@ Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
 
        if (prefs_common.auto_sig)
                compose_insert_sig(compose);
+
+       if (prefs_common.linewrap_quote)
+               compose_wrap_line_all(compose);
+
        gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
        gtk_stext_set_point(GTK_STEXT(compose->text), 0);
 
@@ -2206,7 +2214,8 @@ static void compose_wrap_line_all(Compose *compose)
                        gchar cb[MB_CUR_MAX];
 
 #ifdef WRAP_DEBUG
-                       printf("found CR at %d\n", cur_pos);
+                       printf("found CR at %d next line is ", cur_pos);
+                       dump_text(text, cur_pos + 1, tlen, 1);
 #endif
                        /* if it's just quotation + newline skip it */
                        if (i_len && (cur_pos + 1 < tlen)) {
@@ -2226,13 +2235,26 @@ static void compose_wrap_line_all(Compose *compose)
                                                do_delete = 0;
                                }
                        }
+                       /* if it's just newline skip it */
+                       else if (do_delete && (cur_pos + 1 < tlen)) {
+                               if (text->use_wchar)
+                                       clen = wctomb(cb, (wchar_t)GTK_STEXT_INDEX(text, cur_pos + 1));
+                               else {
+                                       cb[0] = GTK_STEXT_INDEX(text,
+                                                               cur_pos + 1);
+                                       clen = 1;
+                               }
+                               /* no need to join the lines */
+                               if ((clen == 1) && (cb[0] == '\n'))
+                                       do_delete = 0;
+                       }
 
 #ifdef WRAP_DEBUG
                        printf("qlen=%d l_len=%d wrap_len=%d do_del=%d\n",
                                qlen, line_len, linewrap_len, do_delete);
 #endif
                        /* should we delete to perform smart wrapping */
-                       if (qlen && line_len < linewrap_len && do_delete) {
+                       if (line_len < linewrap_len && do_delete) {
                                /* get rid of newline */
                                gtk_stext_set_point(text, cur_pos);
                                gtk_stext_forward_delete(text, 1);
@@ -2363,13 +2385,18 @@ static void compose_wrap_line_all(Compose *compose)
                        gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
                        /* gtk_stext_compact_buffer(text); */
                        tlen++;
-                       cur_pos++;
                        line_pos++;
-                       cur_len = cur_len - line_len + ch_len;
+                       /* for loop will increase it */
+                       cur_pos = line_pos - 1;
+                       /* start over with current line */
+                       is_new_line = 1;
                        line_len = 0;
+                       cur_len = 0;
+                       do_delete = 1;
 #ifdef WRAP_DEBUG
                        printf("after CR insert ");
                        dump_text(text, line_pos, tlen, 1);
+                       dump_text(text, cur_pos, tlen, 1);
 #endif
 
                        /* should we insert quotation ? */
@@ -2387,14 +2414,6 @@ static void compose_wrap_line_all(Compose *compose)
                                                /* gtk_stext_compact_buffer(text); */
                                                tlen += ins_len;
                                        }
-
-                                       /* for loop will increase it */
-                                       cur_pos = line_pos - 1;
-                                       cur_len = 0;
-                                       line_len = 0;
-                                       /* start over with current line */
-                                       is_new_line = 1;
-                                       do_delete = 1;
 #ifdef WRAP_DEBUG
                                        printf("after quote insert ");
                                        dump_text(text, line_pos, tlen, 1);
index 9c0d01a1e06c5e275390a737d7627ead4dbf54cc..a9689078802e679599f06429bf65b14cfbec7a2a 100644 (file)
@@ -248,17 +248,17 @@ void gtkut_combo_set_items(GtkCombo *combo, const gchar *str1, ...)
        g_list_free(combo_items);
 }
 
-gboolean gtkut_text_match_string(GtkText *text, gint pos, wchar_t *wcs,
+gboolean gtkut_text_match_string(GtkSText *text, gint pos, wchar_t *wcs,
                                 gint len, gboolean case_sens)
 {
        gint match_count = 0;
 
        for (; match_count < len; pos++, match_count++) {
                if (case_sens) {
-                       if (GTK_TEXT_INDEX(text, pos) != wcs[match_count])
+                       if (GTK_STEXT_INDEX(text, pos) != wcs[match_count])
                                break;
                } else {
-                       if (towlower(GTK_TEXT_INDEX(text, pos)) !=
+                       if (towlower(GTK_STEXT_INDEX(text, pos)) !=
                            towlower(wcs[match_count]))
                                break;
                }
@@ -270,15 +270,15 @@ gboolean gtkut_text_match_string(GtkText *text, gint pos, wchar_t *wcs,
                return FALSE;
 }
 
-guint gtkut_text_str_compare_n(GtkText *text, guint pos1, guint pos2,
+guint gtkut_text_str_compare_n(GtkSText *text, guint pos1, guint pos2,
                               guint len, guint text_len)
 {
        guint i;
        GdkWChar ch1, ch2;
 
        for (i = 0; i < len && pos1 + i < text_len && pos2 + i < text_len; i++) {
-               ch1 = GTK_TEXT_INDEX(text, pos1 + i);
-               ch2 = GTK_TEXT_INDEX(text, pos2 + i);
+               ch1 = GTK_STEXT_INDEX(text, pos1 + i);
+               ch2 = GTK_STEXT_INDEX(text, pos2 + i);
                if (ch1 != ch2)
                        break;
        }
@@ -286,7 +286,7 @@ guint gtkut_text_str_compare_n(GtkText *text, guint pos1, guint pos2,
        return i;
 }
 
-guint gtkut_text_str_compare(GtkText *text, guint start_pos, guint text_len,
+guint gtkut_text_str_compare(GtkSText *text, guint start_pos, guint text_len,
                             const gchar *str)
 {
        wchar_t *wcs;
@@ -310,7 +310,7 @@ guint gtkut_text_str_compare(GtkText *text, guint start_pos, guint text_len,
        return result ? len : 0;
 }
 
-gboolean gtkut_text_is_uri_string(GtkText *text,
+gboolean gtkut_text_is_uri_string(GtkSText *text,
                                  guint start_pos, guint text_len)
 {
        if (gtkut_text_str_compare(text, start_pos, text_len, "http://") ||
index 4f6f1b6caae00ccc1547af4c75ed74a697b52de8..25a32895b1ee7c7e3e36f4c564c0262df2d99e74 100644 (file)
@@ -30,7 +30,7 @@
 #include <gtk/gtkwidget.h>
 #include <gtk/gtkctree.h>
 #include <gtk/gtkcombo.h>
-#include <gtk/gtktext.h>
+#include "gtkstext.h"
 #include <stdlib.h>
 #if HAVE_WCHAR_H
 #  include <wchar.h>
@@ -100,21 +100,21 @@ void gtkut_clist_set_focus_row            (GtkCList       *clist,
 void gtkut_combo_set_items             (GtkCombo       *combo,
                                         const gchar    *str1, ...);
 
-gboolean gtkut_text_match_string       (GtkText        *text,
+gboolean gtkut_text_match_string       (GtkSText       *text,
                                         gint            pos,
                                         wchar_t        *wcs,
                                         gint            len,
                                         gboolean        case_sens);
-guint gtkut_text_str_compare_n         (GtkText        *text,
+guint gtkut_text_str_compare_n         (GtkSText       *text,
                                         guint           pos1,
                                         guint           pos2,
                                         guint           len,
                                         guint           text_len);
-guint gtkut_text_str_compare           (GtkText        *text,
+guint gtkut_text_str_compare           (GtkSText       *text,
                                         guint           start_pos,
                                         guint           text_len,
                                         const gchar    *str);
-gboolean gtkut_text_is_uri_string      (GtkText        *text,
+gboolean gtkut_text_is_uri_string      (GtkSText       *text,
                                         guint           start_pos,
                                         guint           text_len);