2007-02-08 21:09:30 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
LyX for Windows Launcher
|
|
|
|
Author: Joost Verburg
|
|
|
|
|
|
|
|
This will be installed as lyx.exe.
|
|
|
|
|
|
|
|
The application will setup the environment variables based on registry
|
|
|
|
settings and obtain the command line output of lyxc.exe, which can be shown
|
|
|
|
while debugging or in case of a crash. Version information and an icon are
|
|
|
|
also included.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
!include "MUI.nsh"
|
|
|
|
!include "LogicLib.nsh"
|
|
|
|
!include "FileFunc.nsh"
|
|
|
|
!include "StrFunc.nsh"
|
|
|
|
!insertmacro GetParameters
|
|
|
|
${StrStr}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
!include "..\packaging\installer\settings.nsh" #Version info from installer
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2007-06-28 17:00:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Settings
|
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
Caption "${APP_NAME} ${APP_VERSION}"
|
|
|
|
OutFile lyx.exe
|
|
|
|
BrandingText " "
|
|
|
|
|
2007-06-28 17:00:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Windows Vista settings
|
|
|
|
|
|
|
|
RequestExecutionLevel user
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Variables
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Var Parameters
|
|
|
|
Var Debug
|
|
|
|
Var LyXLanguage
|
|
|
|
Var ReturnValue
|
|
|
|
Var ResultText
|
|
|
|
Var ResultSubText
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#User interface for debug output
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
!define MUI_ICON "..\packaging\icons\lyx_32x32.ico"
|
|
|
|
!define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
|
|
|
|
|
|
|
|
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
|
|
|
|
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
|
|
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
|
|
|
|
|
|
!insertmacro MUI_LANGUAGE English
|
|
|
|
|
|
|
|
ShowInstDetails show
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Windows API constants
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
!define SWP_NOSIZE 0x1
|
|
|
|
!define MONITOR_DEFAULTTONEAREST 0x2
|
|
|
|
|
|
|
|
!define SM_CYCAPTION 4
|
|
|
|
!define SM_CXSIZEFRAME 32
|
|
|
|
!define SM_CYSIZEFRAME 33
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Version information
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
VIProductVersion "${APP_VERSION_NUMBER}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_INFO}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Macros
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
!macro SystemCall STACK
|
|
|
|
|
|
|
|
Push "${STACK}"
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
|
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro GetLyXSetting NAME VAR
|
|
|
|
|
|
|
|
Push "${NAME}"
|
|
|
|
Call GetLyXSetting
|
|
|
|
Pop "${VAR}"
|
|
|
|
|
|
|
|
!macroend
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Main application
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Section -Prepare
|
|
|
|
|
|
|
|
${if} $Debug == ${FALSE}
|
|
|
|
HideWindow
|
|
|
|
${endif}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Hide controls we don't need
|
2007-02-08 21:09:30 +00:00
|
|
|
FindWindow $R0 "#32770" "" $HWNDPARENT
|
|
|
|
GetDlgItem $R0 $R0 1004
|
|
|
|
ShowWindow $R0 ${SW_HIDE}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Debug info
|
2007-02-08 21:09:30 +00:00
|
|
|
!insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
|
|
|
|
are being logged."
|
|
|
|
SetDetailsPrint textonly
|
|
|
|
DetailPrint "Debug log:"
|
|
|
|
SetDetailsPrint listonly
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#LyX Language
|
2007-02-08 21:09:30 +00:00
|
|
|
!insertmacro GetLyXSetting "Language" $LyXLanguage
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Set language for gettext
|
2007-02-08 21:09:30 +00:00
|
|
|
${if} $LyXLanguage != ""
|
|
|
|
Push LC_ALL
|
|
|
|
Push $LyXLanguage
|
|
|
|
Call SetEnvironmentVariable
|
|
|
|
${endif}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Apparently the output charset needs to be set to some value,
|
|
|
|
#otherwise no non-ASCII characters will be displayed
|
2007-02-08 21:09:30 +00:00
|
|
|
Push OUTPUT_CHARSET
|
|
|
|
Push -
|
|
|
|
Call SetEnvironmentVariable
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Point to the Aiksaurus data in the LyX folder
|
2007-02-08 21:09:30 +00:00
|
|
|
Push AIK_DATA_DIR
|
|
|
|
Push "$EXEDIR\..\aiksaurus"
|
|
|
|
Call SetEnvironmentVariable
|
|
|
|
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
Section -Launch
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Start LyX and capture the command line output
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Push '"$EXEDIR\lyxc.exe" $Parameters'
|
|
|
|
CallInstDLL "$EXEDIR\Console.dll" ExecToLog
|
2007-02-28 20:48:30 +00:00
|
|
|
Pop $ReturnValue #Return value
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
Section -Debug
|
|
|
|
|
|
|
|
${if} $Debug == ${FALSE}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Check whether something went wrong
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
${if} $ReturnValue == "error"
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Probably the file does not exist
|
2007-02-08 21:09:30 +00:00
|
|
|
MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
|
|
|
|
|
|
|
|
${elseif} $ReturnValue != 0
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#LyX has crashed
|
2007-02-08 21:09:30 +00:00
|
|
|
MessageBox MB_YESNO|MB_ICONSTOP \
|
|
|
|
"LyX has been closed because of an unexpected situation.$\n\
|
|
|
|
This is most likely caused by a flaw in the software.$\n$\n\
|
|
|
|
When you open your documents again, you will be able$\n\
|
|
|
|
to restore an emergency save and continue working.$\n$\n\
|
|
|
|
Would you like to view detailed information about this error?" \
|
|
|
|
IDYES debug IDNO no_debug
|
|
|
|
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
no_debug:
|
|
|
|
|
|
|
|
Quit
|
|
|
|
|
|
|
|
debug:
|
|
|
|
|
|
|
|
ShowWindow $R0 ${SW_HIDE}
|
|
|
|
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
${if} $ReturnValue != 0
|
|
|
|
|
|
|
|
StrCpy $ResultText "Error Information"
|
|
|
|
StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
|
|
|
|
(Help > Introduction) for information about reporting this issue."
|
|
|
|
|
|
|
|
${else}
|
|
|
|
|
|
|
|
StrCpy $ResultText "Debugging Completed"
|
|
|
|
StrCpy $ResultSubText "The events you have chosen are logged below."
|
|
|
|
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
${if} $Debug == ${FALSE}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Put the log window on the screen again
|
2007-02-08 21:09:30 +00:00
|
|
|
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
BringToFront
|
|
|
|
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Functions
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Function InitInterface
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Command line parameters
|
2007-02-08 21:09:30 +00:00
|
|
|
Call GetParameters
|
|
|
|
Pop $Parameters
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Check for debug mode
|
2007-02-08 21:09:30 +00:00
|
|
|
${StrStr} $R0 $Parameters "-dbg"
|
|
|
|
|
|
|
|
${if} $R0 == ""
|
|
|
|
StrCpy $Debug ${FALSE}
|
|
|
|
${else}
|
|
|
|
StrCpy $Debug ${TRUE}
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
${if} $Debug == ${FALSE}
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Keep the log window outside the screen to ensure that there will be no flickering
|
2007-02-08 21:09:30 +00:00
|
|
|
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Function GetLyXSetting
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Get a LyX setting from the registry
|
|
|
|
#First try a current user setting, then a system setting
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Exch $R0
|
|
|
|
Push $R1
|
|
|
|
|
|
|
|
ReadRegStr $R1 HKCU ${APP_REGKEY_SETTINGS} $R0
|
|
|
|
|
|
|
|
${if} $R1 == ""
|
|
|
|
ReadRegStr $R1 HKLM ${APP_REGKEY_SETTINGS} $R0
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
Exch $R1
|
|
|
|
Exch 1
|
|
|
|
Pop $R0
|
|
|
|
|
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Function SetEnvironmentVariable
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Sets the value of an environment variable
|
|
|
|
#Input on stack: name of variable, value
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Exch $R0
|
|
|
|
Exch 1
|
|
|
|
Exch $R1
|
|
|
|
|
|
|
|
Push 'kernel32::SetEnvironmentVariable(t, t) i("$R1", "$R0")'
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
|
|
|
|
Pop $R1
|
|
|
|
Pop $R0
|
|
|
|
|
|
|
|
FunctionEnd
|