]> git.lyx.org Git - features.git/blobdiff - development/Win32/packaging/installer/include/detection.nsh
Consider inset strings in simple find/replaceAll (#12049)
[features.git] / development / Win32 / packaging / installer / include / detection.nsh
index d0763026780d683883d5b4aa2d64750ccbf66c9c..01c44ff616f572808c784a57ced4f372061c1933 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
 
 detection.nsh
 
@@ -24,13 +24,11 @@ Detection of external component locations
 #
 #--------------------------
 
-#Var ReportReturn
-#Var CommandLineOutput
-
 Function SearchExternal
   Call LaTeXActions # function from LaTeX.nsh
   Call MissingPrograms
-  Call FindDictionaries
+  SetRegView ${APP_VERSION_ACHITECHTURE}
+  Call FindDictionaries # function from dictionaries.nsh
 FunctionEnd
 
 # ---------------------------------------
@@ -43,6 +41,7 @@ Function MissingPrograms
   # 2. 64bit Windows but 32bit Ghostscript
   # 3. 64bit Windows and 64bit Ghostscript
   StrCpy $3 0
+  StrCpy $4 "0"
   ${if} ${RunningX64}
    SetRegView 64
   ${endif}
@@ -73,7 +72,11 @@ Function MissingPrograms
   ${if} ${RunningX64}
   ${andif} $GhostscriptPath == ""
    StrCpy $3 0
-   goto GSloop
+   # we have to assure that we only repeat once and not forever
+   ${if} $4 != "32"
+    StrCpy $4 "32"
+    goto GSloop
+   ${endif}
   ${endif}
 
   # test if Python is installed
@@ -93,14 +96,9 @@ Function MissingPrograms
    StrCpy $DelPythonFiles "True"
   ${endif}
   
-  # test if Acrobat or Adobe Reader is used as PDF-viewer
-  ReadRegStr $String HKCR ".pdf" ""
-  ${if} $String != "AcroExch.Document" # this name is only used by Acrobat and Adobe Reader
-   StrCpy $Acrobat "None"
-  ${else}
-   StrCpy $Acrobat "Yes"
-  ${endif}
-
+  # No test necessary for Acrobat or Adobe Reader because pdfview does this job
+  # each time it is called.
+  
   # test if a PostScript-viewer is installed, only check for GSview
   # check all cases:
   # 1. 32bit Windows
@@ -129,6 +127,7 @@ Function MissingPrograms
   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-2_is1" "InstallLocation"
   ${if} $ImageEditorPath != ""
    StrCpy $ImageEditorPath "$ImageEditorPathbin" # add the bin folder
+   StrCpy $ImageEditor "Gimp"
   ${endif}
   ${if} ${RunningX64}
    SetRegView 32
@@ -143,30 +142,64 @@ Function MissingPrograms
    ${else}
     StrCpy $ImageEditorPath $0
    ${endif}
+   StrCpy $ImageEditor "Photoshop"
   ${endif}
-  
+  # check for Krita
+  ${if} ${RunningX64}
+   SetRegView 64
+  ${endif}
+  ReadRegStr $0 HKLM "SOFTWARE\Classes\Krita.Document\shell\open\command" ""
+  ${if} $0 != ""
+   StrCpy $0 "$0" -16 # delete '\krita.exe" "%1"'
+   StrCpy $0 $0 "" 1 # remove the leading quote
+   ${if} $ImageEditorPath != ""
+    StrCpy $ImageEditorPath "$ImageEditorPath;$0"
+   ${else}
+    StrCpy $ImageEditorPath $0
+   ${endif}
+   StrCpy $ImageEditor "Krita"
+  ${endif}
+  ${if} ${RunningX64}
+   SetRegView 32
+  ${endif}
+
   # test if and where the BibTeX-editor JabRef is installed
-  ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
+  ${if} ${RunningX64}
+   SetRegView 64
+  ${endif}
+  ReadRegStr $PathBibTeXEditor HKLM "SOFTWARE\JabRef" "Path"
+  # if not installed as admin, check for user
   ${if} $PathBibTeXEditor == ""
-   ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
+   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
+  ${endif}
+  ${if} ${RunningX64}
+   SetRegView 32
   ${endif}
 
-  ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
-    StrCpy $PathBibTeXEditor ""
-    StrCpy $JabRefInstalled == "No"
+  ${ifnot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
+   StrCpy $PathBibTeXEditor ""
+   StrCpy $JabRefInstalled == "No"
   ${else}
    StrCpy $JabRefInstalled == "Yes"
   ${endif}
-  
+
   # test if and where LilyPond is installed
   ReadRegStr $LilyPondPath HKLM "Software\LilyPond" "Install_Dir"
   ${if} $LilyPondPath != ""
    StrCpy $LilyPondPath "$LilyPondPath\usr\bin" # add "\usr\bin"
   ${endif}
-  
+
   # test if Inkscape is installed
-  ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
-  
+  ReadRegStr $SVGPath HKLM "SOFTWARE\Classes\inkscape.svg\DefaultIcon" ""
+  ${if} $SVGPath != ""
+   StrCpy $SVGPath $SVGPath "" 1 # remove the leading quote
+   StrCpy $SVGPath $SVGPath -14 # # delete '\inkscape.exe"'
+  ${endif}
+  ${if} $SVGPath == ""
+   # this was used before Inkscape 0.91:
+   ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
+  ${endif}
+
   # test if Gnumeric is installed
   ReadRegStr $0 HKLM "Software\Classes\Applications\gnumeric.exe\shell\Open\command" ""
   ${if} $0 != ""
@@ -175,48 +208,25 @@ Function MissingPrograms
    StrCpy $GnumericPath $0
   ${endif}
 
-FunctionEnd
-
-# ---------------------------------------
-
-Function FindDictionaries
-  # find the installed dictionaries
-
-  # start with empty strings
-  StrCpy $FoundDict ""
-  StrCpy $FoundThes ""
-  
-  # read out the possible spell-checker filenames from the file        
-  FileOpen $R5 "$INSTDIR\Resources\HunspellDictionaryNames.txt" r
-  ${for} $5 1 66
-   # the file has 132 lines, but we only need to check for one of the 2 dictionary files per language
-   # therefore check only for every second line
-   FileRead $R5 $String   # skip the .aff file
-   FileRead $R5 $String   # $String is now the .dic filename
-   StrCpy $String $String -2 # remove the linebreak characters
-   StrCpy $R3 $String -4 # $R3 is now the dictionary language code
-   !insertmacro FileCheck $4 $String "$INSTDIR\Resources\dicts" # macro from LyXUtils.nsh
-   ${if} $4 == "True"
-    StrCpy $FoundDict "$R3 $FoundDict"
-   ${endif}
-  ${next}
-  FileClose $R5
-  
-  # read out the possible thesaurus filenames from the file    
-  FileOpen $R5 "$INSTDIR\Resources\ThesaurusDictionaryNames.txt" r
-  ${for} $5 1 22
-   # the file has 44 lines, but we only need to check for one of the 2 dictionary files per language
-   # therefore check only for every second line
-   FileRead $R5 $String   # $String is now the dictionary name
-   FileRead $R5 $String   # $String is now the dictionary name
-   StrCpy $String $String -2 # remove the linebreak characters
-   StrCpy $R3 $String 5 3 # $R3 is now the dictionary language code
-   !insertmacro FileCheck $4 $String "$INSTDIR\Resources\thes" # macro from LyXUtils.nsh
-   ${if} $4 == "True"
-    StrCpy $FoundThes "$R3 $FoundThes"
-   ${endif}
-  ${next}
-  FileClose $R5
+  # test if Pandoc is installed
+  # HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\John MacFarlane\Pandoc
+  ${if} ${RunningX64}
+   SetRegView 64 # the PATH is in the 64bit registry section
+  ${endif}
+  # check for the path to the pandoc.exe in Window's PATH variable
+  StrCpy $5 ""
+  StrCpy $Search "pandoc"
+  ReadRegStr $String HKCU "Environment" "PATH"
+  !insertmacro PATHCheck $5 "pandoc.exe" # macro from LyXUtils.nsh
+  # if it is not in the user-specific PATH it might be in the global PATH
+  ${if} $5 == "False"
+   ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
+   !insertmacro PATHCheck $5 "pandoc.exe" # macro from LyXUtils.nsh
+  ${endif}
+  SetRegView 32
+  ${if} $5 != "False"
+   StrCpy $PandocPath $5
+  ${endif}
 
 FunctionEnd
 
@@ -278,8 +288,10 @@ Function EditorCheck
   ${else}
    SetRegView 32
    ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
-   StrCpy $0 $0 -1 # remove the "\"
-   StrCpy $EditorPath "$EditorPath;$0"
+   ${if} $0 != ""
+    StrCpy $0 $0 -1 # remove the "\"
+    StrCpy $EditorPath "$EditorPath;$0"
+   ${endif}
   ${endif}
   SetRegView 32