/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 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
#include "defs.h"
+#ifndef PANGO_ENABLE_ENGINE
+# define PANGO_ENABLE_ENGINE
+#endif
+
#include <glib.h>
+#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtkdnd.h>
+#include <gtk/gtkclipboard.h>
+#include <pango/pango-break.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
# include <wctype.h>
#endif
-#include "intl.h"
#include "main.h"
#include "mainwindow.h"
#include "compose.h"
followup_and_reply_to);
static void compose_reedit_set_entry (Compose *compose,
MsgInfo *msginfo);
+
static void compose_insert_sig (Compose *compose,
gboolean replace);
static gchar *compose_get_signature_str (Compose *compose);
static ComposeInsertResult compose_insert_file (Compose *compose,
const gchar *file);
+
static void compose_attach_append (Compose *compose,
const gchar *file,
const gchar *type,
const gchar *content_type);
static void compose_attach_parts (Compose *compose,
MsgInfo *msginfo);
-static void compose_wrap_line (Compose *compose);
-static void compose_wrap_line_all (Compose *compose);
-static void compose_wrap_line_all_full (Compose *compose,
+
+static void compose_wrap_paragraph (Compose *compose,
+ GtkTextIter *par_iter);
+static void compose_wrap_all (Compose *compose);
+static void compose_wrap_all_full (Compose *compose,
gboolean autowrap);
+
static void compose_set_title (Compose *compose);
static void compose_select_account (Compose *compose,
PrefsAccount *account,
gint redo_state,
gpointer data);
-static gint calc_cursor_xpos (GtkTextView *text,
- gint extra,
- gint char_width);
-
static void compose_create_header_entry (Compose *compose);
static void compose_add_header_entry (Compose *compose, gchar *header, gchar *text);
static void compose_update_priority_menu_item(Compose * compose);
static void compose_changed_cb (GtkTextBuffer *textbuf,
Compose *compose);
+static void compose_wrap_cb (gpointer data,
+ guint action,
+ GtkWidget *widget);
static void compose_toggle_autowrap_cb (gpointer data,
guint action,
GtkWidget *widget);
NULL},
{N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Edit/_Wrap current paragraph"),
- "<control>L", compose_wrap_line, 0, NULL},
+ "<control>L", compose_wrap_cb, 0, NULL},
{N_("/_Edit/Wrap all long _lines"),
- "<control><alt>L", compose_wrap_line_all, 0, NULL},
+ "<control><alt>L", compose_wrap_cb, 1, NULL},
{N_("/_Edit/Aut_o wrapping"), "<shift><control>L", compose_toggle_autowrap_cb, 0, "<ToggleItem>"},
{N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Edit/Edit with e_xternal editor"),
gtk_text_buffer_place_cursor(textbuf, &iter);
if (quote && prefs_common.linewrap_quote)
- compose_wrap_line_all(compose);
+ compose_wrap_all(compose);
gtk_widget_grab_focus(compose->text);
compose_insert_sig(compose, FALSE);
if (prefs_common.linewrap_quote)
- compose_wrap_line_all(compose);
+ compose_wrap_all(compose);
gtk_text_buffer_get_start_iter(textbuf, &iter);
gtk_text_buffer_place_cursor(textbuf, &iter);
compose_insert_sig(compose, FALSE);
if (prefs_common.linewrap_quote)
- compose_wrap_line_all(compose);
+ compose_wrap_all(compose);
gtk_text_buffer_get_start_iter(textbuf, &iter);
gtk_text_buffer_place_cursor(textbuf, &iter);
G_CALLBACK(compose_changed_cb),
compose);
- g_signal_handlers_block_by_func(G_OBJECT(textbuf),
- G_CALLBACK(text_inserted),
- compose);
-
if ((fp = procmime_get_first_text_content(msginfo)) == NULL)
g_warning("Can't get text part\n");
else {
while (fgets(buf, sizeof(buf), fp) != NULL) {
strcrchomp(buf);
gtk_text_buffer_insert(textbuf, &iter, buf, -1);
- gtk_text_buffer_get_iter_at_mark(textbuf, &iter, mark);
}
fclose(fp);
}
compose_attach_parts(compose, msginfo);
- g_signal_handlers_unblock_by_func(G_OBJECT(textbuf),
- G_CALLBACK(text_inserted),
- compose);
g_signal_handlers_unblock_by_func(G_OBJECT(textbuf),
G_CALLBACK(compose_changed_cb),
compose);
compose_ext_editor_cb(compose, 0, NULL);
break;
case A_LINEWRAP_CURRENT:
- compose_wrap_line(compose);
+ compose_wrap_paragraph(compose, NULL);
break;
case A_LINEWRAP_ALL:
- compose_wrap_line_all(compose);
+ compose_wrap_all(compose);
break;
case A_ADDRBOOK:
compose_address_cb(compose, 0, NULL);
if (cur_pos > gtk_text_buffer_get_char_count (buffer))
cur_pos = gtk_text_buffer_get_char_count (buffer);
- gtk_text_buffer_get_iter_at_offset (buffer, &iter, cur_pos);
- gtk_text_buffer_place_cursor (buffer, &iter);
+ gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
+ gtk_text_buffer_place_cursor(buffer, &iter);
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(compose_changed_cb),
{
gchar *sig_body = NULL;
gchar *sig_str = NULL;
+ gchar *utf8_sig_str = NULL;
g_return_val_if_fail(compose->account != NULL, NULL);
g_free(tmp);
}
- if (compose->account->sig_sep)
+ if (compose->account->sig_sep) {
sig_str = g_strconcat("\n\n", compose->account->sig_sep, "\n", sig_body,
NULL);
- else
+ g_free(sig_body);
+ } else
sig_str = g_strconcat("\n\n", sig_body, NULL);
- g_free(sig_body);
-
- return sig_str;
+ if (sig_str) {
+ utf8_sig_str = conv_codeset_strdup
+ (sig_str, conv_get_locale_charset_str(), CS_INTERNAL);
+ g_free(sig_str);
+ }
+
+ return utf8_sig_str;
}
static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *file)
gchar buf[BUFFSIZE];
gint len;
FILE *fp;
+ gboolean prev_autowrap;
gboolean badtxt = FALSE;
g_return_val_if_fail(file != NULL, COMPOSE_INSERT_NO_FILE);
cur_encoding = conv_get_locale_charset_str();
+ prev_autowrap = compose->autowrap;
+ compose->autowrap = FALSE;
+
while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar *str;
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(text_inserted),
compose);
+ compose->autowrap = prev_autowrap;
+ if (compose->autowrap)
+ compose_wrap_all(compose);
fclose(fp);
procmime_mimeinfo_free_all(mimeinfo);
}
-
-#define CHAR_BUF_SIZE 8
#undef NEXT_PART_NOT_CHILD
-#define GET_CHAR(iter_p, buf, len) \
-{ \
- GtkTextIter end_iter; \
- gchar *tmp; \
- end_iter = *iter_p; \
- gtk_text_iter_forward_char(&end_iter); \
- tmp = gtk_text_buffer_get_text(textbuf, iter_p, &end_iter, FALSE); \
- if (tmp) { \
- glong items_read, items_witten; \
- GError *error = NULL; \
- gunichar *wide_char; \
- strncpy2(buf, tmp, CHAR_BUF_SIZE); \
- wide_char = g_utf8_to_ucs4(tmp, -1, \
- &items_read, &items_witten, \
- &error); \
- if (error != NULL) { \
- g_warning("%s\n", error->message); \
- g_error_free(error); \
- } \
- len = wide_char && g_unichar_iswide(*wide_char) ? 2 : 1; \
- g_free(wide_char); \
- } else { \
- buf[0] = '\0'; \
- len = 1; \
- } \
- g_free(tmp); \
-}
-
-#define DISP_WIDTH(len) \
- ((len > 2 && conv_get_locale_charset() == C_UTF_8) ? 2 : \
- (len == 2 && conv_get_locale_charset() == C_UTF_8) ? 1 : len)
-
-#define SPACE_CHARS " \t"
-
-static void compose_wrap_line(Compose *compose)
-{
- GtkTextView *text = GTK_TEXT_VIEW(compose->text);
- GtkTextBuffer *textbuf = gtk_text_view_get_buffer(text);
- GtkTextMark *mark;
- GtkTextIter insert_iter, iter;
- gint ch_len, last_ch_len;
- gchar cbuf[CHAR_BUF_SIZE], last_ch;
- guint text_len;
- gint p_start, p_end;
- gint line_pos, cur_pos;
- gint line_len, cur_len;
- gboolean line_end, quoted;
-
- text_len = gtk_text_buffer_get_char_count(textbuf);
- mark = gtk_text_buffer_get_insert(textbuf);
- gtk_text_buffer_get_iter_at_mark(textbuf, &insert_iter, mark);
- cur_pos = gtk_text_iter_get_offset(&insert_iter);
- GET_CHAR(&insert_iter, cbuf, ch_len);
- if ((ch_len == 1 && *cbuf == '\n') || cur_pos == text_len) {
- GtkTextIter prev_iter;
- if (cur_pos == 0)
- return; /* on the paragraph mark */
- prev_iter = insert_iter;
- gtk_text_iter_backward_char(&prev_iter);
- GET_CHAR(&prev_iter, cbuf, ch_len);
- if (ch_len == 1 && *cbuf == '\n')
- return; /* on the paragraph mark */
- }
-
- /* find paragraph start. */
- line_end = quoted = FALSE;
- for (iter = insert_iter; gtk_text_iter_backward_char(&iter);) {
- GET_CHAR(&iter, cbuf, ch_len);
- if (ch_len == 1 && *cbuf == '\n') {
- if (quoted)
- return; /* quoted part */
- if (line_end) {
- gtk_text_iter_forward_chars(&iter, 2);
- break;
- }
- line_end = TRUE;
- } else {
- if (ch_len == 1
- && strchr(prefs_common.quote_chars, *cbuf))
- quoted = 1;
- else if (ch_len != 1 || !isspace(*(guchar *)cbuf))
- quoted = 0;
-
- line_end = FALSE;
- }
- }
- p_start = gtk_text_iter_get_offset(&iter);
-
- /* find paragraph end. */
- line_end = FALSE;
- for (iter = insert_iter; gtk_text_iter_forward_char(&iter);) {
- GET_CHAR(&iter, cbuf, ch_len);
- if (ch_len == 1 && *cbuf == '\n') {
- if (line_end) {
- p_end -= 1;
- gtk_text_iter_backward_char(&iter);
- break;
- }
- line_end = TRUE;
- } else {
- if (line_end && ch_len == 1 &&
- strchr(prefs_common.quote_chars, *cbuf))
- return; /* quoted part */
-
- line_end = FALSE;
- }
- }
- p_end = gtk_text_iter_get_offset(&iter);
-
- if (p_end >= text_len)
- p_end = text_len;
-
- if (p_start >= p_end)
- return;
-
- line_len = cur_len = 0;
- last_ch_len = 0;
- last_ch = '\0';
- line_pos = p_start;
- for (cur_pos = p_start; cur_pos < p_end; cur_pos++) {
- gboolean space = FALSE;
-
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, cur_pos);
-
- GET_CHAR(&iter, cbuf, ch_len);
-
- if (ch_len < 0) {
- cbuf[0] = '\0';
- ch_len = 1;
- }
-
- if (ch_len == 1 && isspace(*(guchar *)cbuf))
- space = 1;
-
- if (ch_len == 1 && *cbuf == '\n') {
- gboolean replace = FALSE;
- GtkTextIter next_iter = iter;
-
- gtk_text_iter_forward_char(&next_iter);
-
- if (last_ch_len == 1 && !isspace((guchar)last_ch)) {
- if (cur_pos + 1 < p_end) {
- GET_CHAR(&next_iter, cbuf, ch_len);
- if (ch_len == 1 &&
- !isspace(*(guchar *)cbuf))
- replace = TRUE;
- }
- }
- gtk_text_buffer_delete(textbuf, &iter, &next_iter);
- if (replace) {
- gtk_text_buffer_insert(textbuf, &iter, " ", 1);
- space = TRUE;
- }
- else {
- p_end--;
- cur_pos--;
- gtk_text_buffer_get_iter_at_offset
- (textbuf, &iter, cur_pos);
- continue;
- }
- }
-
- last_ch_len = ch_len;
- last_ch = *cbuf;
-
- if (space) {
- line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
- }
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, line_pos);
-
- if (cur_len + ch_len > prefs_common.linewrap_len &&
- line_len > 0) {
- gint tlen = ch_len;
- GtkTextIter prev_iter = iter;
-
- gtk_text_iter_backward_char(&prev_iter);
-
- GET_CHAR(&prev_iter, cbuf, ch_len);
- if (ch_len == 1 && isspace(*(guchar *)cbuf)) {
- gtk_text_buffer_delete(textbuf, &prev_iter, &iter);
- iter = prev_iter;
- p_end--;
- cur_pos--;
- line_pos--;
- cur_len--;
- line_len--;
- }
- ch_len = tlen;
-
- gtk_text_buffer_insert(textbuf, &iter, "\n", 1);
- p_end++;
- cur_pos++;
- line_pos++;
- cur_len = cur_len - line_len + ch_len;
- line_len = 0;
- continue;
- }
-
- if (ch_len > 1) {
- line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
- }
- cur_len += ch_len;
- }
-}
-
-#undef WRAP_DEBUG
-#ifdef WRAP_DEBUG
-/* Darko: used when I debug wrapping */
-void dump_text(GtkTextBuffer *textbuf, int pos, int tlen, int breakoncr)
-{
- gint i, clen;
- gchar cbuf[CHAR_BUF_SIZE];
- GtkTextIter iter, end_iter;
-
- printf("%d [", pos);
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, pos);
- gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter, pos + tlen);
- for (; gtk_text_iter_forward_char(&iter) &&
- gtk_text_iter_compare(&iter, &end_iter) < 0;) {
- GET_CHAR(&iter, cbuf, clen);
- if (clen < 0) break;
- if (breakoncr && clen == 1 && cbuf[0] == '\n')
- break;
- fwrite(cbuf, clen, 1, stdout);
- }
- printf("]\n");
-}
-#endif
typedef enum {
- WAIT_FOR_SPACE,
WAIT_FOR_INDENT_CHAR,
- WAIT_FOR_INDENT_CHAR_OR_SPACE
+ WAIT_FOR_INDENT_CHAR_OR_SPACE,
} IndentState;
/* return indent length, we allow:
- > followed by spaces/tabs
- | followed by spaces/tabs
- uppercase characters immediately followed by >,
- and the repeating sequences of the above */
-/* return indent length */
-static guint get_indent_length(GtkTextBuffer *textbuf, guint start_pos, guint text_len)
-{
- guint i_len = 0;
- guint i, ch_len, alnum_cnt = 0;
+ indent characters followed by indent characters or spaces/tabs,
+ alphabets and numbers immediately followed by indent characters,
+ and the repeating sequences of the above
+ If quote ends with multiple spaces, only the first one is included. */
+static gchar *compose_get_quote_str(GtkTextBuffer *buffer,
+ const GtkTextIter *start, gint *len)
+{
+ GtkTextIter iter = *start;
+ gunichar wc;
+ gchar ch[6];
+ gint clen;
IndentState state = WAIT_FOR_INDENT_CHAR;
- gchar cbuf[CHAR_BUF_SIZE];
gboolean is_space;
gboolean is_indent;
+ gint alnum_count = 0;
+ gint space_count = 0;
+ gint quote_len = 0;
if (prefs_common.quote_chars == NULL) {
return 0 ;
}
- for (i = start_pos; i < text_len; i++) {
- GtkTextIter iter;
-
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, i);
- GET_CHAR(&iter, cbuf, ch_len);
- if (ch_len > 1)
+ while (!gtk_text_iter_ends_line(&iter)) {
+ wc = gtk_text_iter_get_char(&iter);
+ if (g_unichar_iswide(wc))
break;
-
- if (cbuf[0] == '\n')
+ clen = g_unichar_to_utf8(wc, ch);
+ if (clen != 1)
break;
- is_indent = strchr(prefs_common.quote_chars, cbuf[0]) ? TRUE : FALSE;
- is_space = strchr(SPACE_CHARS, cbuf[0]) ? TRUE : FALSE;
+ is_indent = strchr(prefs_common.quote_chars, ch[0]) ? TRUE : FALSE;
+ is_space = g_unichar_isspace(wc);
- switch (state) {
- case WAIT_FOR_SPACE:
- if (is_space == FALSE)
- goto out;
- state = WAIT_FOR_INDENT_CHAR_OR_SPACE;
- break;
- case WAIT_FOR_INDENT_CHAR_OR_SPACE:
- if (is_indent == FALSE && is_space == FALSE &&
- !isupper((guchar)cbuf[0]))
- goto out;
- if (is_space == TRUE) {
- alnum_cnt = 0;
+ if (state == WAIT_FOR_INDENT_CHAR) {
+ if (!is_indent && !g_unichar_isalnum(wc))
+ break;
+ if (is_indent) {
+ quote_len += alnum_count + space_count + 1;
+ alnum_count = space_count = 0;
state = WAIT_FOR_INDENT_CHAR_OR_SPACE;
- } else if (is_indent == TRUE) {
- alnum_cnt = 0;
- state = WAIT_FOR_SPACE;
+ } else
+ alnum_count++;
+ } else if (state == WAIT_FOR_INDENT_CHAR_OR_SPACE) {
+ if (!is_indent && !is_space && !g_unichar_isalnum(wc))
+ break;
+ if (is_space)
+ space_count++;
+ else if (is_indent) {
+ quote_len += alnum_count + space_count + 1;
+ alnum_count = space_count = 0;
} else {
- alnum_cnt++;
+ alnum_count++;
state = WAIT_FOR_INDENT_CHAR;
}
- break;
- case WAIT_FOR_INDENT_CHAR:
- if (is_indent == FALSE && !isupper((guchar)cbuf[0]))
- goto out;
- if (is_indent == TRUE) {
- if (alnum_cnt > 0
- && !strchr(prefs_common.quote_chars, cbuf[0]))
- goto out;
- alnum_cnt = 0;
- state = WAIT_FOR_SPACE;
- } else {
- alnum_cnt++;
- }
- break;
}
- i_len++;
+ gtk_text_iter_forward_char(&iter);
}
-out:
- if ((i_len > 0) && (state == WAIT_FOR_INDENT_CHAR))
- i_len -= alnum_cnt;
+ if (quote_len > 0 && space_count > 0)
+ quote_len++;
+
+ if (len)
+ *len = quote_len;
+
+ if (quote_len > 0) {
+ iter = *start;
+ gtk_text_iter_forward_chars(&iter, quote_len);
+ return gtk_text_buffer_get_text(buffer, start, &iter, FALSE);
+ }
- return i_len;
+ return NULL;
}
-/* insert quotation string when line was wrapped */
-static guint ins_quote(GtkTextBuffer *textbuf, GtkTextIter *iter,
- guint indent_len,
- guint prev_line_pos, guint text_len,
- gchar *quote_fmt)
+static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
+ const GtkTextIter *start,
+ GtkTextIter *break_pos,
+ gint max_col,
+ gint quote_len)
{
- guint ins_len = 0;
+ GtkTextIter iter = *start, line_end = *start;
+ PangoLogAttr *attrs;
+ gchar *str;
+ gchar *p;
+ gint len;
+ gint i;
+ gint col = 0;
+ gint pos = 0;
+ gboolean can_break = FALSE;
+ gboolean do_break = FALSE;
- if (indent_len) {
- GtkTextIter iter1, iter2;
- gchar *text;
+ gtk_text_iter_forward_to_line_end(&line_end);
+ str = gtk_text_buffer_get_text(buffer, &iter, &line_end, FALSE);
+ len = g_utf8_strlen(str, -1);
+ /* g_print("breaking line: %d: %s (len = %d)\n",
+ gtk_text_iter_get_line(&iter), str, len); */
+ attrs = g_new(PangoLogAttr, len + 1);
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter1,
- prev_line_pos);
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter2,
- prev_line_pos + indent_len);
- text = gtk_text_buffer_get_text(textbuf, &iter1, &iter2, FALSE);
- if (!text) return 0;
+ pango_default_break(str, -1, NULL, attrs, len + 1);
+
+ p = str;
+
+ /* skip quote and leading spaces */
+ for (i = 0; *p != '\0' && i < len; i++) {
+ gunichar wc;
+
+ wc = g_utf8_get_char(p);
+ if (i >= quote_len && !g_unichar_isspace(wc))
+ break;
+ if (g_unichar_iswide(wc))
+ col += 2;
+ else if (*p == '\t')
+ col += 8;
+ else
+ col++;
+ p = g_utf8_next_char(p);
+ }
+
+ for (; *p != '\0' && i < len; i++) {
+ PangoLogAttr *attr = attrs + i;
+ gunichar wc;
+ gint uri_len;
+
+ if (attr->is_line_break && can_break)
+ pos = i;
+
+ /* don't wrap URI */
+ if ((uri_len = get_uri_len(p)) > 0) {
+ col += uri_len;
+ if (pos > 0 && col > max_col) {
+ do_break = TRUE;
+ break;
+ }
+ i += uri_len - 1;
+ p += uri_len;
+ can_break = TRUE;
+ continue;
+ }
- gtk_text_buffer_insert(textbuf, iter, text, -1);
- ins_len = g_utf8_strlen(text, -1);
+ wc = g_utf8_get_char(p);
+ if (g_unichar_iswide(wc))
+ col += 2;
+ else if (*p == '\t')
+ col += 8;
+ else
+ col++;
+ if (pos > 0 && col > max_col) {
+ do_break = TRUE;
+ break;
+ }
- g_free(text);
+ p = g_utf8_next_char(p);
+ can_break = TRUE;
}
- return ins_len;
+ debug_print("compose_get_line_break_pos(): do_break = %d, pos = %d, col = %d\n", do_break, pos, col);
+
+ g_free(attrs);
+ g_free(str);
+
+ *break_pos = *start;
+ gtk_text_iter_set_line_offset(break_pos, pos);
+
+ return do_break;
}
static gboolean is_sig_separator(Compose *compose, GtkTextBuffer *textbuf, guint start_pos)
return FALSE;
}
-/* check if we should join the next line */
-static gboolean join_next_line_is_needed(GtkTextBuffer *textbuf,
- guint start_pos, guint tlen,
- guint prev_ilen, gboolean autowrap)
+static gboolean compose_join_next_line(GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ const gchar *quote_str)
{
- guint indent_len, ch_len;
- gboolean do_join = FALSE;
- gchar cbuf[CHAR_BUF_SIZE];
+ GtkTextIter iter_ = *iter, cur, prev, next;
+ PangoLogAttr attrs[3];
+ gchar *str;
+ gchar *next_quote_str;
+ gunichar wc1, wc2;
+ gint quote_len;
+ gboolean keep_cursor = FALSE;
- indent_len = get_indent_length(textbuf, start_pos, tlen);
+ if (!gtk_text_iter_forward_line(&iter_) ||
+ gtk_text_iter_ends_line(&iter_))
+ return FALSE;
- if ((autowrap || indent_len > 0) && indent_len == prev_ilen) {
- GtkTextIter iter;
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter,
- start_pos + indent_len);
- GET_CHAR(&iter, cbuf, ch_len);
-
- if (ch_len > 0 && (cbuf[0] != '\n'))
- do_join = TRUE;
- }
+ next_quote_str = compose_get_quote_str(buffer, &iter_, "e_len);
- return do_join;
-}
+ if ((quote_str || next_quote_str) &&
+ strcmp2(quote_str, next_quote_str) != 0) {
+ g_free(next_quote_str);
+ return FALSE;
+ }
+ g_free(next_quote_str);
-static void compose_wrap_line_all(Compose *compose)
-{
- compose_wrap_line_all_full(compose, FALSE);
-}
+ /* delete quote str */
+ if (quote_len > 0) {
+ GtkTextIter end = iter_;
-static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
-{
- GtkTextView *text = GTK_TEXT_VIEW(compose->text);
- GtkTextBuffer *textbuf = gtk_text_view_get_buffer(text);
- GtkTextIter iter, end_iter;
- guint tlen;
- guint line_pos = 0, cur_pos = 0, p_pos = 0;
- gint line_len = 0, cur_len = 0;
- gint ch_len;
- gboolean is_new_line = TRUE, do_delete = FALSE;
- guint i_len = 0;
- gboolean linewrap_quote = prefs_common.linewrap_quote;
- gboolean set_editable_pos = FALSE;
- gint editable_pos = 0;
- guint linewrap_len = prefs_common.linewrap_len;
- gchar *qfmt = prefs_common.quotemark;
- gchar cbuf[CHAR_BUF_SIZE];
- GtkTextMark *cursor_mark = gtk_text_buffer_get_insert(textbuf);
-
- tlen = gtk_text_buffer_get_char_count(textbuf);
+ gtk_text_iter_forward_chars(&end, quote_len);
+ if (gtk_text_iter_ends_line(&end))
+ return FALSE;
+ gtk_text_buffer_delete(buffer, &iter_, &end);
+ }
- for (; cur_pos < tlen; cur_pos++) {
- /* mark position of new line - needed for quotation wrap */
- if (is_new_line) {
- if (linewrap_quote)
- i_len = get_indent_length(textbuf, cur_pos, tlen);
+ /* delete linebreak and extra spaces */
+ prev = cur = iter_;
+ while (gtk_text_iter_backward_char(&cur)) {
+ wc1 = gtk_text_iter_get_char(&cur);
+ if (!g_unichar_isspace(wc1))
+ break;
+ prev = cur;
+ }
+ next = cur = iter_;
+ while (!gtk_text_iter_ends_line(&cur)) {
+ wc1 = gtk_text_iter_get_char(&cur);
+ if (!g_unichar_isspace(wc1))
+ break;
+ gtk_text_iter_forward_char(&cur);
+ next = cur;
+ }
+ if (!gtk_text_iter_equal(&prev, &next)) {
+ GtkTextMark *mark;
- is_new_line = FALSE;
- p_pos = cur_pos;
+ mark = gtk_text_buffer_get_insert(buffer);
+ gtk_text_buffer_get_iter_at_mark(buffer, &cur, mark);
+ if (gtk_text_iter_equal(&prev, &cur))
+ keep_cursor = TRUE;
+ gtk_text_buffer_delete(buffer, &prev, &next);
+ }
+ iter_ = prev;
+
+ /* insert space if required */
+ gtk_text_iter_backward_char(&prev);
+ wc1 = gtk_text_iter_get_char(&prev);
+ wc2 = gtk_text_iter_get_char(&next);
+ gtk_text_iter_forward_char(&next);
+ str = gtk_text_buffer_get_text(buffer, &prev, &next, FALSE);
+ pango_default_break(str, -1, NULL, attrs, 3);
+ if (!attrs[1].is_line_break ||
+ (!g_unichar_iswide(wc1) || !g_unichar_iswide(wc2))) {
+ gtk_text_buffer_insert(buffer, &iter_, " ", 1);
+ if (keep_cursor) {
+ gtk_text_iter_backward_char(&iter_);
+ gtk_text_buffer_place_cursor(buffer, &iter_);
}
+ }
+ g_free(str);
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, cur_pos);
- GET_CHAR(&iter, cbuf, ch_len);
+ *iter = iter_;
+ return TRUE;
+}
- /* fix line length for tabs */
- if (ch_len == 1 && *cbuf == '\t') {
- guint tab_width = 8;
- guint tab_offset = line_len % tab_width;
+static void compose_wrap_paragraph(Compose *compose, GtkTextIter *par_iter)
+{
+ GtkTextView *text = GTK_TEXT_VIEW(compose->text);
+ GtkTextBuffer *buffer;
+ GtkTextIter iter, break_pos;
+ gchar *quote_str = NULL;
+ gint quote_len;
+ gboolean wrap_quote = prefs_common.linewrap_quote;
- line_len += tab_width - tab_offset - 1;
- cur_len = line_len;
- }
+ buffer = gtk_text_view_get_buffer(text);
- /* we have encountered line break */
- if (ch_len == 1 && *cbuf == '\n') {
- gint clen;
- gchar cb[CHAR_BUF_SIZE];
-
- /* should we join the next line */
- if ((autowrap || i_len != cur_len) && do_delete &&
- !is_sig_separator(compose, textbuf, cur_pos+i_len) &&
- join_next_line_is_needed
- (textbuf, cur_pos + 1, tlen, i_len, autowrap)) {
- do_delete = TRUE;
- } else
- do_delete = FALSE;
-
- /* skip delete if it is continuous URL */
- if (do_delete && (line_pos - p_pos <= i_len) &&
- gtkut_text_buffer_is_uri_string(textbuf, line_pos,
- tlen))
- do_delete = FALSE;
-
- /* should we delete to perform smart wrapping */
- if (line_len < linewrap_len && do_delete) {
- /* get rid of newline */
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &iter,
- cur_pos);
- end_iter = iter;
- gtk_text_iter_forward_char(&end_iter);
- gtk_text_buffer_delete(textbuf, &iter, &end_iter);
- tlen--;
-
- /* if text starts with quote fmt or with
- indent string, delete them */
- if (i_len) {
- guint ilen;
- ilen = gtkut_text_buffer_str_compare_n
- (textbuf, cur_pos, p_pos, i_len,
- tlen);
- if (ilen) {
- end_iter = iter;
- gtk_text_iter_forward_chars
- (&end_iter, ilen);
- gtk_text_buffer_delete(textbuf,
- &iter,
- &end_iter);
- tlen -= ilen;
- }
- }
+ if (par_iter) {
+ iter = *par_iter;
+ } else {
+ GtkTextMark *mark;
+ mark = gtk_text_buffer_get_insert(buffer);
+ gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+ }
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &iter,
- cur_pos);
- GET_CHAR(&iter, cb, clen);
-
- /* insert space if it's alphanumeric */
- if ((cur_pos != line_pos) &&
- ((clen > 1) || isalnum((guchar)cb[0]))) {
- GtkTextIter cursor_iter;
- gboolean go_back = FALSE;
- gtk_text_buffer_get_iter_at_mark(textbuf, &cursor_iter, cursor_mark);
- if (gtk_text_iter_get_offset(&iter) ==
- gtk_text_iter_get_offset(&cursor_iter))
- go_back = TRUE;
-
- gtk_text_buffer_insert(textbuf, &iter,
- " ", 1);
- if (go_back) {
- gtk_text_buffer_get_iter_at_mark(textbuf, &cursor_iter, cursor_mark);
- gtk_text_iter_backward_chars(&cursor_iter, 1);
- gtk_text_buffer_place_cursor(textbuf, &cursor_iter);
- }
- tlen++;
- }
+ /* move to paragraph start */
+ gtk_text_iter_set_line_offset(&iter, 0);
+ if (gtk_text_iter_ends_line(&iter)) {
+ while (gtk_text_iter_ends_line(&iter) &&
+ gtk_text_iter_forward_line(&iter))
+ ;
+ } else {
+ while (gtk_text_iter_backward_line(&iter)) {
+ if (gtk_text_iter_ends_line(&iter)) {
+ gtk_text_iter_forward_line(&iter);
+ break;
+ }
+ }
+ }
- /* and start over with current line */
- cur_pos = p_pos - 1;
- line_pos = cur_pos;
- line_len = cur_len = 0;
- do_delete = FALSE;
- is_new_line = TRUE;
-#ifdef WRAP_DEBUG
- g_print("after delete l_pos=");
- dump_text(textbuf, line_pos, tlen, 1);
-#endif
- /* move beginning of line if we are on LF */
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &iter,
- line_pos);
- GET_CHAR(&iter, cb, clen);
- if (clen == 1 && *cb == '\n')
- line_pos++;
-#ifdef WRAP_DEBUG
- g_print("new line_pos=%d\n", line_pos);
-#endif
+ if (gtk_text_iter_is_end(&iter)) {
+ if (par_iter)
+ *par_iter = iter;
+ return;
+ }
+ do {
+ quote_str = compose_get_quote_str(buffer, &iter, "e_len);
+ if (quote_str) {
+ if (!wrap_quote) {
+ gtk_text_iter_forward_line(&iter);
+ g_free(quote_str);
continue;
}
-
- /* mark new line beginning */
- line_pos = cur_pos + 1;
- line_len = cur_len = 0;
- do_delete = FALSE;
- is_new_line = TRUE;
- continue;
- }
-
- if (ch_len < 0) {
- cbuf[0] = '\0';
- ch_len = 1;
+ debug_print("compose_wrap_paragraph(): quote_str = '%s'\n", quote_str);
}
- /* possible line break */
- if (ch_len == 1 && isspace(*(guchar *)cbuf)) {
- line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
- }
+ if (compose_get_line_break_pos(buffer, &iter, &break_pos,
+ prefs_common.linewrap_len,
+ quote_len)) {
+ GtkTextIter prev, next, cur;
- /* are we over wrapping length set in preferences ? */
- if (cur_len + DISP_WIDTH(ch_len) > linewrap_len) {
- gint clen;
+ gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
-#ifdef WRAP_DEBUG
- g_print("should wrap cur_pos=%d ", cur_pos);
- dump_text(textbuf, p_pos, tlen, 1);
- dump_text(textbuf, line_pos, tlen, 1);
-#endif
- /* force wrapping if it is one long word but not URL */
- if (line_pos - p_pos <= i_len)
- if (!gtkut_text_buffer_is_uri_string
- (textbuf, line_pos, tlen))
- line_pos = cur_pos - 1;
-#ifdef WRAP_DEBUG
- g_print("new line_pos=%d\n", line_pos);
-#endif
+ /* remove trailing spaces */
+ cur = break_pos;
+ gtk_text_iter_backward_char(&cur);
+ prev = next = cur;
+ while (!gtk_text_iter_starts_line(&cur)) {
+ gunichar wc;
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &iter,
- line_pos - 1);
- GET_CHAR(&iter, cbuf, clen);
-
- /* if next character is space delete it */
- if (clen == 1 && isspace(*(guchar *)cbuf)) {
- if (p_pos + i_len != line_pos ||
- !gtkut_text_buffer_is_uri_string
- (textbuf, line_pos, tlen)) {
- /* workaround for correct cursor
- position */
- if (set_editable_pos == FALSE) {
- GtkTextMark *ins = gtk_text_buffer_get_insert(textbuf);
- gtk_text_buffer_get_iter_at_mark(textbuf, &iter, ins);
- editable_pos = gtk_text_iter_get_offset(&iter);
- if (editable_pos == line_pos)
- set_editable_pos = TRUE;
- }
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &iter,
- line_pos-1);
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &end_iter,
- line_pos);
- gtk_text_buffer_delete(textbuf, &iter, &end_iter);
- //gtk_stext_set_point(text, line_pos);
- //gtk_stext_backward_delete(text, 1);
- tlen--;
- cur_pos--;
- line_pos--;
- cur_len--;
- line_len--;
- }
+ gtk_text_iter_backward_char(&cur);
+ wc = gtk_text_iter_get_char(&cur);
+ if (!g_unichar_isspace(wc))
+ break;
+ prev = cur;
}
-
- /* if it is URL at beginning of line don't wrap */
- if (p_pos + i_len == line_pos &&
- gtkut_text_buffer_is_uri_string(textbuf, line_pos, tlen)) {
-#ifdef WRAP_DEBUG
- g_print("found URL at ");
- dump_text(textbuf, line_pos, tlen, 1);
-#endif
- continue;
+ if (!gtk_text_iter_equal(&prev, &next)) {
+ gtk_text_buffer_delete(buffer, &prev, &next);
+ break_pos = next;
+ gtk_text_iter_forward_char(&break_pos);
}
- /* insert CR */
- gtk_text_buffer_get_iter_at_offset(textbuf,
- &iter,
- line_pos);
- gtk_text_buffer_insert(textbuf, &iter, "\n", 1);
- //gtk_stext_set_point(text, line_pos);
- //gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
- //gtk_stext_compact_buffer(text);
- tlen++;
- line_pos++;
- /* for loop will increase it */
- cur_pos = line_pos - 1;
- /* start over with current line */
- is_new_line = TRUE;
- line_len = cur_len = 0;
- if (autowrap || i_len > 0) {
- do_delete = TRUE;
- } else
- do_delete = FALSE;
-#ifdef WRAP_DEBUG
- g_print("after CR insert ");
- dump_text(textbuf, line_pos, tlen, 1);
- dump_text(textbuf, cur_pos, tlen, 1);
-#endif
+ if (quote_str)
+ gtk_text_buffer_insert(buffer, &break_pos,
+ quote_str, -1);
- /* should we insert quotation ? */
- if (linewrap_quote && i_len) {
- /* only if line is not already quoted */
- if (!gtkut_text_buffer_str_compare
- (textbuf, line_pos, tlen, qfmt)) {
- guint ins_len;
-
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, line_pos);
-
- if (line_pos - p_pos > i_len) {
- ins_len = ins_quote
- (textbuf, &iter, i_len, p_pos,
- tlen, qfmt);
- tlen += ins_len;
- }
-#ifdef WRAP_DEBUG
- g_print("after quote insert ");
- dump_text(textbuf, line_pos, tlen, 1);
-#endif
- }
- }
- continue;
- }
+ iter = break_pos;
+ compose_join_next_line(buffer, &iter, quote_str);
- if (ch_len > 1) {
- line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
+ /* move iter to current line start */
+ gtk_text_iter_set_line_offset(&iter, 0);
+ } else {
+ /* move iter to next line start */
+ iter = break_pos;
+ gtk_text_iter_forward_line(&iter);
}
- /* advance to next character in buffer */
- cur_len += ch_len;
- }
- if (set_editable_pos && editable_pos <= tlen) {
- gtk_text_buffer_get_iter_at_offset(textbuf, &iter, editable_pos);
- gtk_text_buffer_place_cursor(textbuf, &iter);
- }
+ g_free(quote_str);
+ } while (!gtk_text_iter_ends_line(&iter));
+ /* stop if paragraph end (empty line) */
+
+ if (par_iter)
+ *par_iter = iter;
}
-#undef GET_CHAR
-#undef CHAR_BUF_SIZE
+static void compose_wrap_all(Compose *compose)
+{
+ compose_wrap_all_full(compose, FALSE);
+}
+
+static void compose_wrap_all_full(Compose *compose, gboolean autowrap)
+{
+ GtkTextView *text = GTK_TEXT_VIEW(compose->text);
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+
+ buffer = gtk_text_view_get_buffer(text);
+
+ gtk_text_buffer_get_start_iter(buffer, &iter);
+ while (!gtk_text_iter_is_end(&iter))
+ compose_wrap_paragraph(compose, &iter);
+}
static void compose_set_title(Compose *compose)
{
if (action == COMPOSE_WRITE_FOR_SEND) {
buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
+
if (!buf) {
AlertValue aval;
gchar *msg;
}
g_free(chars);
+ if (encoding == ENC_8BIT || encoding == ENC_7BIT) {
+ if (!strncmp(buf, "From ", sizeof("From ")-1) ||
+ strstr(buf, "\nFrom ") != NULL) {
+ encoding = ENC_QUOTED_PRINTABLE;
+ }
+ }
+
mimetext = procmime_mimeinfo_new();
mimetext->content = MIMECONTENT_MEM;
mimetext->data.mem = buf;
/* protect trailing spaces when signing message */
if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing &&
privacy_system_can_sign(compose->privacy_system))
- encoding = ENC_QUOTED_PRINTABLE;
+ if (encoding == ENC_7BIT)
+ encoding = ENC_QUOTED_PRINTABLE;
+ else if (encoding == ENC_8BIT)
+ encoding = ENC_BASE64;
if (encoding != ENC_UNKNOWN)
procmime_encode_content(mimetext, encoding);
return -1;
procmime_write_mimeinfo(mimemsg, fp);
+
+ procmime_mimeinfo_free_all(mimemsg);
return 0;
}
}
if (prefs_common.linewrap_at_send)
- compose_wrap_line_all(compose);
+ compose_wrap_all(compose);
/* write queue header */
tmp = g_strdup_printf("%s%cqueue.%p", get_tmp_dir(),
mimepart->disposition = DISPOSITIONTYPE_ATTACHMENT;
}
+ if (compose->use_signing) {
+ if (ainfo->encoding == ENC_7BIT)
+ ainfo->encoding = ENC_QUOTED_PRINTABLE;
+ else if (ainfo->encoding == ENC_8BIT)
+ ainfo->encoding = ENC_BASE64;
+ }
+
procmime_encode_content(mimepart, ainfo->encoding);
g_node_append(parent->node, mimepart->node);
gchar *titles[N_ATTACH_COLS];
guint n_menu_entries;
- GtkStyle *style, *new_style;
GdkColormap *cmap;
GdkColor color[1];
gboolean success[1];
/* text widget */
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(edit_vbox), scrolledwin, TRUE, TRUE, 0);
gtk_paned_add2(GTK_PANED(paned), edit_vbox);
gtk_widget_show_all(paned);
- style = gtk_widget_get_style(text);
-
- new_style = gtk_style_copy(style);
if (prefs_common.textfont) {
PangoFontDescription *font_desc;
font_desc = pango_font_description_from_string
- (prefs_common.textfont);
+ (prefs_common.textfont);
if (font_desc) {
- if (new_style->font_desc)
- pango_font_description_free
- (new_style->font_desc);
- new_style->font_desc = font_desc;
+ gtk_widget_modify_font(text, font_desc);
+ pango_font_description_free(font_desc);
}
}
- gtk_widget_set_style(text, new_style);
-
color[0] = quote_color;
cmap = gdk_window_get_colormap(window->window);
gdk_colormap_alloc_colors(cmap, color, 1, FALSE, TRUE, success);
if (success[0] == FALSE) {
+ GtkStyle *style;
+
g_warning("Compose: color allocation failed.\n");
style = gtk_widget_get_style(text);
quote_color = style->black;
ifactory = gtk_item_factory_from_widget(compose->menubar);
menu_set_sensitive(ifactory, "/Options/Sign", can_sign);
+ if (!can_sign)
+ menu_set_active(ifactory, "/Options/Sign", FALSE);
menu_set_sensitive(ifactory, "/Options/Encrypt", can_encrypt);
+ if (!can_encrypt)
+ menu_set_active(ifactory, "/Options/Encrypt", FALSE);
}
static void compose_update_privacy_system_menu_item(Compose * compose)
}
}
-static gint calc_cursor_xpos(GtkTextView *text, gint extra, gint char_width)
-{
-#warning FIXME_GTK2
- return 0;
-}
-
/* callback functions */
/* compose_edit_size_alloc() - called when resized. don't know whether Gtk
/* got the maximum */
gtk_ruler_set_range(GTK_RULER(shruler),
- 0.0, line_width_in_chars,
- calc_cursor_xpos(GTK_TEXT_VIEW(widget),
- allocation->x,
- char_width),
+ 0.0, line_width_in_chars, 0,
/*line_width_in_chars*/ char_width);
}
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *file = (gchar *) tmp->data;
- compose_attach_append(compose, file, file, NULL);
+ gchar *utf8_filename = conv_filename_to_utf8(file);
+ compose_attach_append(compose, file, utf8_filename, NULL);
compose_changed_cb(NULL, compose);
g_free(file);
+ g_free(utf8_filename);
}
g_list_free(file_list);
}
static void compose_undo_cb(Compose *compose)
{
+ gboolean prev_autowrap = compose->autowrap;
+
+ compose->autowrap = FALSE;
undo_undo(compose->undostruct);
+ compose->autowrap = prev_autowrap;
}
static void compose_redo_cb(Compose *compose)
{
+ gboolean prev_autowrap = compose->autowrap;
+
+ compose->autowrap = FALSE;
undo_redo(compose->undostruct);
+ compose->autowrap = prev_autowrap;
}
static void entry_cut_clipboard(GtkWidget *entry)
}
}
-
static void compose_cut_cb(Compose *compose)
{
if (compose->focused_editable &&
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
mark = gtk_text_buffer_get_insert(buffer);
gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
-#warning FIXME_GTK2 /* should regist current line offset */
offset = gtk_text_iter_get_line_offset(&ins);
if (gtk_text_iter_forward_line(&ins)) {
gtk_text_iter_set_line_offset(&ins, offset);
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
mark = gtk_text_buffer_get_insert(buffer);
gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
-#warning FIXME_GTK2 /* should regist current line offset */
offset = gtk_text_iter_get_line_offset(&ins);
if (gtk_text_iter_backward_line(&ins)) {
gtk_text_iter_set_line_offset(&ins, offset);
}
}
+static void compose_wrap_cb(gpointer data, guint action, GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+
+ if (action == 1)
+ compose_wrap_all(compose);
+ else
+ compose_wrap_paragraph(compose, NULL);
+}
+
static void compose_toggle_autowrap_cb(gpointer data, guint action,
GtkWidget *widget)
{
Compose *compose = (Compose *)data;
compose->autowrap = GTK_CHECK_MENU_ITEM(widget)->active;
if (compose->autowrap)
- compose_wrap_line_all_full(compose, TRUE);
+ compose_wrap_all_full(compose, TRUE);
}
static void compose_toggle_sign_cb(gpointer data, guint action,
{
gint paste_as_quotation = GPOINTER_TO_INT(g_object_get_data
(G_OBJECT(compose->text), "paste_as_quotation"));
+ GtkTextMark *mark;
- g_return_if_fail(text);
+ /* CLAWS: pass to default handler only if not pasting as quotation, and
+ * no autowrap */
+ if (!paste_as_quotation && !compose->autowrap)
+ return;
+
+ g_return_if_fail(text != NULL);
g_signal_handlers_block_by_func(G_OBJECT(buffer),
G_CALLBACK(text_inserted),
} else
gtk_text_buffer_insert(buffer, iter, text, len);
- if (compose->autowrap)
- compose_wrap_line_all_full(compose, TRUE);
+ mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
+ compose_wrap_all_full(compose, TRUE);
+ gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
+ gtk_text_buffer_delete_mark(buffer, mark);
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(text_inserted),
compose->draft_timeout_tag = gtk_timeout_add
(500, (GtkFunction) compose_defer_auto_save_draft, compose);
}
-
static gint compose_defer_auto_save_draft(Compose *compose)
{
compose->draft_timeout_tag = -1;