OSDN Git Service

HEAD.TXTが取得できない問題を解決
[gikonavigoeson/gikonavi.git] / Editor.pas
1 unit Editor;
2
3 interface
4
5 uses
6         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7         Dialogs, StdCtrls, ComCtrls, ExtCtrls, ToolWin, Menus, OleCtrls, Registry,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10 {$ELSE}
11         SHDocVw_TLB,
12 {$IFEND}
13         ActiveX, {HTTPApp,} YofUtils, Trip, IniFiles, StrUtils,
14         GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
15         IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
16         IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
17         IdLogBase, IdLogDebug, IdException, DateUtils, MojuUtils, bmRegExp;
18
19 type
20 //      TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
21         //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
22         TGikoResultType = (grtOK, grtCookie, grtCheck, grtError);
23
24         TEditorForm = class(TForm)
25                 MainMenu: TMainMenu;
26                 FileMenu: TMenuItem;
27                 PostMessage: TMenuItem;
28                 SaveMessage: TMenuItem;
29                 CloseMenu: TMenuItem;
30                 N01: TMenuItem;
31                 StatusBar: TStatusBar;
32                 EditorPage: TPageControl;
33                 EditorTab: TTabSheet;
34                 PreviewTab: TTabSheet;
35                 Browser: TWebBrowser;
36                 EditMenu: TMenuItem;
37                 UndoMenu: TMenuItem;
38                 CutMenu: TMenuItem;
39                 CopyMenu: TMenuItem;
40                 PasteMenu: TMenuItem;
41                 N02: TMenuItem;
42                 ToolBarImageList: TImageList;
43                 HotToobarImageList: TImageList;
44                 BodyEdit: TMemo;
45                 NameBasePanel: TPanel;
46                 NameLabel: TLabel;
47                 MailLabel: TLabel;
48                 NameComboBox: TComboBox;
49                 MailComboBox: TComboBox;
50                 ToolBar: TToolBar;
51                 SendToolButton: TToolButton;
52                 OutBoxToolButton: TToolButton;
53                 ToolButton5: TToolButton;
54                 UndoToolButton: TToolButton;
55                 CutToolButton: TToolButton;
56                 CopyToolButton: TToolButton;
57                 PasteToolButton: TToolButton;
58                 ToolButton3: TToolButton;
59                 TransToolButton: TToolButton;
60                 TopToolButton: TToolButton;
61                 Indy: TIdHTTP;
62                 IdAntiFreeze: TIdAntiFreeze;
63                 ToolButton1: TToolButton;
64                 ToolButton2: TToolButton;
65                 ActionList: TActionList;
66                 SendAction: TAction;
67                 SaveAction: TAction;
68                 CloseAction: TAction;
69                 UndoAction: TAction;
70                 CutAction: TAction;
71                 CopyAction: TAction;
72                 PasteAction: TAction;
73                 AbortAction: TAction;
74                 TopAction: TAction;
75                 Show1: TMenuItem;
76                 T1: TMenuItem;
77                 N1: TMenuItem;
78                 S1: TMenuItem;
79                 SageCheckBox: TCheckBox;
80                 IdLogDebug: TIdLogDebug;
81                 TransAction: TAction;
82                 A1: TMenuItem;
83                 KotehanCheckBox: TCheckBox;
84                 TitlePanel: TPanel;
85                 Label1: TLabel;
86                 TitleEdit: TEdit;
87                 SelectAllAction: TAction;
88                 N2: TMenuItem;
89                 SelectAll1: TMenuItem;
90     Timer1: TTimer;
91     QuotePasteAction: TAction;
92     QuotePasteMenuItem: TMenuItem;
93     C1: TMenuItem;
94     SpaceToNBSPAction: TAction;
95     AmpToCharRefAction: TAction;
96     SpaceTabnbsp1: TMenuItem;
97     amp1: TMenuItem;
98     SETTINGTab: TTabSheet; 
99                 Browser1: TWebBrowser;
100                 BoardtopTab: TTabSheet;
101                 Browser2: TWebBrowser;
102     HEADTab: TTabSheet;
103     Browser3: TWebBrowser;
104
105                 procedure EditorPageChange(Sender: TObject);
106                 procedure FormCreate(Sender: TObject);
107                 procedure BrowserStatusTextChange(Sender: TObject;
108                         const Text: WideString);
109                 procedure FormClose(Sender: TObject; var Action: TCloseAction);
110                 procedure FormDestroy(Sender: TObject);
111                 procedure SendActionExecute(Sender: TObject);
112                 procedure SaveActionExecute(Sender: TObject);
113                 procedure AbortActionExecute(Sender: TObject);
114                 procedure CloseActionExecute(Sender: TObject);
115                 procedure UndoActionExecute(Sender: TObject);
116                 procedure CutActionExecute(Sender: TObject);
117                 procedure CopyActionExecute(Sender: TObject);
118                 procedure PasteActionExecute(Sender: TObject);
119                 procedure SendActionUpdate(Sender: TObject);
120                 procedure SaveActionUpdate(Sender: TObject);
121                 procedure CloseActionUpdate(Sender: TObject);
122                 procedure UndoActionUpdate(Sender: TObject);
123                 procedure CutActionUpdate(Sender: TObject);
124                 procedure CopyActionUpdate(Sender: TObject);
125                 procedure PasteActionUpdate(Sender: TObject);
126                 procedure TopActionExecute(Sender: TObject);
127                 procedure TopActionUpdate(Sender: TObject);
128                 procedure SageCheckBoxClick(Sender: TObject);
129                 procedure MailComboBoxChange(Sender: TObject);
130                 procedure TransActionExecute(Sender: TObject);
131                 procedure TransActionUpdate(Sender: TObject);
132                 procedure IdLogDebugReceive(ASender: TIdConnectionIntercept;
133                         AStream: TStream);
134                 procedure IdLogDebugSend(ASender: TIdConnectionIntercept;
135                         AStream: TStream);
136                 procedure SelectAllActionExecute(Sender: TObject);
137     procedure StatusBarResize(Sender: TObject);
138     procedure Timer1Timer(Sender: TObject);
139     procedure FormActivate(Sender: TObject);
140     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
141                 procedure QuotePasteActionExecute(Sender: TObject);
142     procedure SpaceToNBSPActionExecute(Sender: TObject);
143     procedure AmpToCharRefActionExecute(Sender: TObject);
144         private
145                 FThreadItem: TThreadItem;
146                 FBoard: TBoard;
147                 FNameComboEdit: THandle;
148                 FMailComboEdit: THandle;
149                 FAbort: Boolean;
150                 FWork: Boolean;
151                 FStatusCode: Integer;
152                 FDebugStrReceive: string;
153                 FDebugStrSend: string;
154         FSambaTime: TDateTime;
155         FHost: string;
156                 FNow: TDateTime;
157                 procedure Preview;
158                 function RepHtml(s: string): string;
159                 function Check: Boolean;
160                 procedure SetNameList(sName, sMail: string);
161 //              procedure Send(SendType: TGikoSendType; SPID: string; PON: string; FirstWriting: Boolean);
162                 procedure Send(SPID: string; PON: string; FirstWriting: Boolean);
163
164                 function GetActiveControlHandle: THandle;
165 //              function GetSendData: string;
166 //              procedure GetSendData(Source: TStringStream);
167                 procedure GetSendData(Source: TStringStream);
168                 procedure SaveSendFile;
169                 procedure SetContent(Content: string);
170                 function GetSPID(CookieLine: string): string;
171                 function GetPON(CookieLine: string): string;
172                 function GetResultType(ResponseText: string): TGikoResultType;
173         procedure ReadSambaTime(const AHost: string);
174         procedure WriteSambaTime(const AHost: string; ATime: TDateTime);
175         function ReadSettingTime(const AHost: string): Integer;
176         function CheckSambaTime(const AHost: string; ATime: TDateTime): Boolean;
177                                 procedure SetSamba24(AURL: string);
178                 /// \88ø\97p\95\84\82Ì\8eæ\93¾
179                 function GetOEIndentChar : string;
180                 /// \96{\95\82Ì\8eæ\93¾
181                 function GetBody : string;
182         protected
183                 procedure CreateParams(var Params: TCreateParams); override;
184         public
185                 FBBSID: String;
186                 procedure SetFont;
187                 procedure SetThreadItem(Item: TThreadItem);
188                 procedure SetBoard(Item: TBoard);
189                 property BBSID: string read FBBSID write FBBSID;
190         end;
191
192 implementation
193
194 uses
195         Giko, ItemDownload;
196 const
197         CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
198         CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
199
200     // \83G\83f\83B\83b\83g\83E\83B\83\93\83h\83E\82ð\89E\89º\82É\82¸\82ç\82µ\82Ä\8aJ\82­\88Ú\93®\97Ê
201     WINDOWMOVE_H = 30;
202     WINDOWMOVE_V = 30;
203
204         //DAX\82³\82ñ±Ø¶ÞÄ!(\81L\81¤\81M)
205         READCGI_ERR                     = '-ERR';
206         READCGI_INCR            = '-INCR';
207         READCGI_OK                      = '+OK';
208         READCGI_PARTIAL = '+PARTIAL';
209         READCGI_ERR_FOUND_KAKO  = '-ERR \89ß\8b\8e\83\8d\83O\91q\8cÉ\82Å\94­\8c©';
210         READCGI_ERR_NOT_HTML            = '-ERR html\89»\91Ò\82¿';
211         READCGI_ERR_NOT_FOUND           = '-ERR \82»\82ñ\82È\94Âor\83X\83\8c\83b\83h\82È\82¢\82Å\82·\81B';
212         READCGI_ERR_ABONE                               = '-ERR \82Ç\82±\82©\82Å\82 \82Ú\81[\82ñ\82ª\82 \82Á\82½\82Ý\82½\82¢\82Å\82·\81B';
213         READCGI_ERR_TIMEOUT                     = '-ERR \8ew\92è\8e\9e\8aÔ\82ª\89ß\82¬\82Ü\82µ\82½\81B';
214         READCGI_ERR_CANTUSE                     = '-ERR \82à\82¤\81@\82Â\82©\82¦\82Ü\82¹\82ñ';
215         RES2CH_TRUE                             = '<!-- 2ch_X:true -->';
216         RES2CH_FALSE                    = '<!-- 2ch_X:false -->';
217         RES2CH_ERROR                    = '<!-- 2ch_X:error -->';
218         RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
219         RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
220
221
222         BBS2CH_NAME:                                     string = '\82Q\82¿\82á\82ñ\82Ë\82é';
223         BBS2CH_LOG_FOLDER:               string = '2ch';
224         EXTERNAL_LOG_FOLDER:            string  = 'exboard';
225
226         FOLDER_INI_FILENAME:     string = 'Folder.ini';
227         FOLDER_INDEX_FILENAME: string   = 'Folder.idx';
228         SUBJECT_FILENAME:                       string  = 'subject.txt';
229         PATH_DELIM:                                             string  = '\';
230
231
232 type
233         TSelection = record
234                 StartPos, EndPos: Integer;
235         end;
236
237 {$R *.DFM}
238
239 {constructor TEditorForm.Create(AOwner: TComponent; Item: TBoard);
240 begin
241         inherited Create(AOwner);
242 end;}
243
244 procedure TEditorForm.CreateParams(var Params: TCreateParams);
245 begin
246         inherited;
247         if FormStyle in [fsNormal, fsStayOnTop] then
248                 if BorderStyle in [bsSingle, bsSizeable] then begin
249                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
250                         Params.WndParent := 0;
251                 end;
252 end;
253
254 {procedure TEditorForm.CreateParams(var Params: TCreateParams);
255 begin
256         inherited CreateParams(Params);
257         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
258 end;}
259
260 procedure TEditorForm.FormCreate(Sender: TObject);
261 var
262         wp: TWindowPlacement;
263                 hUser32 : HINST;
264 begin
265         FWork := False;
266         Browser.Navigate('about:blank');
267
268         FBoard := nil;
269         FThreadItem := nil;
270
271         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
272         wp.length := sizeof(wp);
273         wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
274         wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
275
276         wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
277         wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
278         wp.showCmd := SW_HIDE;
279         SetWindowPlacement(Handle, @wp);
280
281         if GikoSys.Setting.EditWindowMax then
282                 WindowState := wsMaximized;
283
284         //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
285         if (Left + Width) > Screen.Width then
286 //              Left := Screen.Width - Width;
287                 Left := 0;
288         if (Top + Height) > Screen.Height then
289 //              Top := Screen.Height - Height;
290                 Top := 0;
291         if Left < 0 then
292                 Left := 0;
293         if Top < 0 then
294                 Top := 0;
295
296     //\8c»\8dÝ\82Ì\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82ð\95Û\91
297     GikoSys.Setting.EditWindowTop := Top  + WINDOWMOVE_V;   // \8e\9f\82É\8aJ\82­\83E\83B\83\93\83h\83E\82Í
298     GikoSys.Setting.EditWindowLeft := Left + WINDOWMOVE_H;  // \81@\81@\81@\89E\8eÎ\82ß\89º\82É\82¸\82ç\82·
299     //\83E\83B\83\93\83h\83E\82Ì\95\9d\82Æ\8d\82\82³\82ª\8f¬\82³\82·\82¬\82¢\82ê\82Î\8c³\82É\96ß\82·
300         if GikoSys.Setting.EditWindowHeight < 144 then
301                 Height := 400;
302         if GikoSys.Setting.EditWindowWidth < 144 then
303                 Width := 640;
304
305         EditorPage.ActivePage := EditorTab;
306         FNameComboEdit := GetWindow(NameComboBox.Handle, GW_CHILD);
307         FMailComboEdit := GetWindow(MailComboBox.Handle, GW_CHILD);
308         NameComboBox.Items.Assign(GikoSys.Setting.NameList);
309         MailComboBox.Items.Assign(GikoSys.Setting.MailList);
310         SetFont;
311         hUser32 := 0;
312         try
313                 try
314                         hUser32 := LoadLibrary('User32.dll');
315                         if hUser32 <> 0 then
316                                 TransAction.Enabled := true
317                         else
318                                 TransAction.Enabled := false;
319                 except
320                 TransAction.Enabled := false;
321                 end;
322         finally
323                 FreeLibrary(hUser32);
324         end;
325
326     // \83E\83B\83\93\83h\83E\82Ì\83X\83e\83C\8fó\91Ô
327         if GikoSys.Setting.EditWindowStay then begin    // \83X\83e\83C\8fó\91Ô
328                 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
329                 TopAction.Checked := true;
330                 TopToolButton.Down := true;
331         end else begin                                  // \83X\83e\83C\82µ\82È\82¢
332                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
333                 TopAction.Checked := false;
334                 TopToolButton.Down := false;
335         end;
336
337     // \83E\83B\83\93\83h\83E\82Ì\94¼\93§\96¾\8fó\91Ô
338         if(GikoSys.Setting.EditWindowTranslucent) and (TransAction.Enabled) then begin // \94¼\93§\96¾\81i\83g\83\89\83\93\83X\83\8b\81[\83Z\83\93\83g\81j\8fó\91Ô
339         AlphaBlend := true;
340         TransAction.Checked := true;
341         TransToolButton.Down := true;
342     end else begin                                      // \95s\93§\96¾
343         AlphaBlend := false;
344         TransAction.Checked := false;
345         TransToolButton.Down := false;
346     end;
347         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
348         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
349
350         SpaceToNBSPAction.Checked               := GikoSys.Setting.SpaceToNBSP;
351         AmpToCharRefAction.Checked      := GikoSys.Setting.AmpToCharRef;
352 end;
353
354 procedure TEditorForm.SetBoard(Item: TBoard);
355 begin
356         FBoard := Item;
357         Caption := CAPTION_NAME_NEW + ' - [' + Item.Title + ']';
358         NameComboBox.Text := FBoard.KotehanName;
359         MailComboBox.Text := FBoard.KotehanMail;
360         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
361         TitlePanel.Visible := True;
362     SetSamba24('');
363 end;
364
365 procedure TEditorForm.SetThreadItem(Item: TThreadItem);
366 begin
367         FThreadItem := Item;
368         Caption := CAPTION_NAME_RES + ' - [' + FThreadItem.Title + ']';
369         NameComboBox.Text := FThreadItem.ParentBoard.KotehanName;
370         MailComboBox.Text := FThreadItem.ParentBoard.KotehanMail;
371         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
372         TitlePanel.Visible := False;
373     SetSamba24(FThreadItem.ParentBoard.URL);
374 end;
375
376 function TEditorForm.GetBody : string;
377 var
378         body            : string;
379         regexp  : TAWKStr;
380 begin
381
382         body := BodyEdit.Text;
383         if AmpToCharRefAction.Checked then
384                 // & \82Ì\92u\8a·\82Í\88ê\94Ô\8dÅ\8f\89\82É\82â\82é\82±\82Æ
385                 body := CustomStringReplace( body, '&', '&amp;' );
386         if SpaceToNBSPAction.Checked then begin
387                 body := CustomStringReplace( body, #09, '&nbsp;&nbsp;&nbsp;&nbsp;' );
388                 body := CustomStringReplace( body, '  ', '&nbsp;&nbsp;' );
389                 body := CustomStringReplace( body, '&nbsp; ', '&nbsp;&nbsp;' );
390                 regexp := TAWKStr.Create( nil );
391                 try
392                         regexp.RegExp := '^ ';
393                         regexp.GSub( '\&nbsp;', body );
394                 finally
395                         regexp.Free;
396                 end;
397         end;
398
399         Result  := body;
400
401 end;
402
403 procedure TEditorForm.SetFont;
404 begin
405         BodyEdit.Font.Name := GikoSys.Setting.EditorFontName;
406         BodyEdit.Font.Size := GikoSys.Setting.EditorFontSize;
407         BodyEdit.Font.Color := GikoSys.Setting.EditorFontColor;
408         BodyEdit.Color := GikoSys.Setting.EditorBackColor;
409 end;
410
411 procedure TEditorForm.Preview;
412 var
413         Title: string;
414         No: string;
415         Mail: string;
416         Namae: string;
417         DateTime: string;
418         Body: string;
419         s: string;
420
421                                 posTrip : Integer;
422                                 tripOrigin : string;
423 begin
424         if FThreadItem = nil then begin
425                 No := '1';
426                 Title := RepHtml(TitleEdit.Text);
427         end else begin
428                 No := IntToStr(FThreadItem.Count + 1);
429                 Title := RepHtml(FThreadItem.Title);
430         end;
431
432         body := GetBody;
433
434         Namae := RepHtml(NameComboBox.Text);
435         Mail := RepHtml(MailComboBox.Text);
436         Body := RepHtml(body);
437         Body := StringReplace(Body, #13#10, '<br>', [rfReplaceAll]);
438         DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', now);
439
440         if Trim(Namae) = '' then
441                 Namae := '\96¼\96³\82µ\82³\82ñ';
442
443         s := '<HTML><HEAD>' + #13#10
444                         + '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">' + #13#10
445                         + '<TITLE>' + title + '</TITLE>' + #13#10
446 //                      + '<STYLE><!--BODY{font-size : 9pt;font-family : "\82l\82\82o\83S\83V\83b\83N";}--></STYLE>' + #13#10
447                         + '</HEAD>' + #13#10
448                         + '<BODY text="#000000" bgcolor="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">' + #13#10
449                         + '<FONT COLOR="#FF0000">' + title + '</FONT>' + #13#10
450                         + '<DL>' + #13#10;
451                                 posTrip := AnsiPos( '#', Namae );
452                                 if posTrip > 0 then
453                                 begin
454                                                                 tripOrigin := Copy( Namae, posTrip + 1, Length( Namae ) );
455                                                                 Namae :=
456                                                                                                 Copy( Namae, 1, posTrip - 1 ) + '</B> \81\9f' +
457                                                                                                 get_2ch_trip( PChar( tripOrigin ) ) + '<B>';
458                                 end;
459         if Mail = '' then
460                 s := s + '<DT>' + No + ' \81F <FONT color="forestgreen"><B>' + Namae + '</B></FONT> \81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10
461         else
462                 s := s + '<DT>' + No + ' \81F <A href="mailto:' + Mail + '"><B>' + Namae + '</B></A> [' + Mail + ']\81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10;
463         s := s + '</BODY></HTML>';
464         SetContent(s);
465 end;
466
467 function TEditorForm.RepHtml(s: string): string;
468 begin
469 //      s := StringReplace(s, '&', '&amp;', [rfReplaceAll]);
470         s := StringReplace(s, '<', '&lt;', [rfReplaceAll]);
471         s := StringReplace(s, '>', '&gt;', [rfReplaceAll]);
472 //      s := StringReplace(s, ' ', '&nbsp;', [rfReplaceAll]);   //\8ed\97l\95Ï\8dX\82É\82æ\82è&nbsp;\8eg\97p\95s\89Â
473         s := StringReplace(s, '"', '&quot;', [rfReplaceAll]);
474         Result := s;
475 end;
476
477 procedure TEditorForm.EditorPageChange(Sender: TObject);
478 var
479         URL, RefURL, RefeURL, HeadURL: String;
480         setting,head: TMemoryStream;
481 begin
482         if EditorPage.ActivePage = PreviewTab then begin
483                 Preview;
484         end else begin
485                 Browser.Navigate('about:blank');
486         end;
487
488         if FThreadItem = nil then begin
489                 URL := FBoard.GetSendURL;
490                 RefURL := GikoSys.UrlToServer(FBoard.URL)
491                         + GikoSys.UrlToID(FBoard.URL)
492                         + '/';
493                 RefeURL := RefURL + 'SETTING.TXT';
494                 HeadURL := RefURL + 'head.txt';
495         end else begin
496                 URL := FThreadItem.GetSendURL;
497                 RefURL := GikoSys.UrlToServer(FThreadItem.ParentBoard.URL)
498                         + FThreadItem.ParentBoard.BBSID
499                         + '/';
500                 RefeURL := RefURL + 'SETTING.TXT';
501                 HeadURL := RefURL + 'head.txt';
502         end;
503
504         if EditorPage.ActivePage = SETTINGTab then begin
505                 Browser1.Navigate(RefeURL);
506         end else begin
507                 Browser1.Navigate('about:blank');
508         end;
509
510         if EditorPage.ActivePage = BoardtopTab then begin
511                 Browser2.Navigate(RefURL);
512         end else begin
513                 Browser2.Navigate('about:blank');
514         end;
515
516         if EditorPage.ActivePage = HEADTab then begin
517                 Browser3.Navigate(HeadURL);
518         end else begin
519                 Browser3.Navigate('about:blank');
520         end;
521 end;
522
523 procedure TEditorForm.BrowserStatusTextChange(Sender: TObject;
524         const Text: WideString);
525 begin
526         if EditorPage.ActivePage = PreviewTab then begin
527                 StatusBar.Panels[0].Text := Text;
528         end else begin
529                 StatusBar.Panels[0].Text := '';
530         end;
531 end;
532
533 function TEditorForm.Check: Boolean;
534 var
535         Msg: string;
536         rc: Integer;
537         Board: TBoard;
538 begin
539         Result := True;
540         if FThreadItem = nil then
541                 Board := FBoard
542         else
543                 Board := FThreadItem.ParentBoard;
544
545         if (not GikoSys.Setting.UseMachineTime) and
546                  ((Board.LastGetTime = 0) or
547                         (Board.LastGetTime = ZERO_DATE)) then begin
548                 Msg := '\83T\81[\83o\82Ì\8e\9e\8d\8f\82ª\95ª\82©\82ç\82È\82¢\82½\82ß\81A\91\97\90M\8fo\97\88\82Ü\82¹\82ñ'#13#10
549                                  + '\83X\83\8c\83b\83h\82ð\8dX\90V\81i\8eæ\93¾\81j\8cã\81A15\95b\91Ò\82Á\82Ä\82©\82ç\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢';
550                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
551                 Result := False;
552         end else if BodyEdit.Text = '' then begin
553                 Msg := '\96{\95\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
554                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
555                 Result := False;
556         end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
557                 Msg := '\83^\83C\83g\83\8b\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
558                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
559                 Result := False;
560         end else begin
561                 if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
562                         Msg := '\83\8d\83O\83C\83\93\82µ\82Ä\82¢\82È\82¢\82Ì\82Å\81\9c\82Ì\8b@\94\\82Í\97\98\97p\8fo\97\88\82Ü\82¹\82ñ\81B'#13#10
563                                          + '\82±\82Ì\82Ü\82Ü\91\97\90M\82µ\82Ä\82à\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
564                         rc := MsgBox(Handle, Msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION);
565                         Result := (rc = IDYES);
566                 end;
567         end;
568 end;
569
570 procedure TEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
571 begin
572         Action := caFree;
573 end;
574
575 procedure TEditorForm.FormDestroy(Sender: TObject);
576 var
577         wp: TWindowPlacement;
578 begin
579         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
580         wp.length := sizeof(wp);
581         GetWindowPlacement(Handle, @wp);
582
583         GikoSys.Setting.EditWindowTop := wp.rcNormalPosition.Top;
584         GikoSys.Setting.EditWindowLeft := wp.rcNormalPosition.Left;
585         GikoSys.Setting.EditWindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
586         GikoSys.Setting.EditWindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
587         GikoSys.Setting.EditWindowMax := WindowState = wsMaximized;
588         //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;      // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
589         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;   // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
590
591 end;
592
593 procedure TEditorForm.SetNameList(sName, sMail: string);
594 begin
595         if Trim(sName) <> '' then begin
596                 if GikoSys.Setting.NameList.IndexOf(sName) = -1 then
597                         GikoSys.Setting.NameList.Insert(0, sName);
598         end;
599         if Trim(sMail) <> '' then begin
600                 if GikoSys.Setting.MailList.IndexOf(sMail) = -1 then
601                         GikoSys.Setting.MailList.Insert(0, sMail);
602         end;
603 end;
604
605 function TEditorForm.GetActiveControlHandle: THandle;
606 begin
607         if EditorPage.ActivePage = EditorTab then begin
608                 if ActiveControl = NameComboBox then
609                         Result := FNameComboEdit
610                 else if ActiveControl = MailComboBox then
611                         Result := FMailComboEdit
612                 else if ActiveControl = BodyEdit then
613                         Result := BodyEdit.Handle
614                 else if ActiveControl = TitleEdit then
615                         Result := TitleEdit.Handle
616                 else
617                         Result := 0;
618         end else
619                 Result := 0;
620 end;
621
622 procedure TEditorForm.SetContent(Content: string);
623 var
624         doc : Variant;
625 begin
626         if Browser.Document <> nil then begin
627                 doc := Browser.Document;
628                 doc.Clear;
629                 doc.open;
630                 doc.charset := 'Shift_JIS';
631                 doc.Write(Content);
632                 doc.Close;
633         end;
634 end;
635
636 procedure TEditorForm.Send(SPID: string; PON: string; FirstWriting: Boolean);
637 var
638         TextStream: TStringStream;
639         Source: TStringStream;
640         ResponseText: string;
641         URL: string;
642         RefURL: string;
643         State: TGikoDownloadState;
644         ResultType: TGikoResultType;
645         MsgResult: Integer;
646         Cookie: string;
647         Board: TBoard;
648         sysMenu : HMENU;
649         //fusianasan\83g\83\89\83b\83v by\92è\8aú\95Ö
650         Namae: String;
651         SettingTxt: String;
652         RefeURL: string;
653 //        RuleURL: String;
654 //        RuleTxt: String;
655 begin
656         FAbort := False;
657         State := gdsError;
658         Namae := RepHtml(NameComboBox.Text);
659         if FThreadItem = nil then
660                 Board := FBoard
661         else
662                 Board := FThreadItem.ParentBoard;
663
664         Indy.Request.Clear;
665         Indy.ProxyParams.BasicAuthentication := False;
666         if GikoSys.Setting.WriteProxy then begin
667                 Indy.ProxyParams.ProxyServer := GikoSys.Setting.WriteProxyAddress;
668                 Indy.ProxyParams.ProxyPort := GikoSys.Setting.WriteProxyPort;
669                 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.WriteProxyUserID;
670                 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.WriteProxyPassword;
671                 if GikoSys.Setting.ReadProxyUserID <> '' then
672                         Indy.ProxyParams.BasicAuthentication := True;
673         end else begin
674                 Indy.ProxyParams.ProxyServer := '';
675                 Indy.ProxyParams.ProxyPort := 80;
676                 Indy.ProxyParams.ProxyUsername := '';
677                 Indy.ProxyParams.ProxyPassword := '';
678         end;
679         if FThreadItem = nil then begin
680                 URL := FBoard.GetSendURL;
681                 RefURL := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
682         end else begin
683                 URL := FThreadItem.GetSendURL;
684                 RefURL := FThreadItem.URL;
685         end;
686         Indy.Request.UserAgent := GikoSys.GetUserAgent;
687         Indy.Request.Referer := RefURL;
688         Indy.Request.AcceptEncoding := '';
689
690         Cookie := '';
691         if SPID <> '' then
692                 Cookie := Cookie + 'SPID=' + SPID + '; ';
693         if PON <> '' then
694                 Cookie := Cookie + 'PON=' + PON + '; ';
695         Cookie := 'Cookie: ' + Cookie + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
696
697         sysMenu := GetSystemMenu( Handle, false );
698         EnableMenuItem( sysMenu, SC_CLOSE, MF_GRAYED );
699 {
700   EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
701   DrawMenuBar(Handle);
702 }
703         Indy.Request.CustomHeaders.Clear;
704 //      Indy.Request.CacheControl := 'no-cache';
705         Indy.Request.CustomHeaders.Add('Pragma: no-cache');
706         Indy.Request.AcceptLanguage := 'ja';
707         Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
708         Indy.Request.ContentType := 'application/x-www-form-urlencoded';
709         Indy.Request.CustomHeaders.Add(Cookie);
710         TextStream := TStringStream.Create('');
711         Source := TStringStream.Create('');
712         try
713                 try
714                         FDebugStrReceive := '';
715                         FDebugStrSend := '';
716                         GetSendData(Source);
717                         Indy.Post(URL, Source, TextStream);
718                         ResponseText := TextStream.DataString;
719
720                         ResultType := GetResultType(ResponseText);
721
722                         //MsgResult\8f\89\8aú\89»
723                         MsgResult := IDNO;
724                         //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
725                         if ((Namae = '\8eR\8dè\8fÂ') or (Namae = 'fusianasan')) and (FirstWriting) then begin
726                                 MsgResult := MsgBox(
727                                                 Handle,
728                                         '\83\8a\83\82\81[\83g\83z\83X\83g\82ð\95\\8e¦\82·\82é\8b@\94\\82ª\8eg\82í\82ê\82Ä\82¢\82Ü\82·' + #13#10 +
729                                         '\82à\82µ\82à\8aÔ\88á\82Á\82Ä\82±\82Ì\95û\96@\82Å\83z\83X\83g\82ª\95\\8e¦\82³\82ê\82½\82Æ\82µ\82Ä\82à\81A\8e©\8cÈ\90Ó\94C\82È\82Ì\82Å\8dí\8f\9c\88Ë\97\8a\82É\82Í\89\9e\82\82Ü\82¹\82ñ\81B' + #13#10#13#10 +
730                                         '\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
731                                         '\8fî\95ñ',
732                                         MB_YESNO or MB_ICONQUESTION);
733                                 if MsgResult = IDNO  then begin
734                                         Board.SPID := '';
735                                         Board.PON := '';
736                                         FWork := false;
737                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
738                                         DrawMenuBar(Handle);
739                                         Exit;
740                                 end;
741                         end;
742                         if ResultType = grtOK then begin
743                                 WriteSambaTime(FHost, Now());
744                                 State := gdsComplete;
745                         end else if ResultType = grtCookie then begin
746                                 //\83\8b\81[\83v\96h\8e~
747                                 if not FirstWriting then
748                                         raise Exception.Create('');
749                                 MsgResult := MsgBox(
750                                         Handle,
751                                         '\81E\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81A\95Û\91\81A\88ø\97p\81A\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
752                                         '\81E\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10#13#10 +
753                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
754                                         '\8fî\95ñ',
755                                         MB_YESNO or MB_ICONQUESTION);
756                                 if MsgResult = IDYES then begin
757                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
758                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
759                                         if (Board.SPID = '') and (Board.PON = '') then
760                                                 raise Exception.Create('');
761                                         //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
762                                         Send(Board.SPID, Board.PON, False);
763                                         Exit;
764                                 end else begin
765                                         Board.SPID := '';
766                                         Board.PON := '';
767                                         FWork := false;
768                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
769                                         DrawMenuBar(Handle);
770                                         Exit;
771                                 end;
772                         end else if ResultType = grtCheck then begin
773                                 //
774                                 //\83\8b\81[\83v\96h\8e~
775                                 if not FirstWriting then
776                                         raise Exception.Create('');
777
778                                 MsgResult := MsgBox(
779                                         Handle,
780                                         '\8f\91\82«\8d\9e\82Ý\82É\8aÖ\82µ\82Ä\82Í\97l\81X\82È\83\8d\83O\8fî\95ñ\82ª\8bL\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B' + #13#10 +
781                                         '\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10 +
782                                         '\8cö\8f\98\97Ç\91­\82É\94½\82µ\82½\82è\81A\91¼\90l\82É\96À\98f\82ð\82©\82¯\82é\8f\91\82«\8d\9e\82Ý\82Í\8dT\82¦\82Ä\89º\82³\82¢\81B' + #13#10 +
783                                         '\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81E\95Û\91\81E\88ø\97p\81E\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
784                                         #13#10 +
785                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
786                                         '\8am\94F',
787                                         MB_YESNO or MB_ICONQUESTION);
788
789                                 if MsgResult = IDYES then begin
790                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
791                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
792                                         if (Board.SPID = '') and (Board.PON = '') then
793                                                 raise Exception.Create('');
794                                         Send(Board.SPID, Board.PON, False);
795                                         Exit;
796                                 end else begin
797                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
798                                         DrawMenuBar(Handle);
799                                         Board.SPID := '';
800                                         Board.PON := '';
801                                         FWork := false;
802                                         Exit;
803                                         end;
804                         end else begin
805                 WriteSambaTime(FHost, Now());
806                                 State := gdsError;
807                                 raise Exception.Create('');
808                         end;
809
810                 except
811                         on E: EIdConnectException do begin
812                                 State := gdsError;
813                                 ResponseText := '<html><body>'
814                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
815                                                                                         + '\89ñ\90ü\82â\83v\83\8d\83L\83V\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
816                                                                                         + '<br><br><div>' + E.Message + '</div>'
817                                                                                         + '</body></html>';
818                         end;
819                         on E: Exception do begin
820                                 State := gdsError;
821
822                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
823                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
824                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
825                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
826
827                                 ResponseText := '<html><body>' + TextStream.DataString;
828                                 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
829                                 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
830                                 ResponseText := ResponseText + '<hr><div align="left"><pre>';
831                                 ResponseText := ResponseText + '<b>\82±\82±\82©\82ç\83M\83R\83i\83r\82Ì\8fî\95ñ</b>'#13#10;
832                                 ResponseText := ResponseText + #13#10'\81\9c\91\97\90M'#13#10;
833                                 ResponseText := ResponseText + FDebugStrSend;
834                                 ResponseText := ResponseText + #13#10'\81\9c\8eó\90M'#13#10;
835                                 ResponseText := ResponseText + FDebugStrReceive;
836                                 ResponseText := ResponseText + '</pre></div></body></html>';
837                         end;
838                 end;
839                 FStatusCode := Indy.ResponseCode;
840                 if FAbort then
841                         State := gdsAbort;
842         finally
843                 Source.Free;
844                 TextStream.Free;
845                 //sysMenu := GetSystemMenu( Handle, true );
846                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
847                 DrawMenuBar(Handle);
848         end;
849         FWork := false;
850         //\94ñ\8cö\8e®\83M\83R\83i\83r\94Â\82È\82Ç\82Ì\83X\83N\83\8a\83v\83g\97p
851         //ResponceCode\82ª302Found\82Å\8f\91\82«\8d\9e\82Ý\8a®\97¹
852         if FStatusCode = 302 then begin
853                 GikoForm.PlaySound('ResEnd');
854                 SaveSendFile;
855                 if FThreadItem = nil then
856                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
857                 else
858                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
859                 Close;
860                 Exit;
861         end;
862         if State = gdsComplete then begin
863                 GikoForm.PlaySound('ResEnd');
864                 SaveSendFile;
865                 if FThreadItem = nil then
866                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
867                 else
868                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
869                 Close;
870         end else if State = gdsError then begin
871                 if FThreadItem = nil then
872                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG)
873                 else
874                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
875                 EditorPage.ActivePage := PreviewTab;
876                 SetContent(ResponseText);
877         end else if State = gdsAbort then begin
878                 GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
879         end;
880 end;
881
882 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
883 begin
884         if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
885                 Result := grtOK
886         else if (AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
887                                         (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
888                                         (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0)        or
889                                         //(AnsiPos('\83N\83b\83L\81[\8am\94F', ResponseText) > 0) or
890                                         (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)      then
891                 Result := grtCookie
892         else if (AnsiPos('<font size=+2 color=#FF0000>\8f\91\82«\8d\9e\82Ý\83`\83F\83b\83N\81I </font>', ResponseText) > 0)   or
893                                         (AnsiPos('<title>\81¡ \8f\91\82«\8d\9e\82Ý\8am\94F\82µ\82Ü\82· \81¡</title>', ResponseText) > 0)  or
894                                         (AnsiPos('<title>\93\8a\8de\8am\94F</title>', ResponseText) > 0)  or
895                                         (AnsiPos('<b>\8f\91\82«\82±\82Ý\8am\94F</b>', ResponseText) > 0)      or
896                                         (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0)   or
897                                         (AnsiPos(RES2CH_FALSE, ResponseText) > 0)       then
898                 Result := grtCheck
899         else
900                 Result := grtError;
901 end;
902
903
904 procedure TEditorForm.GetSendData(Source: TStringStream);
905 var
906         SessionID: string;
907         s: string;
908         SendTime: Integer;
909         Adjust: Integer;
910         Board: TBoard;
911         body            : string;
912 begin
913         if FThreadItem = nil then
914                 Board := FBoard
915         else
916                 Board := FThreadItem.ParentBoard;
917
918         if GikoSys.Setting.UseMachineTime then begin
919                 if GikoSys.Setting.TimeAdjust then
920                         Adjust := Gikosys.Setting.TimeAdjustSec
921                 else
922                         Adjust := GikoSys.Setting.TimeAdjustSec * -1;
923                 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
924         end else begin
925                 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
926                         SendTime := GikoSys.DateTimeToInt(Now)
927                 else
928                         SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
929         end;
930
931         body := GetBody;
932
933         SessionID := GikoSys.Dolib.SessionID;
934         if SessionID <> '' then
935                 s := 'sid=' + HttpEncode(SessionID) + '&'
936         else
937                 s := '';
938         s := s + 'subject=&'
939                                  + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
940                                  + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
941                                  + 'MESSAGE=' + HttpEncode(body) + '&'
942                                  + 'bbs=' + Board.BBSID + '&'
943                                  + 'time=' + IntToStr(SendTime) + '&';
944         if FThreadItem = nil then begin
945                 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
946                 s := s + 'submit=' + HttpEncode('\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Þ') + #13#10;
947         end else begin
948                 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
949                 s := s + 'submit=' + HttpEncode('\8f\91\82«\8d\9e\82Þ') + #13#10;
950         end;
951         Source.WriteString(s);
952 end;
953
954 procedure TEditorForm.SaveSendFile;
955 var
956         sDate: string;
957         ini: TMemIniFile;
958 begin
959         ini := TMemIniFile.Create(GikoSys.GetSentFileName);
960         try
961                 sDate := IntToStr(GikoSys.DateTimeToInt(Now));
962
963                 ini.WriteString(sDate, 'Name', NameComboBox.Text);
964                 ini.WriteString(sDate, 'EMail', MailComboBox.Text);
965                 ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
966                 ini.WriteInteger(sDate, 'Status', FStatusCode);
967                 ini.WriteDateTime(sDate, 'Date', Now);
968                 if FThreadItem = nil then begin
969                         ini.WriteString(sDate, 'Title', TitleEdit.Text);
970                         ini.WriteString(sDate, 'BBS', FBoard.BBSID);
971                         ini.WriteInteger(sDate, 'NewThread', 1);
972                 end else begin
973                         ini.WriteString(sDate, 'Title', FThreadItem.Title);
974                         ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
975                         ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
976                 end;
977
978                 ini.UpdateFile;
979         finally
980                 ini.Free;
981         end;
982 end;
983
984 procedure TEditorForm.SendActionExecute(Sender: TObject);
985 var
986         Board: TBoard;
987         rc: Integer;
988         state : TGikoDownloadState;
989         body            : string;
990 begin
991         if FWork then
992                 Exit;
993         try
994                 FWork := True;
995                 SendAction.Enabled := False;
996                 Application.ProcessMessages;
997                 if not Check then Exit;
998
999                 if FThreadItem = nil then
1000                         Board := FBoard
1001                 else
1002                         Board := FThreadItem.ParentBoard;
1003
1004                 if FThreadItem = nil then begin
1005                         rc := GikoUtil.MsgBox(Handle,
1006                                                                                                         '\81u' + Board.Title + '\81v\94Â\82É\90V\82µ\82¢\83X\83\8c\83b\83h\97§\82Ä\82Ü\82·'#13#10#13#10
1007                                                                                                         + '\81E\94Â\82Ì\83\8b\81[\83\8b\82ð\8eç\82Á\82½\8f\91\82«\8d\9e\82Ý\82Å\82 \82é\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10
1008                                                                                                         + '\81E\91¼\82É\93¯\82\82æ\82¤\82È\83X\83\8c\83b\83h\82ª\96³\82©\82Á\82½\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10#13#10
1009                                                                                                         + '\81u\82Í\82¢\81v\82ð\89\9f\82·\82Æ\91\97\90M\82µ\82Ü\82·',
1010                                                                                                         '\8am\94F',
1011                                                                                                         MB_ICONQUESTION or MB_YESNO);
1012                         if rc <> ID_YES then
1013                                 Exit;
1014                 end;
1015
1016                 SetNameList(NameComboBox.Text, MailComboBox.Text);
1017                 if KotehanCheckBox.Checked then begin
1018                         Board.KotehanName := NameComboBox.Text;
1019                         Board.KotehanMail := MailComboBox.Text;
1020                 end;
1021
1022                 if Board.IsBoardPlugInAvailable then begin
1023                         body := GetBody;
1024
1025                         if FThreadItem = nil then begin
1026                                 // \83X\83\8c\97§\82Ä
1027                                 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
1028                                         DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
1029
1030                                 if state = gdsComplete then begin
1031                                         GikoForm.PlaySound('ResEnd');
1032                                         SaveSendFile;
1033                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK);
1034                                         FWork := False;
1035                                         Close;
1036                                 end else if State = gdsError then begin
1037                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG);
1038                                 end else if State = gdsAbort then begin
1039                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
1040                                 end;
1041                         end else begin
1042                                 // \83\8c\83X
1043                                 state := TGikoDownloadState( FThreadItem.BoardPlugIn.WriteThread(
1044                                         DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
1045
1046                                 if state = gdsComplete then begin
1047                                         GikoForm.PlaySound('ResEnd');
1048                                         SaveSendFile;
1049                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
1050                     FWork := False;
1051                                         Close;
1052                                 end else if State = gdsError then begin
1053                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
1054                                 end else if State = gdsAbort then begin
1055                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
1056                                 end;
1057                         end;
1058                 end else begin
1059                         if not Timer1.Enabled then
1060                                 Send(Board.SPID, Board.PON, True)
1061                         else begin
1062                                 if not CheckSambaTime(FHost, Now()) then begin
1063                                         rc := GikoUtil.MsgBox(Handle,
1064                                                                 'Samba24\82Ì\8bK\92è\92l\96¢\96\9e\82Ì\95b\90\94\82µ\82©\8co\89ß\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B'#13#10
1065                                                                 + '\91\97\90M\82ð\92\86\8e~\82µ\82Ü\82·\82©\81H' + #13#10
1066                                                                 + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', 'Samba24\8cx\8d\90',
1067                                                                 MB_YESNO or MB_ICONQUESTION);
1068                                         if rc = IDYES then begin
1069                                                 FWork := false;
1070                                                 Exit;
1071                                         end;
1072                                 end;
1073                                 Send(Board.SPID, Board.PON, True);
1074                         end;
1075                 end;
1076         finally
1077                 FWork := False;
1078                 if Timer1.Enabled then
1079                         ReadSambaTime(FHost);
1080         end;
1081 end;
1082
1083 procedure TEditorForm.SaveActionExecute(Sender: TObject);
1084 begin
1085 //
1086 end;
1087
1088 procedure TEditorForm.CloseActionExecute(Sender: TObject);
1089 begin
1090         Close;
1091 end;
1092
1093 procedure TEditorForm.UndoActionExecute(Sender: TObject);
1094 begin
1095         SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
1096 end;
1097
1098 procedure TEditorForm.CutActionExecute(Sender: TObject);
1099 begin
1100         SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
1101 end;
1102
1103 procedure TEditorForm.CopyActionExecute(Sender: TObject);
1104 begin
1105         SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
1106 end;
1107
1108 procedure TEditorForm.PasteActionExecute(Sender: TObject);
1109 begin
1110         SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
1111 end;
1112
1113 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
1114 begin
1115         SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
1116 end;
1117
1118 procedure TEditorForm.TopActionExecute(Sender: TObject);     // \83E\83B\83\93\83h\83E\8dÅ\91O\96Ê(Stay)\83{\83^\83\93\82Ì\8f\88\97\9d
1119 begin
1120         if not (fsShowing in Self.FormState) then begin
1121                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
1122                         SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1123                         GikoSys.Setting.EditWindowStay := true;
1124                 end     else begin   // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
1125                         SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1126                         GikoSys.Setting.EditWindowStay := false;
1127                 end;
1128                 // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
1129                 //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;
1130         end;
1131 end;
1132
1133 procedure TEditorForm.AbortActionExecute(Sender: TObject);
1134 begin
1135         FAbort := True;
1136 end;
1137
1138 procedure TEditorForm.SendActionUpdate(Sender: TObject);
1139 begin
1140         SendAction.Enabled := not FWork;
1141 end;
1142
1143 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
1144 begin
1145         SaveAction.Enabled := False;
1146 end;
1147
1148 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
1149 begin
1150         CloseAction.Enabled := not FWork;
1151 end;
1152
1153 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
1154 begin
1155         UndoAction.Enabled := (GetActiveControlHandle <> 0)
1156                                                                                                 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
1157                                                                                                 and (not FWork);
1158 end;
1159
1160 procedure TEditorForm.CutActionUpdate(Sender: TObject);
1161 var
1162         Selection: TSelection;
1163         AHandle: THandle;
1164 begin
1165         AHandle := GetActiveControlHandle;
1166         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1167         CutAction.Enabled := (AHandle <> 0)
1168                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1169                                                                                 and (not FWork);
1170 end;
1171
1172 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
1173 var
1174         Selection: TSelection;
1175         AHandle: THandle;
1176 begin
1177         AHandle := GetActiveControlHandle;
1178         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1179         CopyAction.Enabled := (AHandle <> 0)
1180                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1181                                                                                 and (not FWork);
1182 end;
1183
1184 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
1185 begin
1186         PasteAction.Enabled := (GetActiveControlHandle <> 0)
1187                                                                                         and (Clipboard.HasFormat(CF_TEXT))
1188                                                                                         and (not FWork);
1189 end;
1190
1191 procedure TEditorForm.TopActionUpdate(Sender: TObject);
1192 begin
1193         TopAction.Enabled := not FWork;
1194 end;
1195
1196 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
1197 begin
1198         if SageCheckBox.Checked then begin
1199                 if AnsiPos('sage', MailComboBox.Text) = 0 then
1200                         MailComboBox.Text := 'sage' + MailComboBox.Text;
1201         end else begin
1202                 if AnsiPos('sage', MailComboBox.Text) <> 0 then
1203                         MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
1204         end;
1205 end;
1206
1207 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
1208 begin
1209         if AnsiPos('sage', MailComboBox.Text) = 0 then
1210                 SageCheckBox.Checked := False
1211         else
1212                 SageCheckBox.Checked := True;
1213 end;
1214
1215
1216 function TEditorForm.GetSPID(CookieLine: string): string;
1217 var
1218         s: string;
1219         i: Integer;
1220 begin
1221         Result := '';
1222         i := 0;
1223         while True do begin
1224                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1225                 if s = '' then
1226                         Break
1227                 else begin
1228                         if Pos('SPID=', s) = 1 then begin
1229                                 Result := Trim(Copy(s, 6, Length(s)));
1230                                 Break;
1231                         end;
1232                 end;
1233                 inc(i);
1234         end;
1235 end;
1236
1237 function TEditorForm.GetPON(CookieLine: string): string;
1238 var
1239         s: string;
1240         i: Integer;
1241 begin
1242         Result := '';
1243         i := 0;
1244         while True do begin
1245                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1246                 if s = '' then
1247                         Break
1248                 else begin
1249                         if Pos('PON=', s) = 1 then begin
1250                                 Result := Trim(Copy(s, 5, Length(s)));
1251                                 Break;
1252                         end;
1253                 end;
1254                 inc(i);
1255         end;
1256 end;
1257
1258 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1259         AStream: TStream);
1260 var
1261         StringStream: TStringStream;
1262 begin
1263         StringStream := TStringStream.Create('');
1264         try
1265                 StringStream.CopyFrom(AStream, AStream.Size);
1266                 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1267         finally
1268                 StringStream.Free;
1269         end;
1270 end;
1271
1272 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1273         AStream: TStream);
1274 var
1275         StringStream: TStringStream;
1276 begin
1277         StringStream := TStringStream.Create('');
1278         try
1279                 StringStream.CopyFrom(AStream, AStream.Size);
1280                 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1281         finally
1282                 StringStream.Free;
1283         end;
1284 end;
1285
1286 procedure TEditorForm.TransActionExecute(Sender: TObject);
1287 begin
1288         AlphaBlend := TransAction.Checked;
1289         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
1290         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
1291 end;
1292
1293 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1294 begin
1295         TransAction.Enabled := not FWork;
1296 end;
1297 //StatusBar\82ÌPanels[0]\82Ì\95\9d\82ð\89Â\95Ï\81B\8ec\82è\82ð\8cÅ\92è\82É\82·\82é
1298 procedure TEditorForm.StatusBarResize(Sender: TObject);
1299 begin
1300         StatusBar.Panels[0].Width := StatusBar.Width
1301                                                                         - StatusBar.Panels[1].Width - StatusBar.Panels[2].Width;
1302
1303 end;
1304
1305 procedure TEditorForm.Timer1Timer(Sender: TObject);
1306 begin
1307         if FSambaTime = ZERO_DATE then
1308                 StatusBar.Panels[1].Text := '\8f\89\8f\91'
1309         else begin
1310                 FNow := IncMilliSecond(FNow, 500);
1311                 StatusBar.Panels[1].Text := Format('%8.0f\95b\8co\89ß', [SecondSpan(FNow, FSambaTime)]);
1312         end;
1313
1314 end;
1315 //Samba.ini\82Ì\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1316 procedure TEditorForm.ReadSambaTime(const AHost: string);
1317 var
1318         ini :TMemIniFile;
1319         tmp: string;
1320 begin
1321         Timer1.Enabled := false; //\8co\89ß\95b\90\94\95\\8e¦Timer\82ðOff\82É\82·\82é\81i\82±\82ê\82ªON\82Ì\82Æ\82«Samba24\91Î\8dôOn\81j
1322         FNow := Now();   //\8c»\8dÝ\8e\9e\8aÔ\82ð\8eæ\93¾\81iTimer\95\\8e¦\97p\82Å\81ACheck\82·\82é\82Æ\82«\82Í\8dÄ\82ÑNow()\82ð\8cÄ\82Ô\81j
1323         Timer1.Enabled := true; //\8co\89ß\95b\90\94\95\\8e¦Timer\82ðOn\82É\82·\82é\81i\82±\82ê\82ªON\82Ì\82Æ\82«Samba24\91Î\8dôOn\81j
1324         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1325         try
1326                  //\95\8e\9a\97ñ\82Å\93Ç\82Ý\8eæ\82Á\82Ä\81A\95Ï\8a·\8aÖ\90\94\82ÅTDateTime\82Ö
1327                  tmp := ini.ReadString('Send', AHost, DateTimeToStr(ZERO_DATE));
1328                  FSambaTime := ConvertDateTimeString(tmp);
1329         finally
1330                 ini.Free;
1331         end;
1332 end;
1333 //Samba.ini\82É\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\8f\91\82«\8d\9e\82Þ
1334 procedure TEditorForm.WriteSambaTime(const AHost: string; ATime: TDateTime);
1335 var
1336         ini :TMemIniFile;
1337 begin
1338         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1339         try
1340                 ini.WriteDateTime('Send', AHost, ATime);
1341                 ini.UpdateFile;
1342         finally
1343                 ini.Free;
1344         end;
1345 end;
1346 //\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82Æ\8c»\8dÝ\8e\9e\82ð\94ä\8ar\82·\82é\81i\90^\81F\8bK\92è\92l\88È\8fã\81@\8bU\81F\8bK\92è\92l\96¢\96\9e\81j
1347 function TEditorForm.CheckSambaTime(const AHost: string; ATime: TDateTime): Boolean;
1348 var
1349         pastsec: double;
1350         SettingTime: Integer;
1351 begin
1352         SettingTime := ReadSettingTime(AHost);
1353         ReadSambaTime(AHost);
1354         pastsec := SecondSpan(ATime, FSambaTime);
1355         if pastsec > SettingTime then
1356                 Result := true
1357         else
1358                 Result := false;
1359 end;
1360 //AHost\81i\8eI\96¼\81j\82ÌSamba\82Ì\8bK\92è\92l\82ð\93Ç\82Ý\8d\9e\82Þ
1361 function TEditorForm.ReadSettingTime(const AHost: string): Integer;
1362 var
1363         ini :TMemIniFile;
1364 begin
1365         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1366         try
1367                 Result := ini.ReadInteger('Setting', AHost, 0);
1368                 //\8bK\92è\92l\82ª\82O\82Ì\82Æ\82«\81A\82à\82µ\82­\82Í\90Ý\92è\82³\82ê\82Ä\82¢\82È\82¢\82Æ\82«\82Í\81A\83t\83@\83C\83\8b\82É\8f\91\82«\82½\82·\81B
1369                 if Result = 0 then begin
1370                         ini.WriteInteger('Setting', AHost, 0);
1371                         ini.UpdateFile;
1372                 end;
1373         finally
1374                 ini.Free;
1375         end;
1376 end;
1377 //Form\82ªActive\82É\82È\82Á\82½\82ç\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1378 procedure TEditorForm.FormActivate(Sender: TObject);
1379 begin
1380         if ( Timer1.Enabled ) and ( FThreadItem <> nil )then
1381                 ReadSambaTime(FHost);
1382 end;
1383 //Samba24\91Î\8dô\82ð\8eg\82¤\82©\82Ç\82¤\82©\8c\88\82ß\82é\8aÖ\90\94
1384 //ReadSambaTime \82ð\8cÄ\82Ñ\8fo\82·\82ÆTimer\82ªOn\82É\82È\82é
1385 procedure TEditorForm.SetSamba24(AURL: string);
1386 var
1387         Protocol, Host, Path, Document, Port, Bookmark : string;
1388 begin
1389         //Samba24\91Î\8dô\82ð\82µ\82È\82¢\82È\82ç\8fI\97¹
1390         if not GikoSys.Setting.UseSamba then
1391                 Exit;
1392         //Host\82ÌURL\82É'.2ch.'\82©'.bbspink.'\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82½\82çSamba24\91Î\8dô\82ð\82·\82é
1393         GikoSys.ParseURI( AURL, Protocol,Host, Path, Document, Port, Bookmark );
1394         if GikoSys.Is2chHost(Host) then begin
1395                 Host := Copy(Host, 1, AnsiPos('.', Host) - 1);
1396                 FHost := Host;   //FHost=\8eI\96¼
1397                 ReadSambaTime(FHost); //\88È\91O\82Ì\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1398                 //StatusBar\82É\82±\82Ì\8eI\82Ì\8bK\92è\92l\82ð\95\\8e¦\82·\82é
1399                 StatusBar.Panels[2].Text := 'Samba24\8bK\92è\92l' + IntToStr(ReadSettingTime(FHost));
1400         end;
1401 end;
1402 procedure TEditorForm.FormCloseQuery(Sender: TObject;
1403   var CanClose: Boolean);
1404 begin
1405         CanClose := not FWork;
1406 end;
1407
1408 function TEditorForm.GetOEIndentChar : string;
1409 var
1410         regKey                  : TRegistry;
1411         Identities      : string;
1412         IndentChar      : DWORD;
1413 const
1414         DEFAULT_CHAR    = '> ';
1415         OE_MAIL_PATH    = '\Software\Microsoft\Outlook Express\5.0\Mail';
1416         INDENT_CHAR             = 'Indent Char';
1417 begin
1418
1419         Result  := DEFAULT_CHAR;
1420         regKey  := TRegistry.Create;
1421         try
1422                 try
1423                         regKey.RootKey  := HKEY_CURRENT_USER;
1424                         if not regKey.OpenKey( 'Identities', False ) then
1425                                 Exit;
1426                         Identities                      := regKey.ReadString( 'Default User ID' );
1427                         if Identities = '' then
1428                                 Exit;
1429                         if not regKey.OpenKey( Identities + OE_MAIL_PATH, False ) then
1430                                 Exit;
1431                         IndentChar := regKey.ReadInteger( INDENT_CHAR );
1432                         Result := Char( IndentChar ) + ' ';
1433                 except
1434                 end;
1435         finally
1436                 regKey.Free;
1437         end;
1438
1439 end;
1440
1441 procedure TEditorForm.QuotePasteActionExecute(Sender: TObject);
1442 var
1443         s                       : TStringList;
1444         i                       : Integer;
1445         quote   : string;
1446 begin
1447
1448         quote   := GetOEIndentChar;
1449         s                       := TStringList.Create;
1450         try
1451                 s.Text  := Clipboard.AsText;
1452
1453                 for i := s.Count - 1 downto 0 do
1454                         s[ i ]  := quote + s[ i ];
1455
1456                 BodyEdit.SelText        := s.Text;
1457         finally
1458                 s.Free;
1459         end;
1460
1461 end;
1462
1463 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
1464 begin
1465         GikoSys.Setting.SpaceToNBSP := SpaceToNBSPAction.Checked;
1466         if EditorPage.ActivePage = PreviewTab then
1467                 Preview;
1468 end;
1469
1470 procedure TEditorForm.AmpToCharRefActionExecute(Sender: TObject);
1471 begin
1472         GikoSys.Setting.AmpToCharRef := AmpToCharRefAction.Checked;
1473         if EditorPage.ActivePage = PreviewTab then
1474                 Preview;
1475 end;
1476
1477 end.
1478