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 Caption "${APP_NAME} ${APP_VERSION}"
28 #--------------------------------
38 #--------------------------------
39 #User interface for debug output
41 !define MUI_ICON "..\packaging\icons\lyx_32x32.ico"
42 !define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
44 !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
45 !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
46 !insertmacro MUI_PAGE_INSTFILES
48 !insertmacro MUI_LANGUAGE English
52 #--------------------------------
53 #Windows API constants
55 !define SWP_NOSIZE 0x1
56 !define MONITOR_DEFAULTTONEAREST 0x2
58 !define SM_CYCAPTION 4
59 !define SM_CXSIZEFRAME 32
60 !define SM_CYSIZEFRAME 33
62 #--------------------------------
65 VIProductVersion "${APP_VERSION_NUMBER}"
66 VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
67 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_INFO}"
68 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
69 VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
71 #--------------------------------
74 !macro SystemCall STACK
77 CallInstDLL "$EXEDIR\System.dll" Call
81 !macro GetLyXSetting NAME VAR
89 #--------------------------------
94 ${if} $Debug == ${FALSE}
98 #Hide controls we don't need
99 FindWindow $R0 "#32770" "" $HWNDPARENT
100 GetDlgItem $R0 $R0 1004
101 ShowWindow $R0 ${SW_HIDE}
104 !insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
106 SetDetailsPrint textonly
107 DetailPrint "Debug log:"
108 SetDetailsPrint listonly
111 !insertmacro GetLyXSetting "Language" $LyXLanguage
113 #Set language for gettext
114 ${if} $LyXLanguage != ""
117 Call SetEnvironmentVariable
120 #Apparently the output charset needs to be set to some value,
121 #otherwise no non-ASCII characters will be displayed
124 Call SetEnvironmentVariable
126 #Point to the Aiksaurus data in the LyX folder
128 Push "$EXEDIR\..\aiksaurus"
129 Call SetEnvironmentVariable
135 #Start LyX and capture the command line output
137 Push '"$EXEDIR\lyxc.exe" $Parameters'
138 CallInstDLL "$EXEDIR\Console.dll" ExecToLog
139 Pop $ReturnValue #Return value
145 ${if} $Debug == ${FALSE}
147 #Check whether something went wrong
149 ${if} $ReturnValue == "error"
151 #Probably the file does not exist
152 MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
154 ${elseif} $ReturnValue != 0
157 MessageBox MB_YESNO|MB_ICONSTOP \
158 "LyX has been closed because of an unexpected situation.$\n\
159 This is most likely caused by a flaw in the software.$\n$\n\
160 When you open your documents again, you will be able$\n\
161 to restore an emergency save and continue working.$\n$\n\
162 Would you like to view detailed information about this error?" \
163 IDYES debug IDNO no_debug
173 ShowWindow $R0 ${SW_HIDE}
177 ${if} $ReturnValue != 0
179 StrCpy $ResultText "Error Information"
180 StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
181 (Help > Introduction) for information about reporting this issue."
185 StrCpy $ResultText "Debugging Completed"
186 StrCpy $ResultSubText "The events you have chosen are logged below."
190 ${if} $Debug == ${FALSE}
192 #Put the log window on the screen again
193 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
194 CallInstDLL "$EXEDIR\System.dll" Call
202 #--------------------------------
205 Function InitInterface
207 #Command line parameters
211 #Check for debug mode
212 ${StrStr} $R0 $Parameters "-dbg"
215 StrCpy $Debug ${FALSE}
217 StrCpy $Debug ${TRUE}
220 ${if} $Debug == ${FALSE}
222 #Keep the log window outside the screen to ensure that there will be no flickering
223 Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
224 CallInstDLL "$EXEDIR\System.dll" Call
230 Function GetLyXSetting
232 #Get a LyX setting from the registry
233 #First try a current user setting, then a system setting
238 ReadRegStr $R1 HKCU ${APP_REGKEY_SETTINGS} $R0
241 ReadRegStr $R1 HKLM ${APP_REGKEY_SETTINGS} $R0
250 Function SetEnvironmentVariable
252 #Sets the value of an environment variable
253 #Input on stack: name of variable, value
259 Push 'kernel32::SetEnvironmentVariable(t, t) i("$R1", "$R0")'
260 CallInstDLL "$EXEDIR\System.dll" Call