[前][次][番号順一覧][スレッド一覧]

sylpheed-jp:1410

From: "Good**, Hironori(Shohta) NAGAKUBO" <shohta@xxxxxxxxxx>
Date: Mon, 14 Jan 2002 14:01:17 +0900
Subject: [sylpheed-jp:01410] Re: 外部エディタでヘッダも編集できるようにするパッチ

Good**, 長久保@福島いわき です。
前回投稿の続報です。

On Sun, 13 Jan 2002 18:21:08 +0900
Subject: [sylpheed-jp:01404] Re: 外部エディタでヘッダも編集できるようにするパッチ
Message-ID: <20020113182108.32a569f7.shohta@xxxxxxxxxx>
"Good**, Hironori(Shohta) NAGAKUBO" <shohta@xxxxxxxxxx> wrote:

> On Sat, 12 Jan 2002 20:37:41 -0800
> Subject: [sylpheed-jp:01401] Re: 外部エディタでヘッダも編集できるようにするパッチ
> Message-ID: <20020112203741.7dd6284e.naokih@xxxxxxxxxx>
> HIROSHIMA Naoki <naokih@xxxxxxxxxx> さん wrote:
> 
> > 廣島です。
> > 
> > On Sun, 13 Jan 2002 09:04:59 +0900
> > "Good**, Hironori(Shohta) NAGAKUBO" <shohta@xxxxxxxxxx> wrote:
> > 
> > > ところが、署名が挿入できなくなってしまいました。
> > 
> > あ、ほんとだ(笑)
> > というわけで直しました (^^;
> > (snip)
> 
> 早速のご教示、ありがとうございます。
> 添付の「headers.patch」を入れました所、今度は大丈夫、我が外部エディタ「XEmacs」画面で、「To:」「Cc:」「Subject:」のヘッダ部分が編集可能になり、キチンと署名も挿入できます。

その後、廣島さんの「headers.patch」を必要があって、XEmacsで読み込んだりしておりましたら、最終行の「}」位置のカーソルで、それと対応すべき括弧
の不在を示すのでしょうか、画面が数行(L174〜)赤で表示されます。
プログラム言語は全くの無知ですので、私の不必要な心配かもしれませんが、念のためお知らせしておきます。
――――――――――――――――――――――――――――――――
--- src.orig/compose.c	Fri Jan 11 16:47:49 2002
+++ src/compose.c	Sat Jan 12 20:20:09 2002
@@ -157,7 +157,8 @@
 						 MsgInfo	*msginfo);
 static void compose_insert_sig			(Compose	*compose);
 static void compose_insert_file			(Compose	*compose,
-						 const gchar	*file);
+						 const gchar	*file,
+						 gboolean	should_parse);
 static void compose_attach_append		(Compose	*compose,
 						 const gchar	*file,
 						 ContentType	 cnttype);
@@ -1115,16 +1116,17 @@
 				"\n", 1);
 	}
 
-	compose_insert_file(compose, sigfile);
+	compose_insert_file(compose, sigfile, FALSE);
 	g_free(sigfile);
 }
 
-static void compose_insert_file(Compose *compose, const gchar *file)
+static void compose_insert_file(Compose *compose, const gchar *file, gboolean should_parse)
 {
 	GtkSText *text = GTK_STEXT(compose->text);
-	gchar buf[BUFFSIZE];
+	gchar buf[BUFFSIZE], *str;
 	gint len;
 	FILE *fp;
+	gboolean is_header_line = should_parse;
 
 	g_return_if_fail(file != NULL);
 
@@ -1144,7 +1146,58 @@
 			while (--len >= 0)
 				if (buf[len] == '\r') buf[len] = '\n';
 		}
-		gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
+
+		if (!is_header_line) {
+			gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
+			continue;
+		}
+
+		if (!strncmp(buf, "----", 4)) {
+			is_header_line = FALSE;
+			continue;
+		}
+
+		len = strlen(buf) - 1;
+		buf[len] = '\0';
+
+		/* check headers */
+
+		if (!strncasecmp(buf, "Subject:", strlen("Subject:"))) {
+			Xstrdup_a(str, buf + strlen("Subject:"), return);
+			g_strstrip(str);
+			gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), str);
+
+		} else if (!strncasecmp(buf, "To:", strlen("To:"))) {
+			Xstrdup_a(str, buf + strlen("To:"), return);
+			g_strstrip(str);
+			gtk_entry_set_text(GTK_ENTRY(compose->to_entry), str);
+
+		} else if (!strncasecmp(buf, "Cc:", strlen("Cc:"))) {
+			Xstrdup_a(str, buf + strlen("Cc:"), return);
+			g_strstrip(str);
+			gtk_entry_set_text(GTK_ENTRY(compose->cc_entry), str);
+
+		} else if (!strncasecmp(buf, "Bcc:", strlen("Bcc:"))) {
+			Xstrdup_a(str, buf + strlen("Bcc:"), return);
+			g_strstrip(str);
+			gtk_entry_set_text(GTK_ENTRY(compose->bcc_entry), str);
+
+		} else if (!strncasecmp(buf, "Reply-To:", strlen("Reply-To"))) {
+			Xstrdup_a(str, buf + strlen("Reply-To:"), return);
+			g_strstrip(str);
+			gtk_entry_set_text(GTK_ENTRY(compose->reply_entry), str);
+
+		} else if (compose->account->protocol == A_NNTP) {
+			if (!strncasecmp(buf, "Newsgroups:", strlen("Newsgroups:"))) {
+				Xstrdup_a(str, buf + strlen("Newsgroups:"), return);
+				g_strstrip(str);
+				gtk_entry_set_text(GTK_ENTRY(compose->newsgroups_entry), str);
+			} else if (!strncasecmp(buf, "Followup-To: ", 13)) {
+				Xstrdup_a(str, buf + strlen("Followup-To:"), return);
+				g_strstrip(str);
+				gtk_entry_set_text(GTK_ENTRY(compose->followup_entry), str);
+			}
+		}
 	}
 
 	gtk_stext_thaw(text);
