procedure UpdateScriptConversationColor(const Script: String);
procedure UpdateScriptScript(const Script: String);
procedure mnURLClick(Sender: TObject);
- procedure ExtractURLs(Script: String; Result: TStrings);
+ function ExtractURLs(Script: String; Urls: TStrings; Labels: TStrings): Boolean;
function GetDefaultFileName(const Name: String; const Ext: String): String;
function BottleLogTitled(const LogName: String): TBottleLogList;
procedure DrawSingleLineScript(LogItem: TLogItem; Rect: TRect;
var Log: TLogItem;
Child: TMenuItem;
Urls: TStringList;
+ Labels: TStringList;
+ ProcessedUrl: String;
+ ProcessedLabel: String;
i: integer;
begin
for i := mnJumpURL.Count-1 downto 0 do begin
Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
if Log = nil then Exit;
Urls := TStringList.Create;
+ Labels := TStringList.Create;
try
- ExtractURLs(Log.Script, Urls);
+ ExtractURLs(Log.Script, Urls, Labels);
for i := 0 to Urls.Count-1 do begin
Child := TMenuItem.Create(Self);
with Child do begin
- Caption := Format('(&%d) %s', [i+1, StringReplace(Urls[i], '&', '&&', [rfReplaceAll])]);
+ ProcessedUrl := StringReplace(Urls[i], '&', '&&', [rfReplaceAll]);
+ ProcessedLabel := StringReplace(Labels[i], '&', '&&', [rfReplaceAll]);
+ if Length(ProcessedLabel) > 0 then begin
+ Caption := Format('[%s] %s (&%d)', [ProcessedLabel, ProcessedUrl, i+1]);
+ end else begin
+ Caption := Format('%s (&%d)', [ProcessedUrl, i+1]);
+ end;
Tag := i;
OnClick := mnURLClick;
AutoHotkeys := maManual;
mnJumpURL.Enabled := Urls.Count > 0;
finally
Urls.Free;
+ Labels.Free;
end;
end;
LogItem := SelectedBottleLog[lvwLog.Selected.Index] as TLogItem;
Urls := TStringList.Create;
try
- ExtractURLs(LogItem.Script, Urls);
+ ExtractURLs(LogItem.Script, Urls, nil);
URL := Urls[(Sender as TMenuItem).Tag];
OpenBrowser(URL);
finally
end;
end;
-procedure TfrmLog.ExtractURLs(Script: String; Result: TStrings);
-var i, u, j: integer;
+function TfrmLog.ExtractURLs(Script: String; Urls: TStrings; Labels: TStrings): Boolean;
+var i, u, j, count: integer;
s: String;
begin
- Result.Clear;
+ count := 0;
SsParser.InputString := Script;
SsParser.LeaveEscape := true;
for i := 0 to SsParser.Count-1 do begin
'-', '%b', [rfReplaceAll]))) > 0 then begin
for j := 1 to u do begin
s := SsParser.GetParam(SsParser[i], j*2);
- if Pos('http://', s) > 0 then Result.Add(s);
+ if Pos('http://', s) > 0 then begin
+ if Urls <> nil then Urls.Add(s);
+ count := count + 1;
+ end;
+ if Labels <> nil then begin
+ s := SsParser.GetParam(SsParser[i], j*2+1);
+ Labels.Add(s);
+ end;
end;
Break;
end;
end;
- if SsParser.Match(SsParser[i], '\URL%b%b') = 0 then begin //\8aÈ\88Õ\94ÅURL\95Ï\8a·
+ if SsParser.Match(SsParser[i], '\URL%b%b') = 0 then begin
//\8aÈ\88Õ\8c`\8e®\URL\83^\83O\95Ï\8a·
s := SsParser.GetParam(SsParser[i], 1);
- if Pos('http://', s) > 0 then Result.Add(s);
+ if Pos('http://', s) > 0 then begin
+ if Urls <> nil then Urls.Add(s);
+ count := count + 1;
+ end
end;
end;
end;
+
+ //\83\89\83x\83\8b\82Ì\90\94\82ðURL\82Ì\90\94\82É\82 \82í\82¹\82é - \82¢\82¿\82¢\82¿\94»\92è\82µ\82È\82\82Ä\82à\82¢\82¢\82æ\82¤\82É
+ if Urls <> nil then begin
+ if Labels <> nil then begin
+ while Urls.Count > Labels.Count do Labels.Add('');
+ end;
+ end;
+ Result := count > 0;
end;
procedure TfrmLog.SelAndFocusMessage(const MID: String);
Ico: TIcon;
sub, Ex: integer;
Bottle: TLogItem;
- DummyStr: TStringList;
begin
Bottle := SelectedBottleLog.Bottles[Item.Index];
if Bottle.HasURL = huUndefined then
begin
- DummyStr := TStringList.Create;
try
- ExtractURLs(Bottle.Script, DummyStr);
- if DummyStr.Count > 0 then
+ if ExtractURLs(Bottle.Script, nil, nil) then
Bottle.HasURL := huYes
else
Bottle.HasURL := huNo;
finally
- DummyStr.Free;
+
end;
end;