OSDN Git Service

URLジャンプメニューに選択肢名も表示するようにした
authorC.Ponapalt <ponapalt@shillest.net>
Thu, 14 Jul 2005 15:58:43 +0000 (15:58 +0000)
committerC.Ponapalt <ponapalt@shillest.net>
Thu, 14 Jul 2005 15:58:43 +0000 (15:58 +0000)
診断用にバージョン情報ダイアログにIndyのバージョンも追加

bottleclient/LogForm.pas
bottleclient/MainForm.pas

index 010fbd9..9bb3696 100755 (executable)
@@ -145,7 +145,7 @@ type
     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;
@@ -641,6 +641,9 @@ procedure TfrmLog.PopupMenuListViewPopup(Sender: TObject);
 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
@@ -651,12 +654,19 @@ 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;
@@ -666,6 +676,7 @@ begin
     mnJumpURL.Enabled := Urls.Count > 0;
   finally
     Urls.Free;
+    Labels.Free;
   end;
 end;
 
@@ -679,7 +690,7 @@ begin
   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
@@ -687,11 +698,11 @@ begin
   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
@@ -704,18 +715,36 @@ 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);
@@ -1160,20 +1189,17 @@ var
   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;
 
index 6c077b2..1803fb7 100755 (executable)
@@ -969,10 +969,12 @@ begin
 end;
 
 procedure TfrmSender.actAboutClick(Sender: TObject);
-var Str: String;
+var
+  Str: String;
 begin
   Str := VersionString + #13#10 + BottleDisclaimer + #13#10#13#10;
-  Str := Str + Format('Compiler Version: %f', [CompilerVersion]);
+  Str := Str + Format('Compiler Version: %f', [CompilerVersion]) + #13#10;
+  Str := Str + 'Indy Version: ' + IdSLPP20.Version;
   frmMessageBox.ShowMessage(Str);
 end;