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