Mercurial > vim
changeset 1376:53b2bedccfdf v7.1.091
updated for version 7.1-091
author | vimboss |
---|---|
date | Thu, 30 Aug 2007 10:26:19 +0000 |
parents | 61b50044616b |
children | e2f5c1597829 |
files | runtime/doc/gui_w32.txt runtime/doc/starting.txt runtime/doc/vi_diff.txt src/globals.h src/gui_w32.c src/main.c src/version.c |
diffstat | 7 files changed, 81 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/gui_w32.txt +++ b/runtime/doc/gui_w32.txt @@ -1,4 +1,4 @@ -*gui_w32.txt* For Vim version 7.1. Last change: 2007 May 03 +*gui_w32.txt* For Vim version 7.1. Last change: 2007 Aug 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -53,6 +53,16 @@ vimrc or gvimrc file: > There is a specific version of gvim.exe that runs under the Win32s subsystem of Windows 3.1 or 3.11. See |win32s|. + +Using Vim as a plugin *gui-w32-windowid* + +When gvim starts up normally, it creates its own top level window. If you +pass Vim the command-line option |--windowid| with a decimal or hexadecimal +value, Vim will create a window that is a child of the window with the given +ID. This enables Vim to act as a plugin in another application. This really +is a programmer's interface, and is of no use without a supporting application +to spawn Vim correctly. + ============================================================================== 2. Vim as default editor *vim-default-editor*
--- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.1. Last change: 2007 May 12 +*starting.txt* For Vim version 7.1. Last change: 2007 Aug 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -548,6 +548,11 @@ a slash. Thus "-R" means recovery and " that it runs inside another window. See |gui-gtk-socketid| for details. {not in Vi} +--windowid {id} *--windowid* + Win32 GUI Vim only. Make gvim try to use the window {id} as a + parent, so that it runs inside that window. See + |gui-w32-windowid| for details. {not in Vi} + --echo-wid *--echo-wid* GTK+ GUI Vim only. Make gvim echo the Window ID on stdout, which can be used to run gvim in a kpart widget. The format
--- a/runtime/doc/vi_diff.txt +++ b/runtime/doc/vi_diff.txt @@ -1,4 +1,4 @@ -*vi_diff.txt* For Vim version 7.1. Last change: 2007 May 07 +*vi_diff.txt* For Vim version 7.1. Last change: 2007 Aug 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -827,6 +827,8 @@ Only Vim is able to accept options in be --socketid {id} Vim: GTK window socket to run Vim in +--windowid {id} Vim: Win32 window ID to run Vim in + --version Vim: show version message and exit. -? Vile: print usage summary and exit.
--- a/src/globals.h +++ b/src/globals.h @@ -876,7 +876,7 @@ EXTERN int Exec_reg INIT(= FALSE); /* TR EXTERN int no_mapping INIT(= FALSE); /* currently no mapping allowed */ EXTERN int no_zero_mapping INIT(= 0); /* mapping zero not allowed */ EXTERN int allow_keys INIT(= FALSE); /* allow key codes when no_mapping - * is set */ + * is set */ EXTERN int no_u_sync INIT(= 0); /* Don't call u_sync() */ EXTERN int restart_edit INIT(= 0); /* call edit when next cmd finished */ @@ -1252,6 +1252,14 @@ EXTERN guint32 gtk_socket_id INIT(= 0); EXTERN int echo_wid_arg INIT(= FALSE); /* --echo-wid argument */ #endif +#ifdef FEAT_GUI_W32 +/* + * The value of the --windowid argument. + * For embedding gvim inside another application. + */ +EXTERN int win_socket_id INIT(= 0); +#endif + #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) EXTERN int typebuf_was_filled INIT(= FALSE); /* received text from client or from feedkeys() */
--- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -23,6 +23,8 @@ * e.g., replace LONG with LONG_PTR, etc. */ +#include "vim.h" + /* * These are new in Windows ME/XP, only defined in recent compilers. */ @@ -1432,16 +1434,29 @@ gui_mch_init(void) } } else - /* Open toplevel window. */ + { + /* If the provided windowid is not valid reset it to zero, so that it + * is ignored and we open our own window. */ + if (IsWindow((HWND)win_socket_id) <= 0) + win_socket_id = 0; + + /* Create a window. If win_socket_id is not zero without border and + * titlebar, it will be reparented below. */ s_hwnd = CreateWindow( - szVimWndClass, "Vim MSWindows GUI", - WS_OVERLAPPEDWINDOW, - gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, - gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, - 100, /* Any value will do */ - 100, /* Any value will do */ - NULL, NULL, - s_hinst, NULL); + szVimWndClass, "Vim MSWindows GUI", + win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP, + gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, + gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, + 100, /* Any value will do */ + 100, /* Any value will do */ + NULL, NULL, + s_hinst, NULL); + if (s_hwnd != NULL && win_socket_id != 0) + { + SetParent(s_hwnd, (HWND)win_socket_id); + ShowWindow(s_hwnd, SW_SHOWMAXIMIZED); + } + } if (s_hwnd == NULL) return FAIL;
--- a/src/main.c +++ b/src/main.c @@ -275,6 +275,7 @@ main * -display or --display * --server... * --socketid + * --windowid */ early_arg_scan(¶ms); @@ -1489,7 +1490,7 @@ parse_command_name(parmp) * Get the name of the display, before gui_prepare() removes it from * argv[]. Used for the xterm-clipboard display. * - * Also find the --server... arguments and --socketid + * Also find the --server... arguments and --socketid and --windowid */ /*ARGSUSED*/ static void @@ -1536,24 +1537,35 @@ early_arg_scan(parmp) # endif } # endif -# ifdef FEAT_GUI_GTK + +# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) +# ifdef FEAT_GUI_W32 + else if (STRICMP(argv[i], "--windowid") == 0) +# else else if (STRICMP(argv[i], "--socketid") == 0) +# endif { - unsigned int socket_id; + unsigned int id; int count; if (i == argc - 1) mainerr_arg_missing((char_u *)argv[i]); if (STRNICMP(argv[i+1], "0x", 2) == 0) - count = sscanf(&(argv[i + 1][2]), "%x", &socket_id); + count = sscanf(&(argv[i + 1][2]), "%x", &id); else - count = sscanf(argv[i+1], "%u", &socket_id); + count = sscanf(argv[i+1], "%u", &id); if (count != 1) mainerr(ME_INVALID_ARG, (char_u *)argv[i]); else - gtk_socket_id = socket_id; +# ifdef FEAT_GUI_W32 + win_socket_id = id; +# else + gtk_socket_id = id; +# endif i++; } +# endif +# ifdef FEAT_GUI_GTK else if (STRICMP(argv[i], "--echo-wid") == 0) echo_wid_arg = TRUE; # endif @@ -1683,8 +1695,12 @@ command_line_scan(parmp) } } #endif -#ifdef FEAT_GUI_GTK +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) +# ifdef FEAT_GUI_GTK else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) +# else + else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0) +# endif { /* already processed -- snatch the following arg */ if (argc > 1) @@ -1693,6 +1709,8 @@ command_line_scan(parmp) ++argv; } } +#endif +#ifdef FEAT_GUI_GTK else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0) { /* already processed, skip */ @@ -3120,6 +3138,7 @@ usage() #endif #ifdef FEAT_GUI_W32 main_msg(_("-P <parent title>\tOpen Vim inside parent application")); + main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); #endif #ifdef FEAT_GUI_GNOME