diff --git a/.gitignore b/.gitignore index 7b420ff..5ec2528 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ LiteXL* !resources/windows/*.diff !resources/windows/*.exe.manifest.in !resources/macos/*.py +!scripts/innosetup/lite-xl@*.bmp +!scripts/innosetup/lite-xl-banner@*.bmp diff --git a/scripts/innosetup/innosetup.iss.in b/scripts/innosetup/innosetup.iss.in index d2d8fbf..98ba798 100644 --- a/scripts/innosetup/innosetup.iss.in +++ b/scripts/innosetup/innosetup.iss.in @@ -9,7 +9,7 @@ ; Use /dArch option to create a setup for a different architecture, e.g.: ; iscc /dArch=x86 innosetup.iss #ifndef Arch - #define Arch "x64" + #define Arch "x64compatible" #endif [Setup] @@ -26,24 +26,26 @@ AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} -#if Arch=="x86" +#if Pos("x86", Arch) != 0 #define ArchInternal "i686" #else ArchitecturesAllowed={#Arch} ArchitecturesInstallIn64BitMode={#Arch} - #if Arch=="x64" + #if Pos("x64", Arch) != 0 #define ArchInternal "x86_64" - #elif Arch=="arm64" + #elif Pos("arm64", Arch) != 0 #define ArchInternal "aarch64" #endif #endif AllowNoIcons=yes -Compression=lzma +Compression=lzma2 SolidCompression=yes DefaultDirName={autopf}/{#MyAppName} DefaultGroupName={#MyAppPublisher} UninstallFilesDir={app} +WizardStyle=modern +AlwaysShowDirOnReadyPage=yes ; Uncomment the following line to run in non administrative install mode ; (install for current user only.) @@ -56,21 +58,45 @@ UsedUserAreasWarning=no OutputDir=. OutputBaseFilename=LiteXL-{#MyAppVersion}-{#ArchInternal}-setup -;DisableDirPage=yes +DisableDirPage=no ;DisableProgramGroupPage=yes LicenseFile={#SourceDir}/LICENSE SetupIconFile={#SourceDir}/resources/icons/icon.ico -WizardImageFile="{#SourceDir}/scripts/innosetup/wizard-modern-image.bmp" -WizardSmallImageFile="{#SourceDir}/scripts/innosetup/litexl-55px.bmp" +UninstallDisplayIcon={app}\{#MyAppExeName}, 0 + +; Get a list of icons for different DPIs +#define WizardIconPath = SourceDir + "/scripts/innosetup/" +#define FinalIconPath "" +#define FindHandle +#define FindResult +#for {FindHandle = FindResult = FindFirst(WizardIconPath + "lite-xl@*.bmp", 0); FindResult; FindResult = FindNext(FindHandle)} \ + Insert(FinalIconPath, 0, WizardIconPath + FindGetFileName(FindHandle) + ",") +#if FindHandle + #expr FindClose(FindHandle) +#endif +WizardSmallImageFile="{#FinalIconPath}" + +; Get a list of banners for different DPIs (FIXME: figure out how to reuse this code?) +#define FinalBannerPath "" +#for {FindHandle = FindResult = FindFirst(WizardIconPath + "lite-xl-banner@*.bmp", 0); FindResult; FindResult = FindNext(FindHandle)} \ + Insert(FinalBannerPath, 0, WizardIconPath + FindGetFileName(FindHandle) + ",") +#if FindHandle + #expr FindClose(FindHandle) +#endif +WizardImageFile="{#FinalBannerPath}" + +; Required for the add to path option to refresh environment +ChangesEnvironment=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked -Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode -Name: "portablemode"; Description: "Portable Mode"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.2; Check: not IsAdminInstallMode +Name: "portablemode"; Description: "Extract only, do not install"; Flags: unchecked +Name: "envPath"; Description: "Add Lite XL to PATH"; Flags: unchecked [Files] Source: "{#SourceDir}/lite-xl/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs @@ -83,8 +109,91 @@ Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; Check: not WizardIsTaskSelected('portablemode') ; Name: "{usersendto}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +[Registry] +Root: "HKA"; Subkey: "Software\Classes\*\shell\{#MyAppName}"; ValueType: string; ValueName: ""; ValueData: "Open with {#MyAppName}"; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\*\shell\{#MyAppName}"; ValueType: string; ValueName: "Icon"; ValueData: "{app}\{#MyAppExeName}, 0"; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\*\shell\{#MyAppName}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExename}"" ""%1"""; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\directory\shell\{#MyAppName}"; ValueType: string; ValueName: ""; ValueData: "Open with {#MyAppName}"; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\directory\shell\{#MyAppName}"; ValueType: string; ValueName: "Icon"; ValueData: "{app}\{#MyAppExeName}, 0"; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\directory\shell\{#MyAppName}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExename}"" ""%1"""; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\directory\background\shell\{#MyAppName}"; ValueType: string; ValueName: ""; ValueData: "Open with {#MyAppName}"; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\directory\background\shell\{#MyAppName}"; ValueType: string; ValueName: "Icon"; ValueData: "{app}\{#MyAppExeName}, 0"; Flags: uninsdeletekey +Root: "HKA"; Subkey: "Software\Classes\directory\background\shell\{#MyAppName}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExename}"" ""%V"""; Flags: uninsdeletekey + [Run] Filename: "{app}/{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Setup] Uninstallable=not WizardIsTaskSelected('portablemode') + +; Code to add installation path to environment taken from: +; https://stackoverflow.com/a/46609047 +[Code] +const SystemKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; +const UserKey = 'Environment'; +const SystemHive = HKEY_LOCAL_MACHINE; +const UserHive = HKEY_CURRENT_USER; + +procedure EnvAddPath(Path: string); +var + SystemPath: string; + UserPath: string; + R: boolean; +begin + { Retrieve user and system PATH } + if not RegQueryStringValue(SystemHive, SystemKey, 'Path', SystemPath) + then SystemPath := ''; + if not RegQueryStringValue(UserHive, UserKey, 'Path', UserPath) + then UserPath := ''; + + { Skip if the string is found in user / system path } + if Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(UserPath) + ';' + Uppercase(SystemPath) + ';') > 0 then exit; + + { Add the environment variable to user or system PATH depending on installation mode } + if IsAdminInstallMode() then R := RegWriteStringValue(SystemHive, SystemKey, 'Path', SystemPath + ';' + Path + ';') + else R := RegWriteStringValue(UserHive, UserKey, 'Path', UserPath + ';' + Path + ';'); + + { Log any issues } + if R then Log(Path + ' is added to PATH') + else Log('Cannot add ' + Path + ' to PATH'); +end; + +procedure EnvRemovePath(Path: string); +var + RegKeys: array of string; + RegHives: array of integer; + Paths: string; + I: integer; + P: integer; +begin + { During uninstallation, we always have administrator privileges } + RegKeys := [SystemKey, UserKey]; + RegHives := [SystemHive, UserHive]; + { Remove the path from both user and system PATH } + for I := 0 to Length(RegKeys) - 1 do + begin + { Skip if registry key doesn't exist } + if not RegQueryStringValue(RegHives[I], RegKeys[I], 'Path', Paths) then continue; + { Skip if path is not in PATH } + P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';'); + if p = 0 then continue; + { Remove string from PATH } + Delete(Paths, P - 1, Length(Path) + 1); + { Write to the environment variable } + if RegWriteStringValue(RegHives[I], RegKeys[I], 'Path', Paths) + then Log(Path + ' is removed from PATH') + else Log('Error removing ' + Path + ' from PATH'); + end; +end; + +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep = ssPostInstall) and WizardIsTaskSelected('envPath') + then EnvAddPath(ExpandConstant('{app}')); +end; + +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +begin + if CurUninstallStep = usPostUninstall + then EnvRemovePath(ExpandConstant('{app}')); +end; diff --git a/scripts/innosetup/innosetup.sh b/scripts/innosetup/innosetup.sh index 86ab89d..0c32055 100644 --- a/scripts/innosetup/innosetup.sh +++ b/scripts/innosetup/innosetup.sh @@ -31,11 +31,11 @@ main() { case "$MSYSTEM" in MINGW64|UCRT64|CLANG64) - arch=x64 + arch=x64compatible arch_file=x86_64 ;; MINGW32|CLANG32) - arch=x86 + arch=x86compatible arch_file=i686 ;; CLANGARM64) diff --git a/scripts/innosetup/lite-xl-banner@164x314.bmp b/scripts/innosetup/lite-xl-banner@164x314.bmp new file mode 100644 index 0000000..ba93404 Binary files /dev/null and b/scripts/innosetup/lite-xl-banner@164x314.bmp differ diff --git a/scripts/innosetup/lite-xl-banner@192x386.bmp b/scripts/innosetup/lite-xl-banner@192x386.bmp new file mode 100644 index 0000000..46289c9 Binary files /dev/null and b/scripts/innosetup/lite-xl-banner@192x386.bmp differ diff --git a/scripts/innosetup/lite-xl-banner@246x459.bmp b/scripts/innosetup/lite-xl-banner@246x459.bmp new file mode 100644 index 0000000..66b0820 Binary files /dev/null and b/scripts/innosetup/lite-xl-banner@246x459.bmp differ diff --git a/scripts/innosetup/lite-xl-banner@273x556.bmp b/scripts/innosetup/lite-xl-banner@273x556.bmp new file mode 100644 index 0000000..19cf794 Binary files /dev/null and b/scripts/innosetup/lite-xl-banner@273x556.bmp differ diff --git a/scripts/innosetup/lite-xl-banner@328x604.bmp b/scripts/innosetup/lite-xl-banner@328x604.bmp new file mode 100644 index 0000000..9a953f9 Binary files /dev/null and b/scripts/innosetup/lite-xl-banner@328x604.bmp differ diff --git a/scripts/innosetup/lite-xl@110x106.bmp b/scripts/innosetup/lite-xl@110x106.bmp new file mode 100644 index 0000000..7932a7a Binary files /dev/null and b/scripts/innosetup/lite-xl@110x106.bmp differ diff --git a/scripts/innosetup/lite-xl@55x55.bmp b/scripts/innosetup/lite-xl@55x55.bmp new file mode 100644 index 0000000..9d8190b Binary files /dev/null and b/scripts/innosetup/lite-xl@55x55.bmp differ diff --git a/scripts/innosetup/lite-xl@64x68.bmp b/scripts/innosetup/lite-xl@64x68.bmp new file mode 100644 index 0000000..fc0dcd5 Binary files /dev/null and b/scripts/innosetup/lite-xl@64x68.bmp differ diff --git a/scripts/innosetup/lite-xl@83x80.bmp b/scripts/innosetup/lite-xl@83x80.bmp new file mode 100644 index 0000000..0e067de Binary files /dev/null and b/scripts/innosetup/lite-xl@83x80.bmp differ diff --git a/scripts/innosetup/lite-xl@92x97.bmp b/scripts/innosetup/lite-xl@92x97.bmp new file mode 100644 index 0000000..ec00ef5 Binary files /dev/null and b/scripts/innosetup/lite-xl@92x97.bmp differ diff --git a/scripts/innosetup/litexl-55px.bmp b/scripts/innosetup/litexl-55px.bmp deleted file mode 100644 index d3424a9..0000000 Binary files a/scripts/innosetup/litexl-55px.bmp and /dev/null differ diff --git a/scripts/innosetup/wizard-modern-image.bmp b/scripts/innosetup/wizard-modern-image.bmp deleted file mode 100644 index cf844e0..0000000 Binary files a/scripts/innosetup/wizard-modern-image.bmp and /dev/null differ