2016-08-29 22:49:24 +02:00
|
|
|
/* vi:set ts=8 sts=4 sw=4 noet:
|
2004-06-13 20:20:40 +00:00
|
|
|
*
|
|
|
|
* VIM - Vi IMproved by Bram Moolenaar
|
|
|
|
* GUI support by Robert Webb
|
|
|
|
*
|
|
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
|
|
* See README.txt for an overview of the Vim source code.
|
|
|
|
*/
|
|
|
|
/*
|
2024-07-26 18:46:54 +02:00
|
|
|
* Windows GUI/Console: main program (EXE) entry point:
|
2004-06-13 20:20:40 +00:00
|
|
|
*
|
2024-07-26 18:46:54 +02:00
|
|
|
* Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
|
|
|
|
* Adapted by Ken Takata.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
#include "vim.h"
|
|
|
|
|
2019-04-02 22:02:32 +02:00
|
|
|
// cproto doesn't create a prototype for VimMain()
|
2019-04-28 19:46:49 +02:00
|
|
|
#ifdef VIMDLL
|
|
|
|
__declspec(dllimport)
|
|
|
|
#endif
|
2019-05-09 15:12:55 +02:00
|
|
|
int VimMain(int argc, char **argv);
|
2024-07-26 18:46:54 +02:00
|
|
|
|
|
|
|
#ifdef VIMDLL
|
|
|
|
# define SaveInst(hInst) // Do nothing
|
|
|
|
#else
|
2019-05-09 15:12:55 +02:00
|
|
|
void SaveInst(HINSTANCE hInst);
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2024-07-26 18:46:54 +02:00
|
|
|
#ifdef FEAT_GUI
|
2004-06-13 20:20:40 +00:00
|
|
|
int WINAPI
|
2019-04-03 20:31:00 +02:00
|
|
|
wWinMain(
|
2019-04-02 22:02:32 +02:00
|
|
|
HINSTANCE hInstance,
|
2017-02-01 13:43:36 +01:00
|
|
|
HINSTANCE hPrevInst UNUSED,
|
2019-04-03 20:31:00 +02:00
|
|
|
LPWSTR lpszCmdLine UNUSED,
|
2017-02-01 13:43:36 +01:00
|
|
|
int nCmdShow UNUSED)
|
2024-07-26 18:46:54 +02:00
|
|
|
{
|
|
|
|
SaveInst(hInstance);
|
|
|
|
return VimMain(0, NULL);
|
|
|
|
}
|
|
|
|
#else
|
2019-04-03 20:31:00 +02:00
|
|
|
int
|
|
|
|
wmain(int argc UNUSED, wchar_t **argv UNUSED)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2019-04-28 19:46:49 +02:00
|
|
|
SaveInst(GetModuleHandleW(NULL));
|
2024-07-26 18:46:54 +02:00
|
|
|
return VimMain(0, NULL);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
2024-07-26 18:46:54 +02:00
|
|
|
|
|
|
|
#ifdef USE_OWNSTARTUP
|
|
|
|
// Use our own entry point and don't use the default CRT startup code to
|
|
|
|
// reduce the size of (g)vim.exe. This works only when VIMDLL is defined.
|
|
|
|
//
|
|
|
|
// For MSVC, the /GS- compiler option is needed to avoid the undefined symbol
|
|
|
|
// error. (It disables the security check. However, it affects only this
|
|
|
|
// function and doesn't have any effect on Vim itself.)
|
|
|
|
// For MinGW, the -nostdlib compiler option and the --entry linker option are
|
|
|
|
// needed.
|
|
|
|
# ifdef FEAT_GUI
|
|
|
|
void WINAPI
|
|
|
|
wWinMainCRTStartup(void)
|
|
|
|
{
|
|
|
|
VimMain(0, NULL);
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
void
|
|
|
|
wmainCRTStartup(void)
|
|
|
|
{
|
|
|
|
VimMain(0, NULL);
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif // USE_OWNSTARTUP
|
2024-07-27 13:25:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
#if defined(VIMDLL) && defined(FEAT_MZSCHEME)
|
|
|
|
|
|
|
|
# if defined(_MSC_VER)
|
|
|
|
static __declspec(thread) void *tls_space;
|
|
|
|
extern intptr_t _tls_index;
|
|
|
|
# elif defined(__MINGW32__)
|
|
|
|
static __thread void *tls_space;
|
|
|
|
extern intptr_t _tls_index;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// Get TLS information that is needed for if_mzsch.
|
|
|
|
__declspec(dllexport) void
|
|
|
|
get_tls_info(void ***ptls_space, intptr_t *ptls_index)
|
|
|
|
{
|
|
|
|
*ptls_space = &tls_space;
|
|
|
|
*ptls_index = _tls_index;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|