Browse Source

Merge branch 'main' into msgbox-designer

# Conflicts:
#	Projects/CompForm.pas
#	Projects/Compil32.dproj
Martijn Laan 5 years ago
parent
commit
7dc6671ac4

+ 1 - 1
Projects/CompForm.dfm

@@ -339,7 +339,7 @@ object CompileForm: TCompileForm
       object N1: TMenuItem
         Caption = '-'
       end
-      object FMRUSep: TMenuItem
+      object FMRUFilesSep: TMenuItem
         Caption = '-'
         Visible = False
       end

+ 86 - 51
Projects/CompForm.pas

@@ -54,6 +54,8 @@ type
 
   TStatusMessageKind = (smkStartEnd, smkNormal, smkWarning, smkError);
 
+  TMRUItemCompareProc = function(const S1, S2: String): Integer;
+
   TCompileForm = class(TUIStateForm)
     MainMenu1: TMainMenu;
     FMenu: TMenuItem;
@@ -82,7 +84,7 @@ type
     HDoc: TMenuItem;
     N6: TMenuItem;
     HAbout: TMenuItem;
-    FMRUSep: TMenuItem;
+    FMRUFilesSep: TMenuItem;
     VCompilerOutput: TMenuItem;
     FindDialog: TFindDialog;
     ReplaceDialog: TReplaceDialog;
@@ -272,8 +274,9 @@ type
     FFilename: String;
     FFileLastWriteTime: TFileTime;
     FSaveInUTF8Encoding: Boolean;
-    FMRUMenuItems: array[0..MRUListMaxCount-1] of TMenuItem;
-    FMRUList: TStringList;
+    FMRUFilesMenuItems: array[0..MRUListMaxCount-1] of TMenuItem;
+    FMRUFilesList: TStringList;
+    FMRUParametersList: TStringList;
     FOptions: record
       ShowStartupForm: Boolean;
       UseWizard: Boolean;
@@ -376,14 +379,19 @@ type
       Line: Integer);
     procedure MemoModifiedChange(Sender: TObject);
     procedure MemoUpdateUI(Sender: TObject);
-    procedure ModifyMRUList(const AFilename: String; const AddNewItem: Boolean);
+    procedure ModifyMRUList(const MRUList: TStringList; const Section, Ident: String;
+      const AItem: String; const AddNewItem: Boolean; CompareProc: TMRUItemCompareProc);
+    procedure ModifyMRUFilesList(const AFilename: String; const AddNewItem: Boolean);
+    procedure ModifyMRUParametersList(const AParameter: String; const AddNewItem: Boolean);
     procedure MoveCaret(const LineNumber: Integer; const AlwaysResetColumn: Boolean);
     procedure NewFile;
     procedure NewWizardFile;
     procedure OpenFile(AFilename: String; const AddToRecentDocs: Boolean);
     procedure OpenMRUFile(const AFilename: String);
     procedure ParseDebugInfo(DebugInfo: Pointer);
-    procedure ReadMRUList;
+    procedure ReadMRUList(const MRUList: TStringList; const Section, Ident: String);
+    procedure ReadMRUFilesList;
+    procedure ReadMRUParametersList;
     procedure ResetLineState;
     procedure StartProcess;
     function SaveFile(const SaveAs: Boolean): Boolean;
@@ -473,7 +481,7 @@ uses
   PathFunc, CmnFunc, CmnFunc2, FileClass, CompMsgs, TmSchema, BrowseFunc,
   HtmlHelpFunc, TaskbarProgressFunc,
   {$IFDEF STATICCOMPILER} Compile, {$ENDIF}
-  CompOptions, CompStartup, CompWizard, CompSignTools, CompTypes, MessageBoxInsert;
+  CompOptions, CompStartup, CompWizard, CompSignTools, CompTypes, CompInputQueryCombo, MessageBoxInsert;
 
 {$R *.DFM}
 
@@ -965,13 +973,14 @@ begin
   Application.OnActivate := AppOnActivate;
   Application.OnIdle := AppOnIdle;
 
-  FMRUList := TStringList.Create;
-  for I := 0 to High(FMRUMenuItems) do begin
+  FMRUFilesList := TStringList.Create;
+  for I := 0 to High(FMRUFilesMenuItems) do begin
     NewItem := TMenuItem.Create(Self);
     NewItem.OnClick := FMRUClick;
-    FMenu.Insert(FMenu.IndexOf(FMRUSep), NewItem);
-    FMRUMenuItems[I] := NewItem;
+    FMenu.Insert(FMenu.IndexOf(FMRUFilesSep), NewItem);
+    FMRUFilesMenuItems[I] := NewItem;
   end;
