3 LyX for Windows Launcher
6 This will be installed as lyx.exe.
8 The application will setup the environment variables based on registry
9 settings and obtain the command line output of lyxc.exe, which can be shown
10 while debugging or in case of a crash. Version information and an icon are
19 !insertmacro GetParameters
20 !insertmacro GetParent
23 # Configuration from installer
24 !include "..\packaging\installer\settings.nsh"
25 !include "..\packaging\installer\include\declarations.nsh"
27 #--------------------------------
30 Caption "${APP_NAME} ${APP_VERSION}"
31 OutFile LyXLauncher.exe
34 #--------------------------------
35 # Windows Vista settings
37 RequestExecutionLevel user
39 #--------------------------------
55 Var EnvironmentVariable
56 Var EnvironmentVariableValue
58 #--------------------------------
59 # User interface for debug output
61 !define MUI_ICON "..\packaging\icons\lyx.ico"
62 !define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
64 !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
65 !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
66 !insertmacro MUI_PAGE_INSTFILES
68 !insertmacro MUI_LANGUAGE English
72 #--------------------------------
73 # Windows API constants
75 !define SWP_NOSIZE 0x1
76 !define MONITOR_DEFAULTTONEAREST 0x2
78 !define SM_CYCAPTION 4
79 !define SM_CXSIZEFRAME 32
80 !define SM_CYSIZEFRAME 33
82 #--------------------------------
85 VIProductVersion "${APP_VERSION_NUMBER}"
86 VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
87 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_INFO}"
88 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
89 VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
91 #--------------------------------
94 !macro SystemCall STACK
97 CallInstDLL "$EXEDIR\System.dll" Call
101 !macro GetLyXSetting NAME VAR
109 #--------------------------------
114 ${If} $Debug == ${FALSE}
118 # Hide controls we don't need
119 FindWindow $R0 "#32770" "" $HWNDPARENT
120 GetDlgItem $R0 $R0 1004
121 ShowWindow $R0 ${SW_HIDE}
124 ${GetParent} $EXEDIR $LyXFolder
127 !insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
129 SetDetailsPrint textonly
130 DetailPrint "Debug log:"
131 SetDetailsPrint listonly
134 !insertmacro GetLyXSetting "Language" $LyXLanguage
136 # Set language for gettext
137 ${if} $LyXLanguage != ""
140 Call SetEnvironmentVariable
143 # Apparently the output charset needs to be set to some value,
144 # otherwise no non-ASCII characters will be displayed
147 Call SetEnvironmentVariable
149 # Location of Aiksaurus data
151 Push "$LyXFolder\aiksaurus"
152 Call SetEnvironmentVariable
154 # Location of Ghostscript
155 Push LYX_GHOSTSCRIPT_EXE
156 Push "$LyXFolder\ghostscript\bin\gswin32c.exe"
157 Call SetEnvironmentVariable
158 Push LYX_GHOSTSCRIPT_DLL
159 Push "$LyXFolder\ghostscript\bin\gsdll32.dll"
160 Call SetEnvironmentVariable
161 Push LYX_GHOSTSCRIPT_FONTS
162 Push "$LyXFolder\ghostscript\fonts"
163 Call SetEnvironmentVariable
165 # Ghostscript resources
167 Push "$LyXFolder\ghostscript\bin\gsdll32.dll"
168 Call SetEnvironmentVariable
170 Push "$LyXFolder\ghostscript\lib;$LyXFolder\ghostscript\fonts;$LyXFolder\ghostscript\Resource"
171 Call SetEnvironmentVariable
177 # Start LyX and capture the command line output
179 Push '"$EXEDIR\lyx.exe" $Parameters'
180 CallInstDLL "$EXEDIR\Console.dll" ExecToLog
181 Pop $ReturnValue #Return value
187 ${If} $Debug == ${FALSE}
189 # Check whether something went wrong
191 ${If} $ReturnValue == "error"
193 # Probably the file does not exist
194 MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
196 ${ElseIf} $ReturnValue != 0
199 MessageBox MB_YESNO|MB_ICONSTOP \
200 "LyX has been closed because of an unexpected situation.$\n\
201 This is most likely caused by a flaw in the software.$\n$\n\
202 When you open your documents again, you will be able$\n\
203 to restore an emergency save and continue working.$\n$\n\
204 Would you like to view detailed information about this error?" \
205 IDYES debug IDNO no_debug
215 ShowWindow $R0 ${SW_HIDE}
219 ${If} $ReturnValue != 0
221 StrCpy $ResultText "Error Information"
222 StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
223 (Help > Introduction) for information about reporting this issue."
227 StrCpy $ResultText "Debugging Completed"
228 StrCpy $ResultSubText "The events you have chosen are logged below."
232 ${If} $Debug == ${FALSE}
234 # Put the log window on the screen again
235 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
236 CallInstDLL "$EXEDIR\System.dll" Call
244 #--------------------------------
247 Function InitInterface
249 #Command line parameters
253 #Check for debug mode
254 ${StrStr} $R0 $Parameters "-dbg"
257 StrCpy $Debug ${FALSE}
259 StrCpy $Debug ${TRUE}
262 ${If} $Debug == ${FALSE}
264 # Keep the log window outside the screen to ensure that there will be no flickering
265 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
266 CallInstDLL "$EXEDIR\System.dll" Call
272 Function GetLyXSetting
276 # Get a LyX setting from the registry
277 # First try a current user setting, then a system setting
279 ReadRegStr $LyXSettingValue HKCU ${APP_REGKEY_SETTINGS} $LyXSetting
281 ${If} $LyXSettingValue == ""
282 ReadRegStr $LyXSettingValue HKLM ${APP_REGKEY_SETTINGS} $LyXSetting
285 Push $LyXSettingValue
289 Function SetEnvironmentVariable
291 # Sets the value of an environment variable
292 # Input on stack: name of variable, value
294 Pop $EnvironmentVariableValue
295 Pop $EnvironmentVariable
297 Push 'kernel32::SetEnvironmentVariable(t, t) i("$EnvironmentVariable", "$EnvironmentVariableValue")'
298 CallInstDLL "$EXEDIR\System.dll" Call