OSDN Git Service

ビルド環境構築手順をもうちょっと修正
[winbottle/winbottle.git] / bottleclient / BottleDef.pas
1 unit BottleDef;
2
3 (*
4   \83A\83v\83\8a\83P\81[\83V\83\87\83\93\91S\91Ì\82Å\8eg\82¤\82³\82Ü\82´\82Ü\82È\83f\81[\83^\82ð\92è\8b`
5 *)
6
7 interface
8
9 uses Windows, IniFiles, BRegExp, Graphics, SysUtils, Forms, Dialogs, Classes,
10   ComCtrls, Contnrs, SsPlayTime, StrReplace;
11
12 type
13   TReturnKeyFunction = (kfYenN, kfReturn, kfYenNReturn, kfConstText);
14   TSoundArrived = (saFalse, saTrue, saParent);
15   TLogWindowPreviewStyle = (psConversation, psImageConversation,
16     psScript, psScriptWithLineBreak);
17   TLogListPreviewStyle = (psNoColor, psNormal, psTagStripped);
18   TSurfacePreviewOnScriptPointPosition = (spspMainWindowLeft, spspMainWindowRight);
19
20   //SSTP Bottle\82Ì\90Ý\92è
21   TBottlePrefs = class(TObject)
22   private
23     FIni: TIniFile;
24     //
25     FIgnoreTimeCritical: boolean;
26     FStayOnTop: boolean;
27     FShowConstBar: boolean;
28     FNoConfirm: boolean;
29     FDblClkInsert: boolean;
30     FShowToolBar: boolean;
31     FDefaultScript: TStringList;
32     FTalkColorH: TColor;
33     FMetaWordColor: TColor;
34     FTalkColorU: TColor;
35     FMarkErrorColor: TColor;
36     FMarkUpColor: TColor;
37     FAutoStart: boolean;
38     FCgiName: string;
39     FHomePage: string;
40     FWhenCtrlReturn: TReturnKeyFunction;
41     FWhenShiftReturn: TReturnKeyFunction;
42     FWhenReturn: TReturnKeyFunction;
43     FNoTranslate: boolean;
44     FNoDescript: boolean;
45     FBgColor: TColor;
46     FTextColor: TColor;
47     FServerPort: integer;
48     FSilentWhenHidden: boolean;
49     FLUID: String;
50     FSenderWindowPosition: TRect;
51     FTabPosition: TTabPosition;
52     FLogWindowPosition: TRect;
53     FNoTransUrl: boolean;
54     FIgnoreFrequentYenS: boolean;
55     FWaitScriptEnd: integer;
56     FMinScriptLength: integer;
57     FCgiNameGhost: String;
58     FGLogPage: String;
59     FVotePage: String;
60     FLogWindowDividerPos: integer;
61     FHelpPage: String;
62     FUseHttpProxy: boolean;
63     FAskUseHttpProxy: boolean;
64     FProxyPort: integer;
65     FProxyAddress: String;
66     FProxyNeedAuthentication: boolean;
67     FProxyUser: String;
68     FProxyPass: String;
69     FConfirmOnExit: boolean;
70     FFixMessySurface: boolean;
71     FResetIfGhostAfterSend: boolean;
72     FGhostDropDownCount: integer;
73     FLogWindowPreviewStyle: TLogWindowPreviewStyle;
74     FCgiFetchLog: String;
75     FTalkColorS: TColor;
76     FLogWindowColumnWidth: String;
77     FClearAfterSend: boolean;
78     FAutoJoinChannels: TStrings;
79     FFMOName: TStrings;
80     FHUTagTo01Tag: boolean;
81     FWarnYenTNotExist: boolean;
82     FWarnScopeChangeInSynchronize: boolean;
83     FNeedConfirmBeforeSend: boolean;
84     FShowRuler: boolean;
85     FHideGhosts: boolean;
86     FVisibleGhostsList: TStringList;
87     FSurfacePreviewOnHint: boolean;
88     FSurfacePreviewOnScriptPoint: boolean;
89     FSurfacePreviewOnScriptPointPosition: TSurfacePreviewOnScriptPointPosition;
90     FNoExtraSSTPHeaders: boolean;
91     FLogListPreviewStyle: TLogListPreviewStyle;
92     FEditorPreviewWindowPosition: TRect;
93     FAutoClip: boolean;
94     FConfirmOnTabClose: boolean;
95     FReconnectWait: integer;
96     FPartialConfirmFormat: String;
97     FAutoPartialConfirm: boolean;
98     FPlayTimeParams: TSsPlayTimeParams;
99     FBottleServerPort: integer;
100     FBottleServer: String;
101     FTabWidth: integer;
102     FBrowserExeName: string;
103     FReplacePresets: TReplacePresets;
104     FNoWarnOfEmptyFMO: Boolean;
105     FShowEditorPreviewWindow: Boolean;
106     FLogItemDragDrop: Boolean;
107
108     procedure SetDblClkInsert(const Value: boolean);
109     procedure SetDefaultScript(const Value: String);
110     procedure SetIgnoreTimeCritical(const Value: boolean);
111     procedure SetMarkErrorColor(const Value: TColor);
112     procedure SetMarkUpColor(const Value: TColor);
113     procedure SetMetaWordColor(const Value: TColor);
114     procedure SetTextColor(const Value: TColor);
115     procedure SetNoConfirm(const Value: boolean);
116     procedure SetShowConstBar(const Value: boolean);
117     procedure SetShowToolBar(const Value: boolean);
118     procedure SetStayOnTop(const Value: boolean);
119     procedure SetTalkColorH(const Value: TColor);
120     procedure SetTalkColorU(const Value: TColor);
121     procedure SetAutoStart(const Value: boolean);
122     procedure SetWhenCtrlReturn(const Value: TReturnKeyFunction);
123     procedure SetWhenReturn(const Value: TReturnKeyFunction);
124     procedure SetWhenShiftReturn(const Value: TReturnKeyFunction);
125     procedure SetNoTranslate(const Value: boolean);
126     procedure SetNoDescript(const Value: boolean);
127     procedure SetBgColor(const Value: TColor);
128     procedure SetServerPort(const Value: integer);
129     procedure SetSilentWhenHidden(const Value: boolean);
130     procedure SetLUID(const Value: String);
131     procedure SetSenderWindowPosition(const Value: TRect);
132     procedure SetTabPosition(const Value: TTabPosition);
133     procedure SetLogWindowPosition(const Value: TRect);
134     procedure SetIgnoreFrequentYenS(const Value: boolean);
135     procedure SetNoTransUrl(const Value: boolean);
136     procedure SetWaitScriptEnd(const Value: integer);
137     procedure SetMinScriptLength(const Value: integer);
138     procedure SetLogWindowDividerPos(const Value: integer);
139     procedure SetProxyAddress(const Value: String);
140     procedure SetProxyPort(const Value: integer);
141     procedure SetProxyUser(const Value: String);
142     procedure SetProxyPass(const Value: String);
143     procedure SetProxyNeedAuthentication(const Value: boolean);
144     procedure SetUseHttpProxy(const Value: boolean);
145     procedure SetAskUseHttpProxy(const Value: boolean);
146     procedure SetConfirmOnExit(const Value: boolean);
147     procedure SetFixMessySurface(const Value: boolean);
148     procedure SetResetIfGhostAfterSend(const Value: boolean);
149     procedure SetGhostDropDownCount(const Value: integer);
150     procedure SetLogWindowPreviewStyle(const Value: TLogWindowPreviewStyle);
151     procedure SetTalkColorS(const Value: TColor);
152     procedure SetLogWindowColumnWidth(const Value: String);
153     procedure SetClearAfterSend(const Value: boolean);
154     procedure SetAutoJoinChannels(const Value: TStrings);
155     procedure SetFMOName(const Value: TStrings);
156     function GetDefaultScript: String;
157     procedure SetHUTagTo01Tag(const Value: boolean);
158     procedure SetWarnScopeChangeInSynchronize(const Value: boolean);
159     procedure SetWarnYenTNotExist(const Value: boolean);
160     procedure SetNeedConfirmBeforeSend(const Value: boolean);
161     procedure SetShowRuler(const Value: boolean);
162     procedure SetHideGhosts(const Value: boolean);
163     procedure SetVisibleGhostsList(const Value: TStringList);
164     procedure SetSurfacePreviewOnHint(const Value: boolean);
165     procedure SetSurfacePreviewOnScriptPoint(const Value: boolean);
166     procedure SetSurfacePreviewOnScriptPointPosition(
167       const Value: TSurfacePreviewOnScriptPointPosition);
168     procedure SetNoExtraSSTPHeaders(const Value: boolean);
169     procedure SetLogListPreviewStyle(const Value: TLogListPreviewStyle);
170     procedure SetEditorPreviewWindowPosition(const Value: TRect);
171     procedure SetAutoClip(const Value: boolean);
172     procedure SetConfirmOnTabClose(const Value: boolean);
173     procedure SetReconnectWait(const Value: integer);
174     procedure SetPartialConfirmFormat(const Value: String);
175     procedure SetAutoPartialConfirm(const Value: boolean);
176     procedure SetPlayTimeParams(const Value: TSsPlayTimeParams);
177     procedure SetTabWidth(const Value: integer);
178     procedure SetBrowserExeName(const Value: string);
179   protected
180     function InScreen(ARect: TRect): boolean;
181   public
182     property BottleServer: String read FBottleServer;
183     property BottleServerPort: integer read FBottleServerPort;
184     property PartialConfirmFormat: String read FPartialConfirmFormat write SetPartialConfirmFormat;
185     property AutoPartialConfirm: boolean read FAutoPartialConfirm write SetAutoPartialConfirm;
186     property ConfirmOnExit: boolean read FConfirmOnExit write SetConfirmOnExit;
187     property ConfirmOnTabClose: boolean read FConfirmOnTabClose write SetConfirmOnTabClose;
188     property AutoClip: boolean read FAutoClip write SetAutoClip;
189     property AutoStart: boolean read FAutoStart write SetAutoStart;
190     property TabPosition: TTabPosition read FTabPosition write SetTabPosition;
191     property TabWidth: integer read FTabWidth write SetTabWidth;
192     property GhostDropDownCount: integer read FGhostDropDownCount write SetGhostDropDownCount;
193     property NoTranslate: boolean read FNoTranslate write SetNoTranslate;
194     property NoDescript: boolean read FNoDescript write SetNoDescript;
195     property NoTransUrl: boolean read FNoTransUrl write SetNoTransUrl;
196     property SilentWhenHidden: boolean read FSilentWhenHidden write SetSilentWhenHidden;
197     property FixMessySurface: boolean read FFixMessySurface write SetFixMessySurface;
198     property HUTagTo01Tag: boolean read FHUTagTo01Tag write SetHUTagTo01Tag;
199     property ResetIfGhostAfterSend: boolean read FResetIfGhostAfterSend write SetResetIfGhostAfterSend;
200     property ClearAfterSend: boolean read FClearAfterSend write SetClearAfterSend;
201     property NeedConfirmBeforeSend: boolean read FNeedConfirmBeforeSend write SetNeedConfirmBeforeSend;
202     property IgnoreFrequentYenS: boolean read FIgnoreFrequentYenS write SetIgnoreFrequentYenS;
203     property WarnYenTNotExist: boolean read FWarnYenTNotExist write SetWarnYenTNotExist;
204     property WarnScopeChangeInSynchronize: boolean read FWarnScopeChangeInSynchronize write SetWarnScopeChangeInSynchronize;
205     property WaitScriptEnd: integer read FWaitScriptEnd write SetWaitScriptEnd;
206     property MinScriptLength: integer read FMinScriptLength write SetMinScriptLength;
207     property StayOnTop: boolean read FStayOnTop write SetStayOnTop;
208     property IgnoreTimeCritical: boolean read FIgnoreTimeCritical write SetIgnoreTimeCritical;
209     property TalkColorH: TColor read FTalkColorH write SetTalkColorH;
210     property TalkColorU: TColor read FTalkColorU write SetTalkColorU;
211     property TalkColorS: TColor read FTalkColorS write SetTalkColorS;
212     property MarkUpColor: TColor read FMarkUpColor write SetMarkUpColor;
213     property MetaWordColor: TColor read FMetaWordColor write SetMetaWordColor;
214     property MarkErrorColor: TColor read FMarkErrorColor write SetMarkErrorColor;
215     property BgColor: TColor read FBgColor write SetBgColor;
216     property TextColor: TColor read FTextColor write SetTextColor;
217     property DefaultScript: String read GetDefaultScript write SetDefaultScript;
218     property ShowRuler: boolean read FShowRuler write SetShowRuler;
219     property DblClkInsert: boolean read FDblClkInsert write SetDblClkInsert;
220     property ShowToolBar: boolean read FShowToolBar write SetShowToolBar;
221     property ShowConstBar: boolean read FShowConstBar write SetShowConstBar;
222     property NoConfirm: boolean read FNoConfirm write SetNoConfirm;
223     property HomePage: string read FHomePage;
224     property WhenReturn: TReturnKeyFunction read FWhenReturn write SetWhenReturn;
225     property WhenShiftReturn: TReturnKeyFunction read FWhenShiftReturn write SetWhenShiftReturn;
226     property WhenCtrlReturn: TReturnKeyFunction read FWhenCtrlReturn write SetWhenCtrlReturn;
227     property ServerPort: integer read FServerPort write SetServerPort;
228     //URL\8aÖ\8cW
229     property CgiName: string read FCgiName;
230     property CgiNameGhost: String read FCgiNameGhost;
231     property CgiFetchLog: String read FCgiFetchLog;
232     property GLogPage: String read FGLogPage;
233     property VotePage: String read FVotePage;
234     property HelpPage: String read FHelpPage;
235
236     //\83`\83\83\83\93\83l\83\8b\8aÖ\8cW
237     property AutoJoinChannels: TStrings read FAutoJoinChannels write SetAutoJoinChannels;
238
239     property LUID: String read FLUID write SetLUID;
240
241     //\83E\83B\83\93\83h\83E\88Ê\92u
242     property SenderWindowPosition: TRect
243       read FSenderWindowPosition write SetSenderWindowPosition;
244     property LogWindowPosition: TRect read FLogWindowPosition write SetLogWindowPosition;
245     property LogWindowDividerPos: integer
246       read FLogWindowDividerPos write SetLogWindowDividerPos;
247     property LogWindowColumnWidth: String
248       read FLogWindowColumnWidth write SetLogWindowColumnWidth;
249     property EditorPreviewWindowPosition: TRect read FEditorPreviewWindowPosition write SetEditorPreviewWindowPosition;
250     //\83v\83\8d\83L\83V\8aÖ\8cW
251     property UseHttpProxy: boolean read FUseHttpProxy write SetUseHttpProxy;
252     property AskUseHttpProxy: boolean read FAskUseHttpProxy write SetAskUseHttpProxy;
253     property ProxyAddress: String read FProxyAddress write SetProxyAddress;
254     property ProxyPort: integer read FProxyPort write SetProxyPort;
255     property ProxyUser: String read FProxyUser write SetProxyUser;
256     property ProxyPass: String read FProxyPass write SetProxyPass;
257     property ProxyNeedAuthentication: boolean read FProxyNeedAuthentication write SetProxyNeedAuthentication;
258     //\8dÄ\90Ú\91±
259     property ReconnectWait: integer read FReconnectWait write SetReconnectWait;
260     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
261     property LogWindowPreviewStyle: TLogWindowPreviewStyle
262       read FLogWindowPreviewStyle write SetLogWindowPreviewStyle;
263     property LogListPreviewStyle: TLogListPreviewStyle
264       read FLogListPreviewStyle write SetLogListPreviewStyle;
265     //\8fÚ\8d×\90Ý\92è
266     property FMOName: TStrings read FFMOName write SetFMOName;
267     property HideGhosts: boolean read FHideGhosts write SetHideGhosts;
268     property VisibleGhostsList: TStringList read FVisibleGhostsList write SetVisibleGhostsList;
269     property NoExtraSSTPHeaders: boolean read FNoExtraSSTPHeaders write SetNoExtraSSTPHeaders;
270     //\83T\81[\83t\83B\83X\83v\83\8c\83r\83\85\81[
271     property SurfacePreviewOnHint: boolean
272       read FSurfacePreviewOnHint write SetSurfacePreviewOnHint;
273     property SurfacePreviewOnScriptPoint: boolean
274       read FSurfacePreviewOnScriptPoint write SetSurfacePreviewOnScriptPoint;
275     property SurfacePreviewOnScriptPointPosition: TSurfacePreviewOnScriptPointPosition
276       read FSurfacePreviewOnScriptPointPosition write SetSurfacePreviewOnScriptPointPosition;
277     //\8dÄ\90\8e\9e\8aÔ\97\\91ª
278     property PlayTimeParams: TSsPlayTimeParams read FPlayTimeParams write SetPlayTimeParams;
279     //URL\83I\81[\83v\83\93\8e\9e\82É\8eg\82¤\83u\83\89\83E\83U\82Ì\8eÀ\8ds\83t\83@\83C\83\8b\96¼
280     property BrowserExeName: string read FBrowserExeName write SetBrowserExeName;
281     //\8e©\93®\92u\8a·\83v\83\8a\83Z\83b\83g
282     property ReplacePresets: TReplacePresets read FReplacePresets;
283     //SSTP\83T\81[\83o\94ñ\91\8dÝ\8cx\8d\90\82Ì\83J\83b\83g\82ð\82·\82é\82©
284     property NoWarnOfEmptyFMO: Boolean
285       read FNoWarnOfEmptyFMO write FNoWarnOfEmptyFMO;
286     //\83G\83f\83B\83^\83v\83\8c\83r\83\85\81[\83E\83C\83\93\83h\83E\82Ì\8fó\91Ô\95Û\91\97p
287     property ShowEditorPreviewWindow: Boolean
288       read FShowEditorPreviewWindow write FShowEditorPreviewWindow;
289     //\83\8d\83O\83h\83\89\83b\83O\81\95\83h\83\8d\83b\83v\97L\8cø
290     property LogItemDragDrop: Boolean
291       read FLogItemDragDrop write FLogItemDragDrop;
292
293     //\83R\83\93\83X\83g\83\89\83N\83^\81E\83f\83X\83g\83\89\83N\83^\81E\95Û\91
294     constructor Create;
295     destructor Destroy; override;
296     procedure SaveSettings;
297   end;
298
299   TChannelListItem = class(TObject)
300   private
301     FMembers: integer;
302     FGhost: String;
303     FInfo: String;
304     FName: String;
305     FNoPost: boolean;
306     FWarnPost: boolean;
307     procedure SetGhost(const Value: String);
308     procedure SetInfo(const Value: String);
309     procedure SetMembers(const Value: integer);
310     procedure SetName(const Value: String);
311     procedure SetNoPost(const Value: boolean);
312     procedure SetWarnPost(const Value: boolean);
313   public
314     property Name: String read FName write SetName;
315     property Info: String read FInfo write SetInfo;
316     property Ghost: String read FGhost write SetGhost;
317     property Members: integer read FMembers write SetMembers;
318     property NoPost: boolean read FNoPost write SetNoPost;
319     property WarnPost: boolean read FWarnPost write SetWarnPost;
320   end;
321
322   TChannelList = class(TList)
323   private
324     function GetChannel(Name: String): TChannelListItem;
325     function GetChannelItem(Index: integer): TChannelListItem;
326   public
327     procedure Clear; override;
328     property Channel[Name: String]: TChannelListItem read GetChannel;
329     property ChannelItem[Index: integer]: TChannelListItem read GetChannelItem;
330   end;
331
332   TScriptTransOption = (
333     toIgnoreTimeCritical,
334     toConvertURL,
335     toNoChoice,
336     toIgnoreFrequentYenS,
337     toWaitScriptEnd,
338     toFixMessySurface,
339     toWarnMessySurface,
340     toHUTagTo01Tag,
341     toWarnCheck
342   );
343
344   TScriptTransOptions = set of TScriptTransOption;
345
346 var
347   Pref: TBottlePrefs;
348   ChannelList: TChannelList; //\83`\83\83\83\93\83l\83\8b\83\8a\83X\83g\82ð\95Û\8e\9d\82·\82é
349   JoinChannels: TStringList; // \8c»\8dÝ\8eQ\89Á\82µ\82Ä\82¢\82é\83`\83\83\83\93\83l\83\8b
350
351 const
352   DefaultBottleServer    = 'bottle.mikage.to';
353   DefaultBottleServerPort = 9871;
354   DefaultCGI      = '/bottle2.cgi';
355   DefaultCGIGhost = '/glog/bottleglog.cgi';
356   DefaultCGIFetchLog = '/fetchlog.cgi';
357
358
359   DefaultHomePage = 'http://bottle.mikage.to/';
360   DefaultGLogPage = 'http://bottle.mikage.to/glog/glogview.cgi';
361   DefaultVotePage = 'http://bottle.mikage.to/viewvotes.cgi';
362   DefaultHelpPage = 'http://bottle.mikage.to/clihelp/index.html';
363
364   DefaultMinScriptLength = 20;
365
366   Version = '2.75';
367
368   {$IFDEF NOMUTEX}
369   VersionString = 'SSTP Bottle Client ver ' + Version + 'a NO MUTEX VERSION';
370   {$ELSE}
371   VersionString = 'SSTP Bottle Client ver ' + Version;
372   {$ENDIF}
373
374   SentLogFile     = 'sent.log';
375
376   BottleDisclaimer = '(C)2001-2006 WinBottle Project'#13#10 +
377     'naru, C.Ponapalt, Yune Kotomi, yese, Mikage Sawatari, E01'#13#10 +
378     DefaultHomePage;
379
380   ChannelDefault = '(CH\90\84\8f§)';
381   ClipChannel    = '(\83N\83\8a\83b\83v)'; 
382
383 function ParamsEncode(const ASrc: string): string;
384 function XMLEntity(From: String): String;
385 function SafeFileName(From: String; ChangePathDelimiters: boolean = true): String;
386 function ComponentToString(Component: TComponent): string;
387 function StringToComponent(Value: string): TComponent;
388
389 function ReplacePresetFileName: string;
390
391 procedure BuildShortCutList(Target: TStrings);
392
393 implementation
394
395 function ParamsEncode(const ASrc: string): string;
396 var
397   i: Integer;
398 const
399   UnsafeChars = ['*', '#', '%', '<', '>', ' ', '[', ']', '+'];
400 begin
401   Result := '';    {Do not Localize}
402   for i := 1 to Length(ASrc) do
403   begin
404     if (ASrc[i] in UnsafeChars) or (not (ord(ASrc[i])in [33..128])) then
405     begin {do not localize}
406       Result := Result + '%' + IntToHex(Ord(ASrc[i]), 2);  {do not localize}
407     end
408     else
409     begin
410       Result := Result + ASrc[i];
411     end;
412   end;
413 end;
414
415 // XML\8eÀ\91Ì\8eQ\8fÆ\82É\92u\82«\8a·\82¦\82é
416 function XMLEntity(From: String): String;
417 var
418   i: integer;
419   InLead: boolean;
420 begin
421   InLead := false;
422   Result := '';
423   for i := 1 to Length(From) do
424   begin
425     if InLead then
426     begin
427       InLead := false;
428       Result := Result + From[i];
429     end else if From[i] in LeadBytes then
430     begin
431       InLead := true;
432       Result := Result + From[i];
433     end else
434     begin
435       case Ord(From[i]) of
436         60: Result := Result + '&lt;'; // Less than
437         62: Result := Result + '&gt;'; // Greater than
438         38: Result := Result + '&amp;'; // Ampersand
439         39: Result := Result + '&#39;'; // Single quote
440         34: Result := Result + '&quot;'; // Double quote
441         else
442           Result := Result + From[i];
443       end;
444     end;
445   end;
446 end;
447
448 // Escape characters which can not be used as a filename
449 function SafeFileName(From: String; ChangePathDelimiters: boolean = true): String;
450 begin
451   Result := StringReplace(From, '*', '\81\96', [rfReplaceAll]);
452   Result := StringReplace(Result, '|', '\81b', [rfReplaceAll]);
453   Result := StringReplace(Result, '"', '''''', [rfReplaceAll]);
454   Result := StringReplace(Result, '<', '\81\83', [rfReplaceAll]);
455   Result := StringReplace(Result, '>', '\81\84', [rfReplaceAll]);
456   Result := StringReplace(Result, '?', '\81H', [rfReplaceAll]);
457   if ChangePathDelimiters then
458   begin
459     Result := StringReplace(Result, '\', '\81\8f', [rfReplaceAll]);
460     Result := StringReplace(Result, ':', '\81F', [rfReplaceAll]);
461     Result := StringReplace(Result, '/', '\81^', [rfReplaceAll]);
462   end;
463 end;
464
465 function ComponentToString(Component: TComponent): string;
466 var
467   BinStream:TMemoryStream;
468   StrStream: TStringStream;
469   s: string;
470 begin
471   BinStream := TMemoryStream.Create;
472   try
473     StrStream := TStringStream.Create(s);
474     try
475       BinStream.WriteComponent(Component);
476       BinStream.Seek(0, soFromBeginning);
477       ObjectBinaryToText(BinStream, StrStream);
478       StrStream.Seek(0, soFromBeginning);
479       Result:= StrStream.DataString;
480     finally
481       StrStream.Free;
482     end;
483   finally
484     BinStream.Free
485   end;
486 end;
487
488 function StringToComponent(Value: string): TComponent;
489 var
490   StrStream:TStringStream;
491   BinStream: TMemoryStream;
492 begin
493   StrStream := TStringStream.Create(Value);
494   try
495     BinStream := TMemoryStream.Create;
496     try
497       ObjectTextToBinary(StrStream, BinStream);
498       BinStream.Seek(0, soFromBeginning);
499       Result := BinStream.ReadComponent(nil);
500     finally
501       BinStream.Free;
502     end;
503   finally
504     StrStream.Free;
505   end;
506 end;
507
508 function ReplacePresetFileName: string;
509 begin
510   Result := ExtractFilePath(Application.ExeName) + 'replace.txt';
511 end;
512
513 procedure BuildShortCutList(Target: TStrings);
514 var
515   c: Char;
516   i: Integer;
517 begin
518   // \83V\83\87\81[\83g\83J\83b\83g\83\8a\83X\83g\82Ì\91I\91ð\8e\88\82ð\8dì\90¬
519   with Target do
520   begin
521     BeginUpdate;
522     try
523       for c := 'A' to 'Z' do
524         Add('Ctrl+' + c);
525       for c := 'A' to 'Z' do
526         Add('Shift+Ctrl+' + c);
527       for c := 'A' to 'Z' do
528         Add('Alt+Ctrl+' + c);
529       for i := 1 to 12 do
530         Add('F' + IntToStr(i));
531       for i := 1 to 12 do
532         Add('Shift+F' + IntToStr(i));
533     finally
534       EndUpdate;
535     end;
536   end;
537 end;
538
539 { TBottlePrefs }
540
541 constructor TBottlePrefs.Create;
542 var ARect: TRect;
543     Strs: TStringList;
544 begin
545   FAutoJoinChannels := TStringList.Create;
546   FDefaultScript := TStringList.Create;
547   FFMOName := TStringList.Create;
548   FVisibleGhostsList := TStringList.Create;
549   try
550     FIni := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
551     //
552     PartialConfirmFormat := FIni.ReadString('System', 'PartialConfirmFormat', '\t|\e');
553     AutoPartialConfirm := FIni.ReadBool('System', 'AutoPartialConfirm', false);
554     ConfirmOnExit := FIni.ReadBool('System', 'ConfirmOnExit', false);
555     ConfirmOnTabClose := FIni.ReadBool('System', 'ConfirmOnTabClose', false);
556     NoWarnOfEmptyFMO := FIni.ReadBool('System', 'NoWarnOfEmptyFMO', False);
557     ShowEditorPreviewWindow := FIni.ReadBool('System', 'ShowEditorPreviewWindow', False);
558     LogItemDragDrop := FIni.ReadBool('System', 'LogItemDragDrop', True);
559
560     AutoClip := FIni.ReadBool('System', 'AutoClip', false);
561     AutoStart := FIni.ReadBool('System', 'AutoStart', false);
562     TabPosition := TTabPosition(FIni.ReadInteger('System', 'TabPosition', 0));
563     TabWidth := FIni.ReadInteger('System', 'TabWidth', 0);
564     GhostDropDownCount := FIni.ReadInteger('System', 'GhostDropDownCount', 30);
565
566     NoTranslate := FIni.ReadBool('System', 'NoTranslate', true);
567     NoDescript := FIni.ReadBool('System', 'NoDescript', false);
568     NoTransUrl := FIni.ReadBool('System', 'NoTransUrl', false);
569     SilentWhenHidden:= FIni.ReadBool('System', 'SilentWhenHidden', true);
570     FixMessySurface := FIni.ReadBool('System', 'FixMessySurface', false);
571     HUTagTo01Tag := FIni.ReadBool('System', 'HUTagTo01Tag', false);
572     ResetIfGhostAfterSend := FIni.ReadBool('System', 'ResetIfGhostAfterSend', false);
573     ClearAfterSend := FIni.ReadBool('System', 'ClearAfterSend', true);
574     NeedConfirmBeforeSend := FIni.ReadBool('System', 'NeedConfirmBeforeSend', true);
575     WarnYenTNotExist := FIni.ReadBool('System', 'WarnYenTNotExist', false);
576     WarnScopeChangeInSynchronize := FIni.ReadBool('System', 'WarnScopeChangeInSynchronize', false);
577
578     IgnoreFrequentYenS := FIni.ReadBool('System', 'IgnoreFrequentYenS', false);
579     WaitScriptEnd := FIni.ReadInteger('System', 'WaitScriptEnd', 0);
580     MinScriptLength := FIni.ReadInteger('System', 'MinScriptLength', DefaultMinScriptLength);
581     StayOnTop := FIni.ReadBool('System', 'StayOnTop', false);
582     ShowConstBar := FIni.ReadBool('System', 'ShowConstBar', true);
583     ShowToolBar := FIni.ReadBool('System', 'ShowToolBar', true);
584     NoConfirm := FIni.ReadBool('System', 'NoConfirm', false);
585     IgnoreTimeCritical := FIni.ReadBool('System', 'IgnoreTimeCritical', false);
586     FDefaultScript.CommaText := FIni.ReadString('System', 'DefaultScript', '\t\u\s[10]\h\s[0]|\e');
587     ShowRuler := FIni.ReadBool('System', 'ShowRuler', false);
588     //
589     try
590       TalkColorH := StringToColor(FIni.ReadString('System', 'TalkColorH', 'clBlack'));
591       TalkColorU := StringToColor(FIni.ReadString('System', 'TalkColorU', 'clMaroon'));
592       TalkColorS := StringToColor(FIni.ReadString('System', 'TalkColorS', 'clPurple'));
593       MarkUpColor := StringToColor(FIni.ReadString('System', 'MarkUpColor', 'clGreen'));
594       MetaWordColor := StringToColor(FIni.ReadString('System', 'MetaWordColor', 'clBlue'));
595       MarkErrorColor := StringToColor(FIni.ReadString('System', 'MarkErrorColor', 'clRed'));
596       TextColor := StringToColor(FIni.ReadString('System', 'TextColor', ColorToString(TalkColorH)));
597       BgColor := StringToColor(FIni.ReadString('System', 'BgColor', 'clWhite'));
598     except
599       on EConvertError do begin
600         ShowMessage('\83J\83\89\81[\82Ì\90Ý\92è\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81[');
601         FTalkColorH := clBlack;
602         FTalkColorU := clMaroon;
603         FMarkUpColor := clGreen;
604         FMetaWordColor := clBlue;
605         FMarkErrorColor := clRed;
606         FTextColor := clBlack;
607       end;
608     end;
609
610     try
611       if FIni.ReadString('System', 'PlayTimeParams', '') = '' then
612       begin
613         FPlayTimeParams := TSsPlayTimeParams.Create(nil);
614         FPlayTimeParams.ProfileName := '\83f\83t\83H\83\8b\83g';
615       end else
616       begin
617         Strs := TStringList.Create;
618         try
619           Strs.CommaText := FIni.ReadString('System', 'PlayTimeParams', '');
620           FPlayTimeParams := StringToComponent(Strs.Text) as TSsPlayTimeParams;
621         finally
622           Strs.Free;
623         end;
624       end;
625     except
626       on E: Exception do
627       begin
628         ShowMessage('\8dÄ\90\8e\9e\8aÔ\97\\91ª\90Ý\92è\82Ì\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81[' + E.Message);
629         if FPlayTimeParams = nil then
630           FPlayTimeParams := TSsPlayTimeParams.Create(nil);
631       end;
632     end;
633
634     WhenReturn      := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenReturn', 0));
635     WhenShiftReturn := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenShiftReturn', 0));
636     WhenCtrlReturn  := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenCtrlReturn', 0));
637     //\83\\83P\83b\83g\82ð\83{\83g\83\8b\94z\91\97\82ÌSSTP\92Ê\90M\82É\8eg\97p\82·\82é\8fê\8d\87\82Ì\90Ý\92è
638     ServerPort      := FIni.ReadInteger('System', 'ServerPort', 11000);
639
640     FBottleServer := FIni.ReadString('System', 'BottleServer', DefaultBottleServer);
641     FBottleServerPort := FIni.ReadInteger('System', 'BottleServerPort', DefaultBottleServerPort);
642     FCgiName  := FIni.ReadString('System', 'CgiName', DefaultCGI);
643     FCgiFetchLog := FIni.ReadString('System', 'CgiFetchLog', DefaultCGIFetchLog);
644     FHomePage := FIni.ReadString('System', 'HomePage', DefaultHomePage);
645     FGLogPage := FIni.ReadString('System', 'GLogPage', DefaultGLogPage);
646     FVotePage := FIni.ReadString('System', 'VotePage', DefaultVotePage);
647     FHelpPage := FIni.ReadString('System', 'HelpPage', DefaultHelpPage);
648     FCgiNameGhost := FIni.ReadString('System', 'GHOST', DefaultCGIGhost);
649     FLUID     := FIni.ReadString('System', 'LUID', '');
650     FAutoJoinChannels.CommaText := FIni.ReadString('System', 'AutoJoinChannels', '');
651     //
652     ARect.Top    := FIni.ReadInteger('System', 'SenderWindowPositionTop', 100);
653     ARect.Left   := FIni.ReadInteger('System', 'SenderWindowPositionLeft', 100);
654     ARect.Bottom := FIni.ReadInteger('System', 'SenderWindowPositionBottom', 500);
655     ARect.Right  := FIni.ReadInteger('System', 'SenderWindowPositionRight', 500);
656     if not InScreen(ARect) then
657       ARect := Rect(100, 100, 500, 500);
658     SenderWindowPosition := ARect;
659     ARect.Top    := FIni.ReadInteger('System', 'LogWindowPositionTop', 200);
660     ARect.Left   := FIni.ReadInteger('System', 'LogWindowPositionLeft', 200);
661     ARect.Bottom := FIni.ReadInteger('System', 'LogWindowPositionBottom', 600);
662     ARect.Right  := FIni.ReadInteger('System', 'LogWindowPositionRight', 400);
663     LogWindowDividerPos := FIni.ReadInteger('System', 'LogWindowDividerPos', 150);
664     LogWindowColumnWidth := FIni.ReadString('System', 'LogWindowColumnWidth', '');
665     if not InScreen(ARect) then begin
666       ARect := Rect(200, 200, 600, 400);
667       LogWindowDividerPos := 150;
668     end;
669     LogWindowPosition := ARect;
670     Strs := TStringList.Create;
671     try
672       Strs.CommaText := FIni.ReadString('System', 'EditorPreviewWindowPosition', '500,100,800,500');
673       try
674         ARect.Left   := StrToInt(Strs[0]);
675         ARect.Top    := StrToInt(Strs[1]);
676         ARect.Right  := StrToInt(Strs[2]);
677         ARect.Bottom := StrToInt(Strs[3]);
678       except
679         ARect := Rect(500, 100, 800, 500);
680       end;
681       EditorPreviewWindowPosition := ARect;
682     finally
683       Strs.Free;
684     end;
685     //
686     UseHttpProxy := FIni.ReadBool('System', 'UseHttpProxy', false);
687     AskUseHttpProxy := FIni.ReadBool('System', 'AskUseHttpProxy', false);
688     ProxyAddress := FIni.ReadString('System', 'ProxyAddress', '');
689     ProxyPort    := FIni.ReadInteger('System', 'ProxyPort', 0);
690     ProxyUser    := FIni.ReadString('System', 'ProxyUser', '');
691     ProxyPass    := FIni.ReadString('System', 'ProxyPass', '');
692     ProxyNeedAuthentication := FIni.ReadBool('System', 'ProxyNeedAuthentication', false);
693     //
694     ReconnectWait := FIni.ReadInteger('System', 'ReconnectWait', 6);
695     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
696     LogWindowPreviewStyle := TLogWindowPreviewStyle(
697       FIni.ReadInteger('System', 'LogWindowPreviewStyle', 0));
698     LogListPreviewStyle := TLogListPreviewStyle(
699       FIni.ReadInteger('System', 'LogListPreviewStyle', 0));
700     //\8fÚ\8d×
701     FMOName.CommaText := FIni.ReadString('System', 'FMOName', 'Sakura');
702     HideGhosts := FIni.ReadBool('System', 'HideGhosts', false);
703     VisibleGhostsList.CommaText := FIni.ReadString('System', 'VisibleGhostsList', '');
704     NoExtraSSTPHeaders := FIni.ReadBool('System', 'NoExtraSSTPHeaders', false);
705     //\83T\81[\83t\83B\83X\83v\83\8c\83r\83\85\81[
706     SurfacePreviewOnHint := FIni.ReadBool('System', 'SurfacePreviewOnHint', false);
707     SurfacePreviewOnScriptPoint := FIni.ReadBool('System', 'SurfacePreviewOnScriptPoint', false);
708     SurfacePreviewOnScriptPointPosition :=
709       TSurfacePreviewOnScriptPointPosition(FIni.ReadInteger('System', 'SurfacePreviewOnScriptPointPosition', 0));
710
711     //URL\82ð\8aJ\82­\83u\83\89\83E\83U
712     FBrowserExeName:= FIni.ReadString('System', 'BrowserExeName', '');
713
714     //\8e©\93®\92u\8a·\83v\83\8a\83Z\83b\83g
715     if FileExists(ReplacePresetFileName) then
716     begin
717       try
718         Strs := TStringList.Create;
719         try
720           Strs.LoadFromFile(ReplacePresetFileName);
721           FReplacePresets := StringToComponent(Strs.Text) as TReplacePresets;
722         finally
723           Strs.Free;
724         end;
725       except
726         ShowMessage('Replace.txt\93Ç\82Ý\8d\9e\82Ý\92\86\82Ì\83G\83\89\81[\81B'#13#10+
727           '\83t\83@\83C\83\8b\82ª\94j\91¹\82µ\82Ä\82¢\82é\8fê\8d\87\82Í\81A\82±\82Ì\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82µ\82Ä\8dÄ\8bN\93®\82µ\82Ä\82­\82¾\82³\82¢');
728         raise;
729       end;
730     end else
731       FReplacePresets := TReplacePresets.Create(nil);
732   except
733     on E: Exception do
734     begin
735       ShowMessage('\90Ý\92è\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81['#13#10 + E.Message);
736       Application.Terminate;
737     end;
738   end;
739 end;
740
741 destructor TBottlePrefs.Destroy;
742 begin
743   inherited;
744   SaveSettings;
745   if FReplacePresets <> nil then
746     FReplacePresets.Free;
747   if FIni <> nil then
748     FIni.Free;
749   if FAutoJoinChannels <> nil then
750     FAutoJoinChannels.Free;
751   if FDefaultScript <> nil then
752     FDefaultScript.Free;
753   if FFMOName <> nil then
754     FFMOName.Free;
755   if FVisibleGhostsList <> nil then
756     FVisibleGhostsList.Free;
757   if FPlayTimeParams <> nil then
758     FPlayTimeParams.Free;
759 end;
760
761 procedure TBottlePrefs.SetAutoStart(const Value: boolean);
762 begin
763   FAutoStart := Value;
764 end;
765
766 procedure TBottlePrefs.SetBgColor(const Value: TColor);
767 begin
768   FBgColor := Value;
769 end;
770
771 procedure TBottlePrefs.SetConfirmOnExit(const Value: boolean);
772 begin
773   FConfirmOnExit := Value;
774 end;
775
776 procedure TBottlePrefs.SetDblClkInsert(const Value: boolean);
777 begin
778   FDblClkInsert := Value;
779 end;
780
781 procedure TBottlePrefs.SetDefaultScript(const Value: String);
782 begin
783   FDefaultScript.Text := Value;
784 end;
785
786 procedure TBottlePrefs.SetFixMessySurface(const Value: boolean);
787 begin
788   FFixMessySurface := Value;
789 end;
790
791 procedure TBottlePrefs.SetGhostDropDownCount(const Value: integer);
792 begin
793   FGhostDropDownCount := Value;
794 end;
795
796 procedure TBottlePrefs.SetIgnoreFrequentYenS(const Value: boolean);
797 begin
798   FIgnoreFrequentYenS := Value;
799 end;
800
801 procedure TBottlePrefs.SetIgnoreTimeCritical(const Value: boolean);
802 begin
803   FIgnoreTimeCritical := Value;
804 end;
805
806 procedure TBottlePrefs.SetLogWindowDividerPos(const Value: integer);
807 begin
808   FLogWindowDividerPos := Value;
809 end;
810
811 procedure TBottlePrefs.SetLogWindowPosition(const Value: TRect);
812 begin
813   FLogWindowPosition := Value;
814 end;
815
816 procedure TBottlePrefs.SetLUID(const Value: String);
817 begin
818   FLUID := Value;
819 end;
820
821 procedure TBottlePrefs.SetMarkErrorColor(const Value: TColor);
822 begin
823   FMarkErrorColor := Value;
824 end;
825
826 procedure TBottlePrefs.SetTextColor(const Value: TColor);
827 begin
828   FTextColor := Value;
829 end;
830
831 procedure TBottlePrefs.SetMarkUpColor(const Value: TColor);
832 begin
833   FMarkUpColor := Value;
834 end;
835
836 procedure TBottlePrefs.SetMetaWordColor(const Value: TColor);
837 begin
838   FMetaWordColor := Value;
839 end;
840
841 procedure TBottlePrefs.SetNoConfirm(const Value: boolean);
842 begin
843   FNoConfirm := Value;
844 end;
845
846 procedure TBottlePrefs.SetNoDescript(const Value: boolean);
847 begin
848   FNoDescript := Value;
849 end;
850
851 procedure TBottlePrefs.SetNoTranslate(const Value: boolean);
852 begin
853   FNoTranslate := Value;
854 end;
855
856 procedure TBottlePrefs.SetNoTransUrl(const Value: boolean);
857 begin
858   FNoTransUrl := Value;
859 end;
860
861 procedure TBottlePrefs.SetLogWindowPreviewStyle(
862   const Value: TLogWindowPreviewStyle);
863 begin
864   FLogWindowPreviewStyle := Value;
865 end;
866
867 procedure TBottlePrefs.SetProxyAddress(const Value: String);
868 begin
869   FProxyAddress := Value;
870 end;
871
872 procedure TBottlePrefs.SetProxyPort(const Value: integer);
873 begin
874   FProxyPort := Value;
875 end;
876
877 procedure TBottlePrefs.SetProxyNeedAuthentication(const Value: boolean);
878 begin
879   FProxyNeedAuthentication := Value;
880 end;
881
882 procedure TBottlePrefs.SetProxyPass(const Value: String);
883 begin
884   FProxyPass := Value;
885 end;
886
887 procedure TBottlePrefs.SetProxyUser(const Value: String);
888 begin
889   FProxyUser := Value;
890 end;
891
892 procedure TBottlePrefs.SetResetIfGhostAfterSend(const Value: boolean);
893 begin
894   FResetIfGhostAfterSend := Value;
895 end;
896
897 procedure TBottlePrefs.SetSenderWindowPosition(const Value: TRect);
898 begin
899   FSenderWindowPosition := Value;
900 end;
901
902 procedure TBottlePrefs.SetServerPort(const Value: integer);
903 begin
904   if Value > 0 then FServerPort := Value;
905 end;
906
907 procedure TBottlePrefs.SetShowConstBar(const Value: boolean);
908 begin
909   FShowConstBar := Value;
910 end;
911
912 procedure TBottlePrefs.SetShowToolBar(const Value: boolean);
913 begin
914   FShowToolBar := Value;
915 end;
916
917 procedure TBottlePrefs.SetSilentWhenHidden(const Value: boolean);
918 begin
919   FSilentWhenHidden := Value;
920 end;
921
922 procedure TBottlePrefs.SetStayOnTop(const Value: boolean);
923 begin
924   FStayOnTop := Value;
925 end;
926
927 procedure TBottlePrefs.SetTabPosition(const Value: TTabPosition);
928 begin
929   FTabPosition := Value;
930 end;
931
932 procedure TBottlePrefs.SetTalkColorH(const Value: TColor);
933 begin
934   FTalkColorH := Value;
935 end;
936
937 procedure TBottlePrefs.SetTalkColorU(const Value: TColor);
938 begin
939   FTalkColorU := Value;
940 end;
941
942 procedure TBottlePrefs.SetUseHttpProxy(const Value: boolean);
943 begin
944   FUseHttpProxy := Value;
945 end;
946
947 procedure TBottlePrefs.SetAskUseHttpProxy(const Value: boolean);
948 begin
949   FAskUseHttpProxy := Value;
950 end;
951
952 procedure TBottlePrefs.SetWaitScriptEnd(const Value: integer);
953 begin
954   if Value > 0 then FWaitScriptEnd := Value;
955 end;
956
957 procedure TBottlePrefs.SetMinScriptLength(const Value: integer);
958 begin
959   if Value >= DefaultMinScriptLength then FMinScriptLength := Value;
960 end;
961
962 procedure TBottlePrefs.SetWhenCtrlReturn(const Value: TReturnKeyFunction);
963 begin
964   FWhenCtrlReturn := Value;
965 end;
966
967 procedure TBottlePrefs.SetWhenReturn(const Value: TReturnKeyFunction);
968 begin
969   FWhenReturn := Value;
970 end;
971
972 procedure TBottlePrefs.SetWhenShiftReturn(const Value: TReturnKeyFunction);
973 begin
974   FWhenShiftReturn := Value;
975 end;
976
977 procedure TBottlePrefs.SetTalkColorS(const Value: TColor);
978 begin
979   FTalkColorS := Value;
980 end;
981
982 procedure TBottlePrefs.SetLogWindowColumnWidth(const Value: String);
983 begin
984   FLogWindowColumnWidth := Value;
985 end;
986
987 procedure TBottlePrefs.SetClearAfterSend(const Value: boolean);
988 begin
989   FClearAfterSend := Value;
990 end;
991
992 procedure TBottlePrefs.SetAutoJoinChannels(const Value: TStrings);
993 begin
994   FAutoJoinChannels.Assign(Value);
995 end;
996
997 procedure TBottlePrefs.SetFMOName(const Value: TStrings);
998 begin
999   FFMOName.Assign(Value);
1000 end;
1001
1002 procedure TBottlePrefs.SaveSettings;
1003 var
1004   Strs: TStringList;
1005 begin
1006   FIni.WriteString('System', 'PartialConfirmFormat', PartialConfirmFormat);
1007   FIni.WriteBool('System', 'AutoPartialConfirm', AutoPartialConfirm);
1008   FIni.WriteBool('System', 'ConfirmOnExit', ConfirmOnExit);
1009   FIni.WriteBool('System', 'ConfirmOnTabClose', ConfirmOnTabClose);
1010   FIni.WriteBool('System', 'AutoClip', AutoClip);
1011   FIni.WriteBool('System', 'AutoStart', AutoStart);
1012   FIni.WriteInteger('System', 'TabPosition', Ord(TabPosition));
1013   FIni.WriteInteger('System', 'TabWidth', TabWidth);
1014   FIni.WriteInteger('System', 'GhostDropDownCount', GhostDropDownCount);
1015
1016   FIni.WriteBool('System', 'NoTranslate', NoTranslate);
1017   FIni.WriteBool('System', 'NoDescript', NoDescript);
1018   FIni.WriteBool('System', 'NoTransUrl', NoTransUrl);
1019   FIni.WriteBool('System', 'SilentWhenHidden', SilentWhenHidden);
1020   FIni.WriteBool('System', 'FixMessySurface', FixMessySurface);
1021   FIni.WriteBool('System', 'HUTagTo01Tag', HUTagTo01Tag);
1022   FIni.WriteBool('System', 'ResetIfGhostAfterSend', ResetIfGhostAfterSend);
1023   FIni.WriteBool('System', 'ClearAfterSend', ClearAfterSend);
1024   FIni.WriteBool('System', 'NeedConfirmBeforeSend', NeedConfirmBeforeSend);
1025   FIni.WriteBool('System', 'WarnYenTNotExist', WarnYenTNotExist);
1026   FIni.WriteBool('System', 'WarnScopeChangeInSynchronize', WarnScopeChangeInSynchronize);
1027
1028   FIni.WriteBool('System', 'IgnoreFrequentYenS', IgnoreFrequentYenS);
1029   FIni.WriteInteger('System', 'WaitScriptEnd', WaitScriptEnd);
1030   FIni.WriteInteger('System', 'MinScriptLength', MinScriptLength);
1031   FIni.WriteBool('System', 'StayOnTop', StayOnTop);
1032   FIni.WriteBool('System', 'NoConfirm', NoConfirm);
1033   FIni.WriteBool('System', 'IgnoreTimeCritical', IgnoreTimeCritical);
1034   FIni.WriteString('System', 'TalkColorH',     ColorToString(TalkColorH));
1035   FIni.WriteString('System', 'TalkColorU',     ColorToString(TalkColorU));
1036   FIni.WriteString('System', 'TalkColorS',     ColorToString(TalkColorS));
1037   FIni.WriteString('System', 'MarkUpColor',    ColorToString(MarkUpColor));
1038   FIni.WriteString('System', 'MetaWordColor',  ColorToString(MetaWordColor));
1039   FIni.WriteString('System', 'MarkErrorColor', ColorToString(MarkErrorColor));
1040   FIni.WriteString('System', 'TextColor', ColorToString(TextColor));
1041
1042   Strs := TStringList.Create;
1043   try
1044     Strs.Text := ComponentToString(FPlayTimeParams);
1045     FIni.WriteString('System', 'PlayTimeParams', Strs.CommaText);
1046   finally
1047     Strs.Free;
1048   end;
1049
1050   FIni.WriteString('System', 'BgColor', ColorToString(BgColor));
1051   FIni.WriteBool('System', 'ShowToolBar', ShowToolBar);
1052   FIni.WriteBool('System', 'ShowConstBar', ShowConstBar);
1053   FIni.WriteString('System', 'DefaultScript', FDefaultScript.CommaText);
1054   FIni.WriteBool('System', 'ShowRuler', ShowRuler);
1055   FIni.WriteInteger('System', 'WhenReturn', Ord(WhenReturn));
1056   FIni.WriteInteger('System', 'WhenShiftReturn', Ord(WhenShiftReturn));
1057   FIni.WriteInteger('System', 'WhenCtrlReturn', Ord(WhenCtrlReturn));
1058   FIni.WriteInteger('System', 'ServerPort', ServerPort);
1059   FIni.WriteString('System', 'LUID', LUID);
1060   FIni.WriteString('System', 'AutoJoinChannels', FAutoJoinChannels.CommaText);
1061   //
1062   FIni.WriteInteger('System', 'SenderWindowPositionLeft', SenderWindowPosition.Left);
1063   FIni.WriteInteger('System', 'SenderWindowPositionTop', SenderWindowPosition.Top);
1064   FIni.WriteInteger('System', 'SenderWindowPositionRight', SenderWindowPosition.Right);
1065   FIni.WriteInteger('System', 'SenderWindowPositionBottom', SenderWindowPosition.Bottom);
1066   FIni.WriteInteger('System', 'LogWindowPositionLeft', LogWindowPosition.Left);
1067   FIni.WriteInteger('System', 'LogWindowPositionTop', LogWindowPosition.Top);
1068   FIni.WriteInteger('System', 'LogWindowPositionRight', LogWindowPosition.Right);
1069   FIni.WriteInteger('System', 'LogWindowPositionBottom', LogWindowPosition.Bottom);
1070   FIni.WriteInteger('System', 'LogWindowDividerPos', LogWindowDividerPos);
1071   FIni.WriteString('System', 'LogWindowColumnWidth', LogWindowColumnWidth);
1072   with EditorPreviewWindowPosition do
1073     FIni.WriteString('System', 'EditorPreviewWindowPosition',
1074       Format('%d,%d,%d,%d', [Left, Top, Right, Bottom]));
1075   //
1076   FIni.WriteBool('System', 'UseHttpProxy', UseHttpProxy);
1077   FIni.WriteBool('System', 'AskUseHttpProxy', AskUseHttpProxy);
1078   FIni.WriteString('System', 'ProxyAddress', ProxyAddress);
1079   FIni.WriteInteger('System', 'ProxyPort', ProxyPort);
1080   FIni.WriteBool('System', 'ProxyNeedAuthentication', ProxyNeedAuthentication);
1081   FIni.WriteString('System', 'ProxyUser', ProxyUser);
1082   FIni.WriteString('System', 'ProxyPass', ProxyPass);
1083   //
1084   FIni.WriteInteger('System', 'ReconnectWait', ReconnectWait);
1085   //
1086   FIni.WriteInteger('System', 'LogWindowPreviewStyle', Ord(LogWindowPreviewStyle));
1087   FIni.WriteInteger('System', 'LogListPreviewStyle', Ord(LogListPreviewStyle));
1088   FIni.WriteString('System', 'FMOName', FFMOName.CommaText);
1089   FIni.WriteBool('System', 'HideGhosts', HideGhosts);
1090   FIni.WriteString('System', 'VisibleGhostsList', VisibleGhostsList.CommaText);
1091   FIni.WriteBool('System', 'NoExtraSSTPHeaders', NoExtraSSTPHeaders);
1092   //
1093   FIni.WriteBool('System', 'SurfacePreviewOnHint', SurfacePreviewOnHint);
1094   FIni.WriteBool('System', 'SurfacePreviewOnScriptPoint', SurfacePreviewOnScriptPoint);
1095   FIni.WriteInteger('System', 'SurfacePreviewOnScriptPointPosition', Ord(SurfacePreviewOnScriptPointPosition));
1096
1097   FIni.WriteString('System', 'BrowserExeName', BrowserExeName);
1098   FIni.WriteBool('System', 'NoWarnOfEmptyFMO', NoWarnOfEmptyFMO);
1099   FIni.WriteBool('System', 'ShowEditorPreviewWindow', ShowEditorPreviewWindow);
1100   FIni.WriteBool('System', 'LogItemDragDrop', LogItemDragDrop);
1101
1102   Strs := TStringList.Create;
1103   try
1104     Strs.Text := ComponentToString(FReplacePresets);
1105     Strs.SaveToFile(ReplacePresetFileName);
1106   finally
1107     Strs.Free;
1108   end;
1109 end;
1110
1111 function TBottlePrefs.GetDefaultScript: String;
1112 begin
1113   Result := FDefaultScript.Text;
1114 end;
1115
1116 procedure TBottlePrefs.SetHUTagTo01Tag(const Value: boolean);
1117 begin
1118   FHUTagTo01Tag := Value;
1119 end;
1120
1121 procedure TBottlePrefs.SetWarnScopeChangeInSynchronize(
1122   const Value: boolean);
1123 begin
1124   FWarnScopeChangeInSynchronize := Value;
1125 end;
1126
1127 procedure TBottlePrefs.SetWarnYenTNotExist(const Value: boolean);
1128 begin
1129   FWarnYenTNotExist := Value;
1130 end;
1131
1132 procedure TBottlePrefs.SetNeedConfirmBeforeSend(const Value: boolean);
1133 begin
1134   FNeedConfirmBeforeSend := Value;
1135 end;
1136
1137 procedure TBottlePrefs.SetShowRuler(const Value: boolean);
1138 begin
1139   FShowRuler := Value;
1140 end;
1141
1142 procedure TBottlePrefs.SetHideGhosts(const Value: boolean);
1143 begin
1144   FHideGhosts := Value;
1145 end;
1146
1147 procedure TBottlePrefs.SetVisibleGhostsList(const Value: TStringList);
1148 begin
1149   FVisibleGhostsList.Assign(Value);
1150 end;
1151
1152 procedure TBottlePrefs.SetSurfacePreviewOnHint(const Value: boolean);
1153 begin
1154   FSurfacePreviewOnHint := Value;
1155 end;
1156
1157 procedure TBottlePrefs.SetSurfacePreviewOnScriptPoint(
1158   const Value: boolean);
1159 begin
1160   FSurfacePreviewOnScriptPoint := Value;
1161 end;
1162
1163 procedure TBottlePrefs.SetSurfacePreviewOnScriptPointPosition(
1164   const Value: TSurfacePreviewOnScriptPointPosition);
1165 begin
1166   FSurfacePreviewOnScriptPointPosition := Value;
1167 end;
1168
1169 procedure TBottlePrefs.SetNoExtraSSTPHeaders(const Value: boolean);
1170 begin
1171   FNoExtraSSTPHeaders := Value;
1172 end;
1173
1174 procedure TBottlePrefs.SetLogListPreviewStyle(
1175   const Value: TLogListPreviewStyle);
1176 begin
1177   FLogListPreviewStyle := Value;
1178 end;
1179
1180 procedure TBottlePrefs.SetEditorPreviewWindowPosition(const Value: TRect);
1181 begin
1182   FEditorPreviewWindowPosition := Value;
1183 end;
1184
1185 function TBottlePrefs.InScreen(ARect: TRect): boolean;
1186 var i: integer;
1187     dum: TRect;
1188 begin
1189   Result := false;
1190   for i := 0 to Screen.MonitorCount-1 do
1191   begin
1192     if IntersectRect(dum, ARect, Screen.Monitors[i].WorkareaRect) then
1193     begin
1194       Result := true;
1195       Exit;
1196     end;
1197   end;
1198 end;
1199
1200 procedure TBottlePrefs.SetAutoClip(const Value: boolean);
1201 begin
1202   FAutoClip := Value;
1203 end;
1204
1205 procedure TBottlePrefs.SetConfirmOnTabClose(const Value: boolean);
1206 begin
1207   FConfirmOnTabClose := Value;
1208 end;
1209
1210 procedure TBottlePrefs.SetReconnectWait(const Value: integer);
1211 begin
1212   FReconnectWait := Value;
1213   if Value < 6 then
1214     raise Exception.Create('Reconnect wait must be >=6');
1215 end;
1216
1217 procedure TBottlePrefs.SetPartialConfirmFormat(const Value: String);
1218 begin
1219   FPartialConfirmFormat := Value;
1220 end;
1221
1222 procedure TBottlePrefs.SetAutoPartialConfirm(const Value: boolean);
1223 begin
1224   FAutoPartialConfirm := Value;
1225 end;
1226
1227 procedure TBottlePrefs.SetPlayTimeParams(const Value: TSsPlayTimeParams);
1228 begin
1229   FPlayTimeParams.Assign(Value);
1230 end;
1231
1232 procedure TBottlePrefs.SetTabWidth(const Value: integer);
1233 begin
1234   FTabWidth := Value;
1235 end;
1236
1237 procedure TBottlePrefs.SetBrowserExeName(const Value: string);
1238 begin
1239   FBrowserExeName := Value;
1240 end;
1241
1242 { TChannelListItem }
1243
1244 procedure TChannelListItem.SetGhost(const Value: String);
1245 begin
1246   FGhost := Value;
1247 end;
1248
1249 procedure TChannelListItem.SetInfo(const Value: String);
1250 begin
1251   FInfo := Value;
1252 end;
1253
1254 procedure TChannelListItem.SetMembers(const Value: integer);
1255 begin
1256   FMembers := Value;
1257 end;
1258
1259 procedure TChannelListItem.SetName(const Value: String);
1260 begin
1261   FName := Value;
1262 end;
1263
1264 procedure TChannelListItem.SetNoPost(const Value: boolean);
1265 begin
1266   FNoPost := Value;
1267 end;
1268
1269 procedure TChannelListItem.SetWarnPost(const Value: boolean);
1270 begin
1271   FWarnPost := Value;
1272 end;
1273
1274 { TChannelList }
1275
1276 procedure TChannelList.Clear;
1277 var i: integer;
1278 begin
1279   for i := Self.Count-1 downto 0 do begin
1280     TChannelListItem(Self[i]).Free;
1281   end;
1282   inherited;
1283 end;
1284
1285 function TChannelList.GetChannel(Name: String): TChannelListItem;
1286 var i: integer;
1287 begin
1288   Result := nil;
1289   for i := 0 to Count-1 do
1290     if TChannelListItem(Self[i]).Name = Name then begin
1291       Result := TChannelListItem(Self[i]);
1292       Exit;
1293     end;
1294 end;
1295
1296 function TChannelList.GetChannelItem(Index: integer): TChannelListItem;
1297 begin
1298   Result := TChannelListItem(Self[Index]);
1299 end;
1300
1301 initialization
1302
1303 Classes.RegisterClass(TSsPlayTimeParams);
1304
1305 Pref := TBottlePrefs.Create;
1306 ChannelList := TChannelList.Create;
1307 JoinChannels := TStringList.Create;
1308
1309 finalization
1310
1311 Pref.Free;
1312 ChannelList.Clear;
1313 JoinChannels.Free;
1314 ChannelList.Free;
1315
1316 end.