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