Code clean up --- ensure that register state is not corrupted.

Add Uwe's code to check for the existence of PDF and PS viewers.
Spell Espa�ol correctly ;-)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@10086 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2005-06-18 20:35:58 +00:00
parent 6f70167cff
commit e3cc5f2795
2 changed files with 112 additions and 16 deletions

View File

@ -110,6 +110,12 @@ Var DoNotRequireImageMagick
Var ImageMagickPath Var ImageMagickPath
Var DownloadImageMagick Var DownloadImageMagick
Var PDFViewerPath
Var PDFViewerProg
Var PSViewerPath
Var PSViewerProg
Var DoNotInstallLyX Var DoNotInstallLyX
Var PathPrefix Var PathPrefix
@ -340,6 +346,8 @@ Function .onInit
Call SearchPerl Call SearchPerl
Call SearchGhostscript Call SearchGhostscript
Call SearchImageMagick Call SearchImageMagick
Call SearchPDFViewer
Call SearchPSViewer
ClearErrors ClearErrors
FunctionEnd FunctionEnd
@ -353,7 +361,15 @@ FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $MinSYSPath variable.
Function SearchMinSYS Function SearchMinSYS
; This function manipulates the $0, $1, $2 and $2 registers,
; so push their current content onto the stack.
Push $0
Push $1
Push $2
Push $3
; Search the registry for the MinSYS uninstaller. ; Search the registry for the MinSYS uninstaller.
; If successful, put its location in $2. ; If successful, put its location in $2.
StrCpy $3 "Software\Microsoft\Windows\CurrentVersion\Uninstall" StrCpy $3 "Software\Microsoft\Windows\CurrentVersion\Uninstall"
@ -382,6 +398,12 @@ Function SearchMinSYS
"Inno Setup: App Path" \ "Inno Setup: App Path" \
"" \ "" \
"\bin" "\bin"
; Return the $0, $1, $2 and $2 registers to their original state
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd FunctionEnd
Function DownloadMinSYS Function DownloadMinSYS
@ -397,6 +419,10 @@ Function DownloadMinSYS
FunctionEnd FunctionEnd
Function DownloadMinSYS_LeaveFunction Function DownloadMinSYS_LeaveFunction
; This function manipulates the $0 register
; so push its current content onto the stack.
Push $0
${DownloadLeave} \ ${DownloadLeave} \
$0 \ $0 \
$DownloadMinSYS \ $DownloadMinSYS \
@ -405,10 +431,14 @@ Function DownloadMinSYS_LeaveFunction
"$(EnterMinSYSFolder)" \ "$(EnterMinSYSFolder)" \
"sh.exe" \ "sh.exe" \
"$(InvalidMinSYSFolder)" "$(InvalidMinSYSFolder)"
; Return the $0 register to its original state
Pop $0
FunctionEnd FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $PythonPath variable.
Function SearchPython Function SearchPython
${SearchRegistry} \ ${SearchRegistry} \
$PythonPath \ $PythonPath \
@ -431,6 +461,10 @@ Function DownloadPython
FunctionEnd FunctionEnd
Function DownloadPython_LeaveFunction Function DownloadPython_LeaveFunction
; This function manipulates the $0 register
; so push its current content onto the stack.
Push $0
${DownloadLeave} \ ${DownloadLeave} \
$0 \ $0 \
$DownloadPython \ $DownloadPython \
@ -439,10 +473,14 @@ Function DownloadPython_LeaveFunction
"$(EnterPythonFolder)" \ "$(EnterPythonFolder)" \
"Python.exe" \ "Python.exe" \
"$(InvalidPythonFolder)" "$(InvalidPythonFolder)"
; Return the $0 register to its original state
Pop $0
FunctionEnd FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $MiKTeXPath variable.
Function SearchMiKTeX Function SearchMiKTeX
${SearchRegistry} \ ${SearchRegistry} \
$MiKTeXPath \ $MiKTeXPath \
@ -478,6 +516,7 @@ FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $PerlPath variable.
Function SearchPerl Function SearchPerl
${SearchRegistry} \ ${SearchRegistry} \
$PerlPath \ $PerlPath \
@ -513,21 +552,24 @@ FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $GhostscriptPath variable.
Function SearchGhostscript Function SearchGhostscript
; This function manipulates the $0 and $1 registers,
; so push their current content onto the stack.
Push $0
Push $1
; Find which version of ghostscript, if any, is installed. ; Find which version of ghostscript, if any, is installed.
; Store this value in $0.
StrCpy $0 ""
EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0 EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
${if} $1 == ""
EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
StrCpy $2 "True"
${endif}
${if} $1 != "" ${if} $1 != ""
${if} $2 == "True"
StrCpy $0 "Software\GPL Ghostscript\$1"
${else}
StrCpy $0 "Software\AFPL Ghostscript\$1" StrCpy $0 "Software\AFPL Ghostscript\$1"
${endif}
${else} ${else}
StrCpy $0 "" EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
${if} $1 != ""
StrCpy $0 "Software\GPL Ghostscript\$1"
${endif}
${endif} ${endif}
${SearchRegistry} \ ${SearchRegistry} \
@ -536,6 +578,10 @@ Function SearchGhostscript
"GS_DLL" \ "GS_DLL" \
"\gsdll32.dll" \ "\gsdll32.dll" \
"" ""
; Return the $0 and $1 registers to their original states
Pop $1
Pop $0
FunctionEnd FunctionEnd
Function DownloadGhostscript Function DownloadGhostscript
@ -580,6 +626,7 @@ FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $ImageMagickPath variable.
Function SearchImageMagick Function SearchImageMagick
${SearchRegistry} \ ${SearchRegistry} \
$ImageMagickPath \ $ImageMagickPath \
@ -631,7 +678,7 @@ FunctionEnd
Function SelectMenuLanguage_LeaveFunction Function SelectMenuLanguage_LeaveFunction
!insertmacro MUI_INSTALLOPTIONS_READ $LangName "io_ui_language.ini" "Field 2" "State" !insertmacro MUI_INSTALLOPTIONS_READ $LangName "io_ui_language.ini" "Field 2" "State"
;Get the language code; macro from lyx_utils.nsh ;Get the language code; macro from lyx_utils.nsh
StrCpy $LangCode "" StrCpy $LangCode ""
!insertmacro GetLangCode $LangCode $LangName !insertmacro GetLangCode $LangCode $LangName
@ -639,6 +686,51 @@ FunctionEnd
;-------------------------------- ;--------------------------------
; Sets the value of the global $PDFViewerPath and $PDFViewerProg variables.
Function SearchPDFViewer
StrCpy $PDFViewerPath ""
!insertmacro GetFileExtProg $PDFViewerPath $PDFViewerProg ".pdf" "a"
MessageBox MB_OK "PDF viewer $PDFViewerPath $PDFViewerProg"
FunctionEnd
;--------------------------------
; Replace these with Registers $0 and $1 once everything is working
Var PSViewerPathb
Var PSViewerProgb
Function SearchPSViewer
; This function manipulates the $0 and $1 registers,
; so push their current content onto the stack.
Push $0
Push $1
StrCpy $PSViewerPath ""
StrCpy $PSViewerPathb ""
StrCpy $PSViewerProgb ""
!insertmacro GetFileExtProg $PSViewerPath $PSViewerProg ".ps" "a"
${if} $PSViewerPath != ""
StrCpy $PSViewerPathb $PSViewerPath
StrCpy $PSViewerPathb $PSViewerPathb "" -8
${endif}
${if} $PSViewerPathb == "Distillr"
!insertmacro GetFileExtProg $PSViewerPathb $PSViewerProgb ".ps" "b"
${if} $PSViewerProgb != ""
StrCpy $PSViewerPath $PSViewerPathb
StrCpy $PSViewerProg $PSViewerProgb
${endif}
${endif}
MessageBox MB_OK "PS viewer $PSViewerPath $PSViewerProg"
; Return the $0 and $1 registers to their original states
Pop $1
Pop $0
FunctionEnd
;--------------------------------
Function SummariseDownloads Function SummariseDownloads
StrCpy $PathPrefix "" StrCpy $PathPrefix ""

