OSDN Git Service

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