To: vim-dev@vim.org
Subject: patch 7.1.091 (extra)
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 7.1.091 (extra)
Problem: Win32: Can't embed Vim inside another application.
Solution: Add the --windowid argument. (Nageshwar)
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
*** ../vim-7.1.090/runtime/doc/gui_w32.txt Sat May 12 15:35:53 2007
--- runtime/doc/gui_w32.txt Tue Aug 14 17:32:27 2007
***************
*** 1,4 ****
! *gui_w32.txt* For Vim version 7.1. Last change: 2007 May 03
VIM REFERENCE MANUAL by Bram Moolenaar
--- 1,4 ----
! *gui_w32.txt* For Vim version 7.1. Last change: 2007 Aug 14
VIM REFERENCE MANUAL by Bram Moolenaar
***************
*** 52,57 ****
--- 52,67 ----
*gui-w32s*
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*
*** ../vim-7.1.090/runtime/doc/starting.txt Sat May 12 16:56:17 2007
--- runtime/doc/starting.txt Tue Aug 14 17:34:22 2007
***************
*** 1,4 ****
! *starting.txt* For Vim version 7.1. Last change: 2007 May 12
VIM REFERENCE MANUAL by Bram Moolenaar
--- 1,4 ----
! *starting.txt* For Vim version 7.1. Last change: 2007 Aug 14
VIM REFERENCE MANUAL by Bram Moolenaar
***************
*** 547,552 ****
--- 547,557 ----
GTK+ GUI Vim only. Make gvim try to use GtkPlug mechanism, so
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,
*** ../vim-7.1.090/runtime/doc/vi_diff.txt Sat May 12 14:54:28 2007
--- runtime/doc/vi_diff.txt Tue Aug 14 17:35:10 2007
***************
*** 1,4 ****
! *vi_diff.txt* For Vim version 7.1. Last change: 2007 May 07
VIM REFERENCE MANUAL by Bram Moolenaar
--- 1,4 ----
! *vi_diff.txt* For Vim version 7.1. Last change: 2007 Aug 14
VIM REFERENCE MANUAL by Bram Moolenaar
***************
*** 826,831 ****
--- 826,833 ----
--servername {name} Vim: Specify Vim server name
--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.
*** ../vim-7.1.090/src/globals.h Thu May 10 19:26:02 2007
--- src/globals.h Wed Aug 29 22:27:45 2007
***************
*** 876,882 ****
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 */
EXTERN int no_u_sync INIT(= 0); /* Don't call u_sync() */
EXTERN int restart_edit INIT(= 0); /* call edit when next cmd finished */
--- 876,882 ----
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 */
EXTERN int no_u_sync INIT(= 0); /* Don't call u_sync() */
EXTERN int restart_edit INIT(= 0); /* call edit when next cmd finished */
***************
*** 1250,1255 ****
--- 1250,1263 ----
#ifdef FEAT_GUI_GTK
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)
*** ../vim-7.1.090/src/gui_w32.c Tue Aug 14 16:57:04 2007
--- src/gui_w32.c Tue Aug 14 17:13:41 2007
***************
*** 23,28 ****
--- 23,30 ----
* e.g., replace LONG with LONG_PTR, etc.
*/
+ #include "vim.h"
+
/*
* These are new in Windows ME/XP, only defined in recent compilers.
*/
***************
*** 1432,1447 ****
}
}
else
! /* Open toplevel window. */
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);
if (s_hwnd == NULL)
return FAIL;
--- 1434,1462 ----
}
}
else
! {
! /* 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",
! 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;
*** ../vim-7.1.090/src/main.c Fri Aug 10 21:32:41 2007
--- src/main.c Tue Aug 14 17:22:52 2007
***************
*** 275,280 ****
--- 275,281 ----
* -display or --display
* --server...
* --socketid
+ * --windowid
*/
early_arg_scan(¶ms);
***************
*** 1489,1495 ****
* 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
*/
/*ARGSUSED*/
static void
--- 1490,1496 ----
* 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 and --windowid
*/
/*ARGSUSED*/
static void
***************
*** 1536,1559 ****
# endif
}
# endif
! # ifdef FEAT_GUI_GTK
else if (STRICMP(argv[i], "--socketid") == 0)
{
! unsigned int socket_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);
else
! count = sscanf(argv[i+1], "%u", &socket_id);
if (count != 1)
mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
else
! gtk_socket_id = socket_id;
i++;
}
else if (STRICMP(argv[i], "--echo-wid") == 0)
echo_wid_arg = TRUE;
# endif
--- 1537,1571 ----
# endif
}
# endif
!
! # 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 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", &id);
else
! count = sscanf(argv[i+1], "%u", &id);
if (count != 1)
mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
else
! # 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,1690 ****
}
}
#endif
! #ifdef FEAT_GUI_GTK
else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0)
{
/* already processed -- snatch the following arg */
if (argc > 1)
--- 1695,1706 ----
}
}
#endif
! #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,1698 ****
--- 1709,1716 ----
++argv;
}
}
+ #endif
+ #ifdef FEAT_GUI_GTK
else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0)
{
/* already processed, skip */
***************
*** 3120,3125 ****
--- 3138,3144 ----
#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
*** ../vim-7.1.090/src/version.c Thu Aug 30 11:46:46 2007
--- src/version.c Thu Aug 30 12:21:02 2007
***************
*** 668,669 ****
--- 668,671 ----
{ /* Add new patch number below this line */
+ /**/
+ 91,
/**/
--
We're knights of the Round Table
Our shows are formidable
But many times
We're given rhymes
That are quite unsingable
We're opera mad in Camelot
We sing from the diaphragm a lot.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///