View File

@ -1,15 +1,19 @@
;-------------------------------- ;--------------------------------
!macro GetFileExtProg ProgPath AppExe Extension !macro GetFileExtProg ProgPath AppExe Extension Subentry
ReadRegStr ${AppExe} HKCU \ ReadRegStr ${AppExe} HKCU \
"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${Extension}\OpenWithList" \
"a" "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${Extension}\OpenWithList" \
"${Subentry}"
${if} ${AppExe} != "" ${if} ${AppExe} != ""
ReadRegStr ${ProgPath} HKLM \ ReadRegStr ${ProgPath} HKLM \
"Software\Microsoft\Windows\CurrentVersion\App Paths\${AppExe}" "Path" "Software\Microsoft\Windows\CurrentVersion\App Paths\${AppExe}" "Path"
;remove the "\" at the end ;remove the "\" at the end
StrCpy ${ProgPath} ${ProgPath} -1 StrCpy $0 ${ProgPath} "" -1
${if} $0 == "\"
StrCpy ${ProgPath} ${ProgPath} -1
${endif}
${endif} ${endif}
!macroend !macroend
@ -53,7 +57,7 @@
${endif} ${endif}
${if} ${LangISOCode} = 1034 ${if} ${LangISOCode} = 1034
StrCpy ${LangNme} "Espagñol" StrCpy ${LangNme} "Español"
${endif} ${endif}
${if} ${LangISOCode} = 1036 ${if} ${LangISOCode} = 1036
@ -89,7 +93,7 @@
StrCpy ${LangCde} "en_EN" StrCpy ${LangCde} "en_EN"
${endif} ${endif}
${if} ${Name} == "Espagñol" ${if} ${Name} == "Español"
StrCpy ${LangCde} "es_ES" StrCpy ${LangCde} "es_ES"
${endif} ${endif}