+  FMRUParametersList := TStringList.Create;
 
   FSignTools := TStringList.Create;
 
@@ -1044,8 +1053,9 @@ begin
   FBreakPoints.Free;
   DestroyDebugInfo;
   FSignTools.Free;
-  FMRUList.Free;
- 
+  FMRUParametersList.Free;
+  FMRUFilesList.Free;
+
   inherited;
 end;
 
@@ -1261,7 +1271,7 @@ begin
   Memo.ClearUndo;
   FFilename := AFilename;
   UpdateCaption;
-  ModifyMRUList(AFilename, True);
+  ModifyMRUFilesList(AFilename, True);
   if AddToRecentDocs then
     AddFileToRecentDocs(AFilename);
 end;
@@ -1276,7 +1286,7 @@ begin
     Application.HandleException(Self);
     if MsgBoxFmt('There was an error opening the file. Remove it from the list?',
        [AFilename], SCompilerFormCaption, mbError, MB_YESNO) = IDYES then
-      ModifyMRUList(AFilename, False);
+      ModifyMRUFilesList(AFilename, False);
   end;
 end;
 
@@ -1372,7 +1382,7 @@ begin
   if not FOptions.UndoAfterSave then
     Memo.ClearUndo;
   Result := True;
-  ModifyMRUList(FFilename, True);
+  ModifyMRUFilesList(FFilename, True);
 end;
 
 function TCompileForm.ConfirmCloseFile(const PromptToSave: Boolean): Boolean;
@@ -1404,8 +1414,8 @@ begin
   end;
 end;
 
-procedure TCompileForm.ReadMRUList;
-{ Loads the list of MRU items from the registry }
+procedure TCompileForm.ReadMRUList(const MRUList: TStringList; const Section, Ident: String);
+{ Loads a list of MRU items from the registry }
 var
   Ini: TConfigIniFile;
   I: Integer;
@@ -1414,53 +1424,49 @@ begin
   try
     Ini := TConfigIniFile.Create;
     try
-      FMRUList.Clear;
-      for I := 0 to High(FMRUMenuItems) do begin
-        S := Ini.ReadString('ScriptFileHistoryNew', 'History' + IntToStr(I), '');
-        if S <> '' then FMRUList.Add(S);
+      MRUList.Clear;
+      for I := 0 to MRUListMaxCount-1 do begin
+        S := Ini.ReadString(Section, Ident + IntToStr(I), '');
+        if S <> '' then MRUList.Add(S);
       end;
     finally
       Ini.Free;
     end;
   except
-    { Ignore any exceptions; don't want to hold up the display of the
-      File menu. }
+    { Ignore any exceptions. }
   end;
 end;
 
-procedure TCompileForm.ModifyMRUList(const AFilename: String;
-  const AddNewItem: Boolean);
+procedure TCompileForm.ModifyMRUList(const MRUList: TStringList; const Section, Ident: String;
+  const AItem: String; const AddNewItem: Boolean; CompareProc: TMRUItemCompareProc);
 var
   I: Integer;
   Ini: TConfigIniFile;
   S: String;
 begin
   try
