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
21 # Configuration from installer
22 !include "..\packaging\installer\settings.nsh"
23 !include "..\packaging\installer\include\declarations.nsh"
25 #--------------------------------
28 Caption "${APP_NAME} ${APP_VERSION}"
29 OutFile LyXLauncher.exe
32 #--------------------------------
33 # Windows Vista settings
35 RequestExecutionLevel user
37 #--------------------------------
53 Var EnvironmentVariable
54 Var EnvironmentVariableValue
56 #--------------------------------
57 # User interface for debug output
59 !define MUI_ICON "..\packaging\icons\lyx.ico"
60 !define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
62 !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
63 !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
64 !insertmacro MUI_PAGE_INSTFILES
66 !insertmacro MUI_LANGUAGE English
70 #--------------------------------
71 # Windows API constants
73 !define SWP_NOSIZE 0x1
74 !define MONITOR_DEFAULTTONEAREST 0x2
76 !define SM_CYCAPTION 4
77 !define SM_CXSIZEFRAME 32
78 !define SM_CYSIZEFRAME 33
80 #--------------------------------
83 VIProductVersion "${APP_VERSION_NUMBER}"
84 VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
85 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_INFO}"
86 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
87 VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
89 #--------------------------------
92 !macro SystemCall STACK
95 CallInstDLL "$EXEDIR\System.dll" Call
99 !macro GetLyXSetting NAME VAR
107 #--------------------------------
112 ${If} $Debug == ${FALSE}
116 # Hide controls we don't need
117 FindWindow $R0 "#32770" "" $HWNDPARENT
118 GetDlgItem $R0 $R0 1004
119 ShowWindow $R0 ${SW_HIDE}
122 ${GetParent} $EXEDIR $LyXFolder
125 !insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
127 SetDetailsPrint textonly
128 DetailPrint "Debug log:"
129 SetDetailsPrint listonly
132 !insertmacro GetLyXSetting "Language" $LyXLanguage
134 # Set language for gettext
135 ${if} $LyXLanguage != ""
138 Call SetEnvironmentVariable
141 # Apparently the output charset needs to be set to some value,
142 # otherwise no non-ASCII characters will be displayed
145 Call SetEnvironmentVariable
147 # Location of Aiksaurus data
149 Push "$LyXFolder\aiksaurus"
150 Call SetEnvironmentVariable
152 # Location of Ghostscript (for ImageMagick)
153 Push LYX_GHOSTSCRIPT_EXE
154 Push "$LyXFolder\ghostscript\gswin32c.exe"
155 Call SetEnvironmentVariable
156 Push LYX_GHOSTSCRIPT_DLL
157 Push "$LyXFolder\ghostscript\gsdll32.dll"
158 Call SetEnvironmentVariable
164 # Start LyX and capture the command line output
166 Push '"$EXEDIR\lyx.exe" $Parameters'
167 CallInstDLL "$EXEDIR\Console.dll" ExecToLog
168 Pop $ReturnValue #Return value
174 ${If} $Debug == ${FALSE}
176 # Check whether something went wrong
178 ${If} $ReturnValue == "error"
180 # Probably the file does not exist
181 MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
183 ${ElseIf} $ReturnValue != 0
186 MessageBox MB_YESNO|MB_ICONSTOP \
187 "LyX has been closed because of an unexpected situation.$\n\
188 This is most likely caused by a flaw in the software.$\n$\n\
189 When you open your documents again, you will be able$\n\
190 to restore an emergency save and continue working.$\n$\n\
191 Would you like to view detailed information about this error?" \
192 IDYES debug IDNO no_debug
202 ShowWindow $R0 ${SW_HIDE}
206 ${If} $ReturnValue != 0
208 StrCpy $ResultText "Error Information"
209 StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
210 (Help > Introduction) for information about reporting this issue."
214 StrCpy $ResultText "Debugging Completed"
215 StrCpy $ResultSubText "The events you have chosen are logged below."
219 ${If} $Debug == ${FALSE}
221 # Put the log window on the screen again
222 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
223 CallInstDLL "$EXEDIR\System.dll" Call
231 #--------------------------------
234 Function InitInterface
236 #Command line parameters
237 ${GetParameters} $Parameters
239 #Check for debug mode
240 ${StrStr} $R0 $Parameters "-dbg"
243 StrCpy $Debug ${FALSE}
245 StrCpy $Debug ${TRUE}
248 ${If} $Debug == ${FALSE}
250 # Keep the log window outside the screen to ensure that there will be no flickering
251 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
252 CallInstDLL "$EXEDIR\System.dll" Call
258 Function GetLyXSetting
262 # Get a LyX setting from the registry
263 # First try a current user setting, then a system setting
265 ReadRegStr $LyXSettingValue HKCU ${APP_REGKEY_SETTINGS} $LyXSetting
267 ${If} $LyXSettingValue == ""
268 ReadRegStr $LyXSettingValue HKLM ${APP_REGKEY_SETTINGS} $LyXSetting
271 Push $LyXSettingValue
275 Function SetEnvironmentVariable
277 # Sets the value of an environment variable
278 # Input on stack: name of variable, value
280 Pop $EnvironmentVariableValue
281 Pop $EnvironmentVariable
283 Push 'kernel32::SetEnvironmentVariable(t, t) i("$EnvironmentVariable", "$EnvironmentVariableValue")'
284 CallInstDLL "$EXEDIR\System.dll" Call