Browse CVS Repository
Contents of /gikonavigoeson/gikonavi/ExtPreviewDatamodule.pas
Parent Directory
| Revision Log
| Revision Graph
Revision 1.3 -
( show annotations)
( download)
( as text)
Thu Mar 13 16:41:49 2008 UTC
(16 years ago)
by h677
Branch: MAIN
CVS Tags: v1_59_0_771, v1_59_0_770, v1_59_0_773, v1_59_0_772, v1_59_0_775, v1_59_0_774, v1_59_0_777, v1_63_0_818, v1_63_0_817, v1_63_0_816, v1_63_0_815, v1_63_1_819, v1_58_0_761, v1_60_0_779, v1_60_1_793, v1_62_0_805, v1_62_0_804, v1_62_0_807, v1_62_0_806, v1_59_1_765, v1_62_0_803, v1_62_0_802, v1_59_0_776, v1_62_0_809, v1_58_0_760, v1_61_0_798, v1_61_0_799, v1_60_0_788, v1_60_0_789, v1_59_0_767, v1_58_0_748, v1_59_0_778, v1_60_0_784, v1_60_0_786, v1_60_0_787, v1_61_0_796, v1_62_1_813, v1_58_0_754, v1_61_0_797, v1_59_1_778, v1_58_0_755, v1_59_0_768, v1_59_0_769, v1_60_0_780, v1_61_0_795, v1_60_0_781, v1_62_0_812, v1_62_0_810, v1_62_0_811, v1_60_0_782, v1_61_0_800, v1_58_0_759, v1_60_0_783, v1_59_2_785, v1_58_0_763, v1_58_0_752, v1_58_0_762, v1_58_0_750, v1_58_0_751, v1_58_0_756, v1_58_0_757, v1_60_0_793, v1_60_0_792, v1_60_0_791, v1_60_0_790, v1_60_2_794, v1_61_1_801, HEAD
Branch point for: Bb62, Bb63, Bb60, Bb61, Bb59, Bb58
Changes since 1.2: +6 -2 lines
File MIME type: text/x-pascal
何も処理しないNOPコマンド追加
| 1 |
unit ExtPreviewDatamodule; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
SysUtils, Classes, bmRegExp, ExtCtrls, GikoSystem; |
| 7 |
|
| 8 |
type |
| 9 |
TCommand = class(TObject) |
| 10 |
private |
| 11 |
FCommand: String; |
| 12 |
FConfirm: Boolean; |
| 13 |
FContinue: Boolean; |
| 14 |
FToURL: String; |
| 15 |
public |
| 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; |
| 21 |
end; |
| 22 |
|
| 23 |
TExtPreviewDM = class(TDataModule) |
| 24 |
ExecuteTimer: TTimer; |
| 25 |
procedure DataModuleCreate(Sender: TObject); |
| 26 |
procedure DataModuleDestroy(Sender: TObject); |
| 27 |
procedure ExecuteTimerTimer(Sender: TObject); |
| 28 |
private |
| 29 |
{ Private ?辿?転 } |
| 30 |
FAWKStr: TAWKStr; |
| 31 |
FRegs: TStringList; |
| 32 |
FExecCommand: TCommand; |
| 33 |
function ReadCommand(const Line: String): TCommand; |
| 34 |
public |
| 35 |
{ Public ?辿?転 } |
| 36 |
function PreviewURL(const URL: String): Boolean; |
| 37 |
end; |
| 38 |
|
| 39 |
var |
| 40 |
ExtPreviewDM: TExtPreviewDM; |
| 41 |
|
| 42 |
implementation |
| 43 |
|
| 44 |
uses |
| 45 |
IniFiles, GikoUtil, Windows; |
| 46 |
|
| 47 |
constructor TCommand.Create(const comm: String); |
| 48 |
begin |
| 49 |
FCommand := comm; |
| 50 |
FConfirm := False; |
| 51 |
FContinue := False; |
| 52 |
FToURL := ''; |
| 53 |
end; |
| 54 |
{$R *.dfm} |
| 55 |
{ |
| 56 |
\brief ?R???X?g???N?^ |
| 57 |
} |
| 58 |
procedure TExtPreviewDM.DataModuleCreate(Sender: TObject); |
| 59 |
var |
| 60 |
values: TStringList; |
| 61 |
i, pos: Integer; |
| 62 |
begin |
| 63 |
FAWKStr := TAWKStr.Create(Self); |
| 64 |
FRegs := TStringList.Create; |
| 65 |
if (FileExists(GikoSys.GetExtpreviewFileName)) then begin |
| 66 |
values := TStringList.Create; |
| 67 |
try |
| 68 |
values.LoadFromFile(GikoSys.GetExtpreviewFileName); |
| 69 |
for i := 0 to values.Count - 1 do begin |
| 70 |
if ( AnsiPos('#',values[i]) = 1 ) then begin |
| 71 |
// ????#?長?n???辿???R?????g?s |
| 72 |
end else begin |
| 73 |
pos := AnsiPos(#9,values[i]); |
| 74 |
if (pos > 0) then begin |
| 75 |
FRegs.AddObject( |
| 76 |
Copy(values[i], 1, pos - 1), |
| 77 |
ReadCommand( |
| 78 |
Copy(values[i], pos + 1, Length(values[i]))) |
| 79 |
); |
| 80 |
end; |
| 81 |
end; |
| 82 |
end; |
| 83 |
finally |
| 84 |
values.Free; |
| 85 |
end; |
| 86 |
end; |
| 87 |
end; |
| 88 |
{ |
| 89 |
\brief ?f?X?g???N?^ |
| 90 |
} |
| 91 |
procedure TExtPreviewDM.DataModuleDestroy(Sender: TObject); |
| 92 |
begin |
| 93 |
FRegs.Clear; |
| 94 |
FRegs.Free; |
| 95 |
FAWKStr.Free; |
| 96 |
end; |
| 97 |
{ |
| 98 |
\brief ?R?}???h?s???? |
| 99 |
} |
| 100 |
function TExtPreviewDM.ReadCommand(const Line: String): TCommand; |
| 101 |
var |
| 102 |
pos: Integer; |
| 103 |
sub: String; |
| 104 |
begin |
| 105 |
|
| 106 |
// FCommand , FConfirm , FContinue ???? |
| 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)); |
| 111 |
end else begin |
| 112 |
Result := TCommand.Create( '' ); |
| 113 |
sub := ''; |
| 114 |
end; |
| 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; |
| 119 |
end; |
| 120 |
sub := Copy(Line, pos + 1, Length(Line)); |
| 121 |
end; |
| 122 |
sub := Trim(sub); |
| 123 |
if (AnsiLowerCase(sub) = 'true' ) then begin |
| 124 |
Result.Continue := True; |
| 125 |
end; |
| 126 |
end; |
| 127 |
{ |
| 128 |
\brief ?o?^??????URL?????????辿?R?}???h?????? |
| 129 |
} |
| 130 |
function TExtPreviewDM.PreviewURL(const URL: String): Boolean; |
| 131 |
var |
| 132 |
i: Integer; |
| 133 |
RStart: Integer; |
| 134 |
RLength: Integer; |
| 135 |
EsqURL: String; |
| 136 |
begin |
| 137 |
Result := False; |
| 138 |
ExecuteTimer.Interval := 0; |
| 139 |
ExecuteTimer.Enabled := False; |
| 140 |
FExecCommand := nil; |
| 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; |
| 151 |
break; |
| 152 |
end; |
| 153 |
end; |
| 154 |
end; |
| 155 |
end; |
| 156 |
|
| 157 |
procedure TExtPreviewDM.ExecuteTimerTimer(Sender: TObject); |
| 158 |
var |
| 159 |
rc: Integer; |
| 160 |
begin |
| 161 |
// ?^?C?}?[?但?~ |
| 162 |
ExecuteTimer.Interval := 0; |
| 163 |
ExecuteTimer.Enabled := False; |
| 164 |
|
| 165 |
if (FExecCommand <> nil) then begin |
| 166 |
rc := ID_YES; |
| 167 |
if (FExecCommand.Confirm) then begin |
| 168 |
// Msg |
| 169 |
rc := GikoUtil.MsgBox(0, FExecCommand.Command + '??'#13#10 + |
| 170 |
FExecCommand.ToURL + ' ???n?直???????H', |
| 171 |
'?m?F', MB_ICONQUESTION or MB_YESNO); |
| 172 |
end; |
| 173 |
|
| 174 |
if (rc = ID_YES) then begin |
| 175 |
// ?????R?}???h |
| 176 |
// nop ?????直???? |
| 177 |
if (AnsiLowerCase(FExecCommand.Command) <> 'nop') then begin |
| 178 |
GikoSys.CreateProcess( |
| 179 |
FExecCommand.Command, '"' + FExecCommand.ToURL + '"'); |
| 180 |
end; |
| 181 |
end; |
| 182 |
end; |
| 183 |
end; |
| 184 |
|
| 185 |
end. |
| |