-    { Load most recent items first, just in case they've changed }
-    ReadMRUList;
-
     I := 0;
-    while I < FMRUList.Count do begin
-      if PathCompare(FMRUList[I], AFilename) = 0 then
-        FMRUList.Delete(I)
+    while I < MRUList.Count do begin
+      if CompareProc(MRUList[I], AItem) = 0 then
+        MRUList.Delete(I)
       else
         Inc(I);
     end;
     if AddNewItem then
-      FMRUList.Insert(0, AFilename);
-    while FMRUList.Count > High(FMRUMenuItems)+1 do
-      FMRUList.Delete(FMRUList.Count-1);
+      MRUList.Insert(0, AItem);
+    while MRUList.Count > MRUListMaxCount do
+      MRUList.Delete(MRUList.Count-1);
 
     { Save new MRU items }
     Ini := TConfigIniFile.Create;
     try
       { MRU list }
-      for I := 0 to High(FMRUMenuItems) do begin
-        if I < FMRUList.Count then
-          S := FMRUList[I]
+      for I := 0 to MRUListMaxCount-1 do begin
+        if I < MRUList.Count then
+          S := MRUList[I]
         else
           S := '';
-        Ini.WriteString('ScriptFileHistoryNew', 'History' + IntToStr(I), S);
+        Ini.WriteString(Section, Ident + IntToStr(I), S);
       end;
     finally
       Ini.Free;
@@ -1472,6 +1478,32 @@ begin
   end;
 end;
 
+procedure TCompileForm.ReadMRUFilesList;
+begin
+  ReadMRUList(FMRUFilesList, 'ScriptFileHistoryNew', 'History');
+end;
+
+procedure TCompileForm.ModifyMRUFilesList(const AFilename: String;
+  const AddNewItem: Boolean);
+begin
+  { Load most recent items first, just in case they've changed }
+  ReadMRUFilesList;
+  ModifyMRUList(FMRUFilesList, 'ScriptFileHistoryNew', 'History', AFileName, AddNewItem, @PathCompare);
+end;
+
+procedure TCompileForm.ReadMRUParametersList;
+begin
+  ReadMRUList(FMRUParametersList, 'ParameterHistory', 'History');
+end;
+
+procedure TCompileForm.ModifyMRUParametersList(const AParameter: String;
+  const AddNewItem: Boolean);
+begin
+  { Load most recent items first, just in case they've changed }
+  ReadMRUParametersList;
+  ModifyMRUList(FMRUParametersList, 'ParameterHistory', 'History', AParameter, AddNewItem, @CompareText);
+end;
+
 type
   TAddLinesPrefix = (alpNone, alpTimestamp, alpCountdown);
 
@@ -1925,13 +1957,13 @@ var
 begin
   FSaveEncodingAuto.Checked := not FSaveInUTF8Encoding;
   FSaveEncodingUTF8.Checked := FSaveInUTF8Encoding;
-  ReadMRUList;
-  FMRUSep.Visible := FMRUList.Count <> 0;
-  for I := 0 to High(FMRUMenuItems) do
-    with FMRUMenuItems[I] do begin
-      if I < FMRUList.Count then begin
+  ReadMRUFilesList;
+  FMRUFilesSep.Visible := FMRUFilesList.Count <> 0;
+  for I := 0 to High(FMRUFilesMenuItems) do
+    with FMRUFilesMenuItems[I] do begin
+      if I < FMRUFilesList.Count then begin
         Visible := True;
-        Caption := '&' + IntToStr((I+1) mod 10) + ' ' + DoubleAmp(FMRUList[I]);
+        Caption := '&' + IntToStr((I+1) mod 10) + ' ' + DoubleAmp(FMRUFilesList[I]);
       end
       else
         Visible := False;
@@ -1992,9 +2024,9 @@ var
   I: Integer;
 begin
   if ConfirmCloseFile(True) then
-    for I := 0 to High(FMRUMenuItems) do
-      if FMRUMenuItems[I] = Sender then begin
-        OpenMRUFile(FMRUList[I]);
+    for I := 0 to High(FMRUFilesMenuItems) do
+      if FMRUFilesMenuItems[I] = Sender then begin
+        OpenMRUFile(FMRUFilesList[I]);
         Break;
       end;
 end;
@@ -2366,10 +2398,10 @@ procedure TCompileForm.WMStartNormally(var Message: TMessage);
     StartupForm: TStartupForm;
     Ini: TConfigIniFile;
   begin
-    ReadMRUList;
+    ReadMRUFilesList;
     StartupForm := TStartupForm.Create(Application);
     try
-      StartupForm.MRUList := FMRUList;
+      StartupForm.MRUFilesList := FMRUFilesList;
       StartupForm.StartupCheck.Checked := not FOptions.ShowStartupForm;
       if StartupForm.ShowModal = mrOK then begin
         if FOptions.ShowStartupForm <> not StartupForm.StartupCheck.Checked then begin
@@ -3876,8 +3908,11 @@ end;
 
 procedure TCompileForm.RParametersClick(Sender: TObject);
 begin
-  InputQuery('Run Parameters', 'Command line parameters for ' + DebugTargetStrings[dtSetup] +
-    ' and ' + DebugTargetStrings[dtUninstall] + ':', FRunParameters);
+  ReadMRUParametersList;
+  InputQueryCombo('Run Parameters', 'Command line parameters for ' + DebugTargetStrings[dtSetup] +
+    ' and ' + DebugTargetStrings[dtUninstall] + ':', FRunParameters, FMRUParametersList);
+  if FRunParameters <> '' then
+    ModifyMRUParametersList(FRunParameters, True);
 end;
 
 procedure TCompileForm.RPauseClick(Sender: TObject);

+ 62 - 0
Projects/CompInputQueryCombo.dfm

@@ -0,0 +1,62 @@
+object InputQueryCombo: TInputQueryCombo
+  Left = 330
+  Top = 188
+  BorderIcons = [biSystemMenu]
+  BorderStyle = bsDialog
+  Caption = '...'
+  ClientHeight = 73
+  ClientWidth = 582
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'MS Sans Serif'
+  Font.Style = []
+  OldCreateOrder = True
+  Position = poScreenCenter
+  OnCreate = FormCreate
+  DesignSize = (
+    582
+    73)
+  PixelsPerInch = 96
+  TextHeight = 13
+  object PromptLabel: TLabel
+    Left = 8
+    Top = 11
+    Width = 265
+    Height = 13
+    AutoSize = False
+    Caption = '...'
+    FocusControl = ValueComboBox
+  end
+  object OKButton: TButton
+    Left = 421
+    Top = 43
+    Width = 73
+    Height = 23
+    Anchors = [akRight, akBottom]
+    Caption = 'OK'
+    Default = True
+    ModalResult = 1
+    TabOrder = 0
+  end
+  object CancelButton: TButton
+    Left = 501
+    Top = 43
+    Width = 73
+    Height = 23
+    Anchors = [akRight, akBottom]
+    Cancel = True
+    Caption = 'Cancel'
+    ModalResult = 2
+    TabOrder = 1
+  end
+  object ValueComboBox: TComboBox
+    Left = 279
+    Top = 8
+    Width = 295
+    Height = 21
+    Anchors = [akLeft, akTop, akRight]
+    TabOrder = 2
+  end
+end

+ 86 - 0
Projects/CompInputQueryCombo.pas

@@ -0,0 +1,86 @@
+unit CompInputQueryCombo;
+
+{
+  Inno Setup
+  Copyright (C) 1997-2020 Jordan Russell
+  Portions by Martijn Laan
+  For conditions of distribution and use, see LICENSE.TXT.
+
+  InputQuery with a TComboBox instead of a TEdit
+}
+
+interface
+
+uses
+  Classes, Controls, StdCtrls, UIStateForm;
+
+type
+  TInputQueryCombo = class(TUIStateForm)
+    OKButton: TButton;
+    CancelButton: TButton;
+    PromptLabel: TLabel;
+    ValueComboBox: TComboBox;
+    procedure FormCreate(Sender: TObject);
+  private
+    function GetValue: String;
+    procedure SetPrompt(const APrompt: String);
+    procedure SetValue(const AValue: String);
+    procedure SetValues(const AValues: TStringList);
+  public
+    property Prompt: String write SetPrompt;
+    property Value: String read GetValue write SetValue;
+    property Values: TStringList write SetValues;
+  end;
+
+function InputQueryCombo(const ACaption, APrompt: String; var AValue: String; const AValues: TStringList): Boolean;
+
+implementation
+
+uses
+  Windows, Messages, CompForm, Forms;
+
+{$R *.DFM}
+
+function InputQueryCombo(const ACaption, APrompt: String; var AValue: String; const AValues: TStringList): Boolean;
+begin
+  with TInputQueryCombo.Create(Application) do try
+    Caption := ACaption;
+    Prompt := APrompt;
+    Value := AValue;
+    Values := AValues;
+    if ShowModal = mrOk then begin
+      AValue := Value;
+      Result := True;
+    end else
+      Result := False;
+  finally
+    Free;
+  end;
+end;
+
+procedure TInputQueryCombo.FormCreate(Sender: TObject);
+begin
+  InitFormFont(Self);
+end;
+
+function TInputQueryCombo.GetValue: String;
+begin
+  Result := ValueComboBox.Text;
+end;
+
+procedure TInputQueryCombo.SetPrompt(const APrompt: String);
+begin
+  PromptLabel.Caption := APrompt;
+end;
+
+procedure TInputQueryCombo.SetValue(const AValue: String);
+begin
+  ValueComboBox.Text := AValue;
+end;
+
+procedure TInputQueryCombo.SetValues(const AValues: TStringList);
+begin
+  ValueComboBox.Items := AValues;
+end;
+
+end.

+ 3 - 6
Projects/CompSignTools.pas

@@ -2,20 +2,17 @@ unit CompSignTools;
 
 {
   Inno Setup
-  Copyright (C) 1997-2010 Jordan Russell
+  Copyright (C) 1997-2020 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
   Compiler SignTools form
-
-  $jrsoftware: issrc/Projects/CompSignTools.pas,v 1.3 2010/03/24 18:34:14 mlaan Exp $
 }
 
 interface
 
 uses
-  Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
-  StdCtrls, UIStateForm;
+    Classes, Controls, StdCtrls, UIStateForm;
 
 type
   TSignToolsForm = class(TUIStateForm)
@@ -49,7 +46,7 @@ type
 implementation
 
 uses
-  CmnFunc, CompForm, SysUtils;
+  Windows, Messages, CompForm, CmnFunc, Dialogs, SysUtils;
 
 {$R *.DFM}
 

+ 4 - 7
Projects/CompStartup.pas

@@ -47,13 +47,13 @@ type
   private
     FResult: TStartupFormResult;
     FResultFileName: TFileName;
-    procedure SetMRUList(const MRUList: TStringList);
+    procedure SetMRUFilesList(const MRUFilesList: TStringList);
     procedure UpdateImages;
   protected
     procedure CreateWnd; override;
     procedure CreateParams(var Params: TCreateParams); override;
   public
-    property MRUList: TStringList write SetMRUList;
+    property MRUFilesList: TStringList write SetMRUFilesList;
     property Result: TStartupFormResult read FResult;
     property ResultFileName: TFileName read FResultFileName;
   end;
@@ -65,12 +65,9 @@ uses
 
 {$R *.DFM}
 
-procedure TStartupForm.SetMRUList(const MRUList: TStringList);
-var
-  I: Integer;
+procedure TStartupForm.SetMRUFilesList(const MRUFilesList: TStringList);
 begin
-  for I := 0 to MRUList.Count-1 do
-    OpenListBox.Items.Add(MRUList[I]);
+  OpenListBox.Items := MRUFilesList;
   UpdateHorizontalExtent(OpenListBox);
 end;
 

+ 1 - 0
Projects/Compil32.dpr

@@ -35,6 +35,7 @@ uses
   DebugStruct in 'DebugStruct.pas',
   BrowseFunc in 'BrowseFunc.pas',
   CompSignTools in 'CompSignTools.pas' {SignToolsForm},
+  CompInputQueryCombo in 'CompInputQueryCombo.pas' {InputQueryCombo},
   ScintInt in '..\Components\ScintInt.pas',
   ScintEdit in '..\Components\ScintEdit.pas',
   ScintStylerInnoSetup in '..\Components\ScintStylerInnoSetup.pas',

+ 3 - 0
Projects/Compil32.dproj

@@ -77,6 +77,9 @@
 			<DCCReference Include="CompSignTools.pas">
 				<Form>SignToolsForm</Form>
 			</DCCReference>
+			<DCCReference Include="CompInputQueryCombo.pas">
+				<Form>InputQueryCombo</Form>
+			</DCCReference>
 			<DCCReference Include="MessageBoxInsert.pas">
 				<Form>MBDForm</Form>
 			</DCCReference>

+ 3 - 2
whatsnew.htm

@@ -26,7 +26,7 @@ Portions Copyright &copy; 2000-2020 Martijn Laan. All rights reserved.<br />
 For conditions of distribution and use, see <a href="https://jrsoftware.org/files/is/license.txt">LICENSE.TXT</a>.
 </p>
 
-<p><b>Want to be notified by e-mail of updates?</b> Then <a href="https://jrsoftware.org/ismail.php">click here to subscribe</a> to the Inno Setup announcements mailing list.<br /><b>If you subscribed before October 2019, please resubscribe.</b></p>
+<p><b>Want to be notified by e-mail of  of new Inno Setup releases?</b> <a href="https://jrsoftware.org/ismail.php">Subscribe</a> to the Inno Setup Mailing List!<br /><b>If you subscribed before October 2019, please resubscribe.</b></p>
 
 <p><a name="6.1.0"></a><span class="ver">6.1.0-dev </span><span class="date">(?)</span></p>
 <p><span class="head2">Per-user fonts</span></p>
@@ -43,7 +43,8 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
 <p>Various improvements have been made to the Compiler IDE:</p>
 <ul>
   <li><a href="https://i.imgur.com/wHoJ3FG.png">Improved highlighting</a> for the [CustomMessages] and [Messages] sections.</li>
-  <li>Added buttons to the Welcome dialog to <a href="https://jrsoftware.org/isdonate.php">Donate</a> to support Inno Setup and to <a href="https://jrsoftware.org/ismail.php">Subscribe</a> to the Inno Setup Mailing List.</li>
+  <li>Added buttons to the Welcome dialog to <a href="https://jrsoftware.org/isdonate.php">Donate</a> to support Inno Setup (Thank you!) and to <a href="https://jrsoftware.org/ismail.php">Subscribe</a> to the Inno Setup Mailing List to be notified by e-mail of new Inno Setup releases.</li>
+  <li>The Run Parameters dialog now shows a list of most recently used parameters.</li>
 </ul>
 <p><span class="head2">Pascal Scripting ([Code] section) updates</span></p>
 <p>Pascal Scripting now supports SHA-256 hashes:</p>