@@ -2018,6 +2071,62 @@
 		g_warning(_("can't change file mode\n"));
 	}
 
+	/* write headers */
+
+	/* To */
+	if (compose->use_to) {
+		fputs("To: ", fp);
+		chars = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
+		if (*chars != '\0') fputs(chars, fp);
+		fputs("\n", fp);
+	}
+
+	/* Newsgroups */
+	if (compose->account->protocol == A_NNTP) {
+		fputs("Newsgroups: ", fp);
+		chars = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
+		if (*chars != '\0') fputs(chars, fp);
+		fputs("\n", fp);
+	}
+
+	/* Cc */
+	if (compose->use_cc) {
+		fputs("Cc: ", fp);
+		chars = gtk_entry_get_text(GTK_ENTRY(compose->cc_entry));
+		if (*chars != '\0') fputs(chars, fp);
+		fputs("\n", fp);
+	}
+
+	/* Bcc */
+	if (compose->use_bcc) {
+		fputs("Bcc: ", fp);
+		chars = gtk_entry_get_text(GTK_ENTRY(compose->bcc_entry));
+		if (*chars != '\0') fputs(chars, fp);
+		fputs("\n", fp);
+	}
+
+	/* Reply-To */
+	if (compose->use_replyto) {
+		fputs("Reply-To: ", fp);
+		chars = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
+		if (*chars != '\0') fputs(chars, fp);
+		fputs("\n", fp);
+	}
+
+	/* Followup-To */
+	if (compose->use_followupto) {
+		fputs("Followup-To: ", fp);
+		chars = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
+		if (*chars != '\0') fputs(chars, fp);
+		fputs("\n", fp);
+	}
+
+	/* Subject */
+	fputs("Subject: ", fp);
+	chars = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+	if (*chars != '\0') fputs(chars, fp);
+	fputs("\n----\n", fp);
+
 	chars = gtk_editable_get_chars(GTK_EDITABLE(compose->text), 0, -1);
 
 	/* write body */
@@ -3848,7 +3957,7 @@
 		gtk_stext_freeze(text);
 		gtk_stext_set_point(text, 0);
 		gtk_stext_forward_delete(text, gtk_stext_get_length(text));
-		compose_insert_file(compose, compose->exteditor_file);
+		compose_insert_file(compose, compose->exteditor_file, TRUE);
 		compose_changed_cb(NULL, compose);
 		gtk_stext_thaw(text);
 
@@ -4267,7 +4376,7 @@
 	file = filesel_select_file(_("Select file"), NULL);
 
 	if (file)
-		compose_insert_file(compose, file);
+		compose_insert_file(compose, file, TRUE);
 }
 
 static gint compose_delete_cb(GtkWidget *widget, GdkEventAny *event,
@@ -4622,7 +4731,7 @@
 
 	list = uri_list_extract_filenames((const gchar *)data->data);
 	for (tmp = list; tmp != NULL; tmp = tmp->next)
-		compose_insert_file(compose, (const gchar *)tmp->data);
+		compose_insert_file(compose, (const gchar *)tmp->data, TRUE);
 	list_free_strings(list);
 	g_list_free(list);
 }
――――――――――――――――――――――――――――――――

よろしくご教示ください。

That's all for today. Bye for now.
---
                                     Mon Jan 14 14:00:37 2002 JST
_/_/ Mailing with Linux-Sylpheed _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

   長久保 博徳(鐘多) <shohta@xxxxxxxxxx> 


[前][次][番号順一覧][スレッド一覧]

   @  1397 2002-01-10 20:36 [naokih@xxxxxxxxxx   ] 外部エディタでヘッダも編集できるようにするパッチ
      1398 2002-01-11 01:21 ┗[norttrek@xxxxxxxxxx ]                                       
      1399 2002-01-13 09:04  ┣[shohta@xxxxxxxxxx   ]                                     
      1400 2002-01-13 09:14  ┃┣[shohta@xxxxxxxxxx   ]                                   
   @  1401 2002-01-13 13:37  ┃┗[naokih@xxxxxxxxxx   ]                                   
      1404 2002-01-13 18:21  ┃ ┗[shohta@xxxxxxxxxx   ]                                 
->    1410 2002-01-14 14:01  ┃  ┗[shohta@xxxxxxxxxx   ]                               
      1411 2002-01-15 23:14  ┃   ┗[tsk2@xxxxxxxxxx     ]                             
      1423 2002-01-17 22:33  ┃    ┗[shohta@xxxxxxxxxx   ]                           
   @  1402 2002-01-13 16:05  ┣[aleut@xxxxxxxxxx    ] Re: パッチを当てる方法              
      1405 2002-01-13 19:16  ┃┗[bruce@xxxxxxxxxx    ]                                   
      1403 2002-01-13 18:22  ┗[okushima@xxxxxxxxxx ]