OSDN Git Service

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