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
16 !include "LogicLib.nsh"
17 !include "FileFunc.nsh"
18 !include "StrFunc.nsh"
19 !insertmacro GetParameters
22 !include "..\packaging\installer\settings.nsh" #Version info from installer
24 #--------------------------------
27 Caption "${APP_NAME} ${APP_VERSION}"
31 #--------------------------------
32 #Windows Vista settings
34 RequestExecutionLevel user
36 #--------------------------------
46 #--------------------------------
47 #User interface for debug output
49 !define MUI_ICON "..\packaging\icons\lyx_32x32.ico"
50 !define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
52 !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
53 !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
54 !insertmacro MUI_PAGE_INSTFILES
56 !insertmacro MUI_LANGUAGE English
60 #--------------------------------
61 #Windows API constants
63 !define SWP_NOSIZE 0x1
64 !define MONITOR_DEFAULTTONEAREST 0x2
66 !define SM_CYCAPTION 4
67 !define SM_CXSIZEFRAME 32
68 !define SM_CYSIZEFRAME 33
70 #--------------------------------
73 VIProductVersion "${APP_VERSION_NUMBER}"
74 VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
75 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_INFO}"
76 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
77 VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
79 #--------------------------------
82 !macro SystemCall STACK
85 CallInstDLL "$EXEDIR\System.dll" Call
89 !macro GetLyXSetting NAME VAR
97 #--------------------------------
102 ${if} $Debug == ${FALSE}
106 #Hide controls we don't need
107 FindWindow $R0 "#32770" "" $HWNDPARENT
108 GetDlgItem $R0 $R0 1004
109 ShowWindow $R0 ${SW_HIDE}
112 !insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
114 SetDetailsPrint textonly
115 DetailPrint "Debug log:"
116 SetDetailsPrint listonly
119 !insertmacro GetLyXSetting "Language" $LyXLanguage
121 #Set language for gettext
122 ${if} $LyXLanguage != ""
125 Call SetEnvironmentVariable
128 #Apparently the output charset needs to be set to some value,
129 #otherwise no non-ASCII characters will be displayed
132 Call SetEnvironmentVariable
134 #Point to the Aiksaurus data in the LyX folder
136 Push "$EXEDIR\..\aiksaurus"
137 Call SetEnvironmentVariable
143 #Start LyX and capture the command line output
145 Push '"$EXEDIR\lyxc.exe" $Parameters'
146 CallInstDLL "$EXEDIR\Console.dll" ExecToLog
147 Pop $ReturnValue #Return value
153 ${if} $Debug == ${FALSE}
155 #Check whether something went wrong
157 ${if} $ReturnValue == "error"
159 #Probably the file does not exist
160 MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
162 ${elseif} $ReturnValue != 0
165 MessageBox MB_YESNO|MB_ICONSTOP \
166 "LyX has been closed because of an unexpected situation.$\n\
167 This is most likely caused by a flaw in the software.$\n$\n\
168 When you open your documents again, you will be able$\n\
169 to restore an emergency save and continue working.$\n$\n\
170 Would you like to view detailed information about this error?" \
171 IDYES debug IDNO no_debug
181 ShowWindow $R0 ${SW_HIDE}
185 ${if} $ReturnValue != 0
187 StrCpy $ResultText "Error Information"
188 StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
189 (Help > Introduction) for information about reporting this issue."
193 StrCpy $ResultText "Debugging Completed"
194 StrCpy $ResultSubText "The events you have chosen are logged below."
198 ${if} $Debug == ${FALSE}
200 #Put the log window on the screen again
201 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
202 CallInstDLL "$EXEDIR\System.dll" Call
210 #--------------------------------
213 Function InitInterface
215 #Command line parameters
219 #Check for debug mode
220 ${StrStr} $R0 $Parameters "-dbg"
223 StrCpy $Debug ${FALSE}
225 StrCpy $Debug ${TRUE}
228 ${if} $Debug == ${FALSE}
230 #Keep the log window outside the screen to ensure that there will be no flickering
231 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
232 CallInstDLL "$EXEDIR\System.dll" Call
238 Function GetLyXSetting
240 #Get a LyX setting from the registry
241 #First try a current user setting, then a system setting
246 ReadRegStr $R1 HKCU ${APP_REGKEY_SETTINGS} $R0
249 ReadRegStr $R1 HKLM ${APP_REGKEY_SETTINGS} $R0
258 Function SetEnvironmentVariable
260 #Sets the value of an environment variable
261 #Input on stack: name of variable, value
267 Push 'kernel32::SetEnvironmentVariable(t, t) i("$R1", "$R0")'
268 CallInstDLL "$EXEDIR\System.dll" Call