OSDN Git Service

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