1 unit ExtPreviewDatamodule;
6 SysUtils, Classes, bmRegExp, ExtCtrls, GikoSystem;
9 TCommand = class(TObject)
16 constructor Create(const comm: String);
17 property Command: String read FCommand;
18 property Confirm: Boolean read FConfirm write FConfirm;
19 property Continue: Boolean read FContinue write FContinue;
20 property ToURL: String read FToURL write FToURL;
23 TExtPreviewDM = class(TDataModule)
25 procedure DataModuleCreate(Sender: TObject);
26 procedure DataModuleDestroy(Sender: TObject);
27 procedure ExecuteTimerTimer(Sender: TObject);
32 FExecCommand: TCommand;
33 function ReadCommand(const Line: String): TCommand;
36 function PreviewURL(const URL: String): Boolean;
40 ExtPreviewDM: TExtPreviewDM;
45 IniFiles, GikoUtil, Windows;
47 constructor TCommand.Create(const comm: String);
56 \brief
\83R
\83\93\83X
\83g
\83\89\83N
\83^
58 procedure TExtPreviewDM.DataModuleCreate(Sender: TObject);
63 FAWKStr := TAWKStr.Create(Self);
64 FRegs := TStringList.Create;
65 if (FileExists(GikoSys.GetExtpreviewFileName)) then begin
66 values := TStringList.Create;
68 values.LoadFromFile(GikoSys.GetExtpreviewFileName);
69 for i := 0 to values.Count - 1 do begin
70 if ( AnsiPos('#',values[i]) = 1 ) then begin
71 //
\90æ
\93ª#
\82Å
\8en
\82Ü
\82é
\82Í
\83R
\83\81\83\93\83g
\8ds
73 pos := AnsiPos(#9,values[i]);
74 if (pos > 0) then begin
76 Copy(values[i], 1, pos - 1),
78 Copy(values[i], pos + 1, Length(values[i])))
89 \brief
\83f
\83X
\83g
\83\89\83N
\83^
91 procedure TExtPreviewDM.DataModuleDestroy(Sender: TObject);
98 \brief
\83R
\83}
\83\93\83h
\8ds
\89ð
\8eß
100 function TExtPreviewDM.ReadCommand(const Line: String): TCommand;
106 // FCommand , FConfirm , FContinue
\82Ì
\8f\87
107 pos := AnsiPos(#9, Line);
108 if (pos > 0) then begin
109 Result := TCommand.Create( Copy(Line, 1, pos - 1) );
110 sub := Copy(Line, pos + 1, Length(Line));
112 Result := TCommand.Create( '' );
115 pos := AnsiPos(#9, sub);
116 if (pos > 0) then begin
117 if (AnsiLowerCase(Copy(sub, 1, pos - 1)) = 'true' ) then begin
118 Result.Confirm := True;
120 sub := Copy(Line, pos + 1, Length(Line));
123 if (AnsiLowerCase(sub) = 'true' ) then begin
124 Result.Continue := True;
128 \brief
\93o
\98^
\82³
\82ê
\82½URL
\82ð
\8f\88\97\9d\82·
\82é
\83R
\83}
\83\93\83h
\82ð
\95Ô
\82·
130 function TExtPreviewDM.PreviewURL(const URL: String): Boolean;
138 ExecuteTimer.Interval := 0;
139 ExecuteTimer.Enabled := False;
141 if (Length(URL) > 0) and (FRegs.Count > 0) then begin
142 EsqURL := FAWKStr.ProcessEscSeq(URL);
143 for i := 0 to FRegs.Count - 1 do begin
144 FAWKStr.RegExp := FRegs[i];
145 if ( FAWKStr.Match(EsqURL, RStart, RLength ) <> 0 ) then begin
146 FExecCommand := TCommand(FRegs.Objects[i]);
147 FExecCommand.ToURL := Copy(EsqURL, RStart, RLength);
148 ExecuteTimer.Interval := GikoSys.Setting.PreviewWait;
149 ExecuteTimer.Enabled := True;
150 Result := not FExecCommand.FContinue;
157 procedure TExtPreviewDM.ExecuteTimerTimer(Sender: TObject);
161 //
\83^
\83C
\83}
\81[
\92â
\8e~
162 ExecuteTimer.Interval := 0;
163 ExecuteTimer.Enabled := False;
165 if (FExecCommand <> nil) then begin
167 if (FExecCommand.Confirm) then begin
169 rc := GikoUtil.MsgBox(0, FExecCommand.Command + '
\82É'#13#10 +
170 FExecCommand.ToURL + '
\82ð
\93n
\82µ
\82Ü
\82·
\82©
\81H',
171 '
\8am
\94F', MB_ICONQUESTION or MB_YESNO);
174 if (rc = ID_YES) then begin
175 //
\93Á
\8eê
\83R
\83}
\83\93\83h
176 // nop
\89½
\82à
\82µ
\82È
\82¢
177 if (AnsiLowerCase(FExecCommand.Command) <> 'nop') then begin
178 GikoSys.CreateProcess(
179 FExecCommand.Command, '"' + FExecCommand.ToURL + '"');