void * fn_vim_thread(void *ud) { #ifdef DYNAMIC_GETTEXT //#error dynamic_gettext /* Initialize gettext library */ dyn_libintl_init(NULL); #endif extern int VimMain(int argc, char** argv); int sdl_argc=1; char* sdl_argv[]={"gvim", NULL}; VimMain(sdl_argc, sdl_argv); disp_task_quitvim_t quitvim = {DISP_TASK_QUITVIM}; display_push_task((disp_task_t*)&quitvim); return 0; }
// // Setup for translating strings. // static void dyn_gettext_load(void) { char szBuff[BUFSIZE]; char szLang[BUFSIZE]; DWORD len; HKEY keyhandle; int gotlang = 0; strcpy(szLang, "LANG="); // First try getting the language from the registry, this can be // used to overrule the system language. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0, KEY_READ, &keyhandle) == ERROR_SUCCESS) { len = BUFSIZE; if (RegQueryValueEx(keyhandle, "lang", 0, NULL, (BYTE*)szBuff, &len) == ERROR_SUCCESS) { szBuff[len] = 0; strcat(szLang, szBuff); gotlang = 1; } RegCloseKey(keyhandle); } if (!gotlang && getenv("LANG") == NULL) { // Get the language from the system. // Could use LOCALE_SISO639LANGNAME, but it's not in Win95. // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use // only the first two. len = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, (LPTSTR)szBuff, BUFSIZE); if (len >= 2 && _strnicmp(szBuff, "en", 2) != 0) { // There are a few exceptions (probably more) if (_strnicmp(szBuff, "cht", 3) == 0 || _strnicmp(szBuff, "zht", 3) == 0) strcpy(szBuff, "zh_TW"); else if (_strnicmp(szBuff, "chs", 3) == 0 || _strnicmp(szBuff, "zhc", 3) == 0) strcpy(szBuff, "zh_CN"); else if (_strnicmp(szBuff, "jp", 2) == 0) strcpy(szBuff, "ja"); else szBuff[2] = 0; // truncate to two-letter code strcat(szLang, szBuff); gotlang = 1; } } if (gotlang) putenv(szLang); // Try to locate the runtime files. The path is used to find libintl.dll // and the vim.mo files. getRuntimeDir(szBuff); if (szBuff[0] != 0) { len = (DWORD)strlen(szBuff); if (dyn_libintl_init(szBuff)) { strcpy(szBuff + len, "lang"); (*dyn_libintl_bindtextdomain)(VIMPACKAGE, szBuff); (*dyn_libintl_textdomain)(VIMPACKAGE); } } }
/*ARGSUSED*/ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow) { int argc = 0; char **argv; char *tofree; char prog[256]; #ifdef VIMDLL char *p; HANDLE hLib; #endif /* Ron: added full path name so that the $VIM variable will get set to our * startup path (so the .vimrc file can be found w/o a VIM env. var.) */ GetModuleFileName(NULL, prog, 255); argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree); if (argc == 0) { MessageBox(0, "Could not allocate memory for command line.", "VIM Error", 0); return 0; } #ifdef DYNAMIC_GETTEXT /* Initialize gettext library */ dyn_libintl_init(NULL); #endif #ifdef VIMDLL // LoadLibrary - get name of dll to load in here: p = strrchr(prog, '\\'); if (p != NULL) { # ifdef DEBUG strcpy(p+1, "vim32d.dll"); # else strcpy(p+1, "vim32.dll"); # endif } hLib = LoadLibrary(prog); if (hLib == NULL) { MessageBox(0, _("Could not load vim32.dll!"), _("VIM Error"), 0); goto errout; } // fix up the function pointers # ifdef FEAT_GUI pSaveInst = GetProcAddress(hLib, (LPCSTR)2); # endif pmain = GetProcAddress(hLib, (LPCSTR)1); if (pmain == NULL) { MessageBox(0, _("Could not fix up function pointers to the DLL!"), _("VIM Error"),0); goto errout; } #else # ifdef FEAT_GUI pSaveInst = SaveInst; # endif pmain = # if defined(FEAT_GUI_W32) //&& defined(__MINGW32__) VimMain # else main # endif ; #endif #ifdef FEAT_GUI pSaveInst( #ifdef __MINGW32__ GetModuleHandle(NULL) #else hInstance #endif ); #endif pmain(argc, argv); #ifdef VIMDLL FreeLibrary(hLib); errout: #endif free(argv); if (tofree != NULL) free(tofree); #ifdef FEAT_MBYTE free_cmd_argsW(); #endif return 0; }