a226b10
To: vim-dev@vim.org
a226b10
Subject: patch 7.1.091 (extra)
a226b10
Fcc: outbox
a226b10
From: Bram Moolenaar <Bram@moolenaar.net>
a226b10
Mime-Version: 1.0
a226b10
Content-Type: text/plain; charset=ISO-8859-1
a226b10
Content-Transfer-Encoding: 8bit
a226b10
------------
a226b10
a226b10
Patch 7.1.091 (extra)
a226b10
Problem:    Win32: Can't embed Vim inside another application.
a226b10
Solution:   Add the --windowid argument. (Nageshwar)
a226b10
Files:	    runtime/doc/gui_w32.txt, runtime/doc/starting.txt,
a226b10
	    runtime/doc/vi_diff.txt, src/globals.h, src/gui_w32.c, src/main.c
a226b10
a226b10
a226b10
*** ../vim-7.1.090/runtime/doc/gui_w32.txt	Sat May 12 15:35:53 2007
a226b10
--- runtime/doc/gui_w32.txt	Tue Aug 14 17:32:27 2007
a226b10
***************
a226b10
*** 1,4 ****
a226b10
! *gui_w32.txt*   For Vim version 7.1.  Last change: 2007 May 03
a226b10
  
a226b10
  
a226b10
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
a226b10
--- 1,4 ----
a226b10
! *gui_w32.txt*   For Vim version 7.1.  Last change: 2007 Aug 14
a226b10
  
a226b10
  
a226b10
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
a226b10
***************
a226b10
*** 52,57 ****
a226b10
--- 52,67 ----
a226b10
  								*gui-w32s*
a226b10
  There is a specific version of gvim.exe that runs under the Win32s subsystem
a226b10
  of Windows 3.1 or 3.11.  See |win32s|.
a226b10
+ 
a226b10
+ 
a226b10
+ Using Vim as a plugin					*gui-w32-windowid*
a226b10
+ 
a226b10
+ When gvim starts up normally, it creates its own top level window.  If you
a226b10
+ pass Vim the command-line option |--windowid| with a decimal or hexadecimal
a226b10
+ value, Vim will create a window that is a child of the window with the given
a226b10
+ ID.  This enables Vim to act as a plugin in another application.  This really
a226b10
+ is a programmer's interface, and is of no use without a supporting application
a226b10
+ to spawn Vim correctly.
a226b10
  
a226b10
  ==============================================================================
a226b10
  2. Vim as default editor				*vim-default-editor*
a226b10
*** ../vim-7.1.090/runtime/doc/starting.txt	Sat May 12 16:56:17 2007
a226b10
--- runtime/doc/starting.txt	Tue Aug 14 17:34:22 2007
a226b10
***************
a226b10
*** 1,4 ****
a226b10
! *starting.txt*  For Vim version 7.1.  Last change: 2007 May 12
a226b10
  
a226b10
  
a226b10
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
a226b10
--- 1,4 ----
a226b10
! *starting.txt*  For Vim version 7.1.  Last change: 2007 Aug 14
a226b10
  
a226b10
  
a226b10
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
a226b10
***************
a226b10
*** 547,552 ****
a226b10
--- 547,557 ----
a226b10
  		GTK+ GUI Vim only.  Make gvim try to use GtkPlug mechanism, so
a226b10
  		that it runs inside another window.  See |gui-gtk-socketid|
a226b10
  		for details. {not in Vi}
a226b10
+ 
a226b10
+ --windowid {id}						*--windowid*
a226b10
+ 		Win32 GUI Vim only.  Make gvim try to use the window {id} as a
a226b10
+ 		parent, so that it runs inside that window.  See
a226b10
+ 		|gui-w32-windowid| for details. {not in Vi}
a226b10
  
a226b10
  --echo-wid						*--echo-wid*
a226b10
  		GTK+ GUI Vim only.  Make gvim echo the Window ID on stdout,
a226b10
*** ../vim-7.1.090/runtime/doc/vi_diff.txt	Sat May 12 14:54:28 2007
a226b10
--- runtime/doc/vi_diff.txt	Tue Aug 14 17:35:10 2007
a226b10
***************
a226b10
*** 1,4 ****
a226b10
! *vi_diff.txt*   For Vim version 7.1.  Last change: 2007 May 07
a226b10
  
a226b10
  
a226b10
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
a226b10
--- 1,4 ----
a226b10
! *vi_diff.txt*   For Vim version 7.1.  Last change: 2007 Aug 14
a226b10
  
a226b10
  
a226b10
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
a226b10
***************
a226b10
*** 826,831 ****
a226b10
--- 826,833 ----
a226b10
  --servername {name}	Vim: Specify Vim server name
a226b10
  
a226b10
  --socketid {id}		Vim: GTK window socket to run Vim in
a226b10
+ 
a226b10
+ --windowid {id}		Vim: Win32 window ID to run Vim in
a226b10
  
a226b10
  --version	Vim: show version message and exit.
a226b10
  
a226b10
*** ../vim-7.1.090/src/globals.h	Thu May 10 19:26:02 2007
a226b10
--- src/globals.h	Wed Aug 29 22:27:45 2007
a226b10
***************
a226b10
*** 876,882 ****
a226b10
  EXTERN int no_mapping INIT(= FALSE);	/* currently no mapping allowed */
a226b10
  EXTERN int no_zero_mapping INIT(= 0);	/* mapping zero not allowed */
a226b10
  EXTERN int allow_keys INIT(= FALSE);	/* allow key codes when no_mapping
a226b10
! 					     * is set */
a226b10
  EXTERN int no_u_sync INIT(= 0);		/* Don't call u_sync() */
a226b10
  
a226b10
  EXTERN int restart_edit INIT(= 0);	/* call edit when next cmd finished */
a226b10
--- 876,882 ----
a226b10
  EXTERN int no_mapping INIT(= FALSE);	/* currently no mapping allowed */
a226b10
  EXTERN int no_zero_mapping INIT(= 0);	/* mapping zero not allowed */
a226b10
  EXTERN int allow_keys INIT(= FALSE);	/* allow key codes when no_mapping
a226b10
! 					 * is set */
a226b10
  EXTERN int no_u_sync INIT(= 0);		/* Don't call u_sync() */
a226b10
  
a226b10
  EXTERN int restart_edit INIT(= 0);	/* call edit when next cmd finished */
a226b10
***************
a226b10
*** 1250,1255 ****
a226b10
--- 1250,1263 ----
a226b10
  #ifdef FEAT_GUI_GTK
a226b10
  EXTERN guint32	gtk_socket_id INIT(= 0);
a226b10
  EXTERN int	echo_wid_arg INIT(= FALSE);	/* --echo-wid argument */
a226b10
+ #endif
a226b10
+ 
a226b10
+ #ifdef FEAT_GUI_W32
a226b10
+ /*
a226b10
+  * The value of the --windowid argument.
a226b10
+  * For embedding gvim inside another application.
a226b10
+  */
a226b10
+ EXTERN int	win_socket_id INIT(= 0);
a226b10
  #endif
a226b10
  
a226b10
  #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
a226b10
*** ../vim-7.1.090/src/gui_w32.c	Tue Aug 14 16:57:04 2007
a226b10
--- src/gui_w32.c	Tue Aug 14 17:13:41 2007
a226b10
***************
a226b10
*** 23,28 ****
a226b10
--- 23,30 ----
a226b10
   * e.g., replace LONG with LONG_PTR, etc.
a226b10
   */
a226b10
  
a226b10
+ #include "vim.h"
a226b10
+ 
a226b10
  /*
a226b10
   * These are new in Windows ME/XP, only defined in recent compilers.
a226b10
   */
a226b10
***************
a226b10
*** 1432,1447 ****
a226b10
  	}
a226b10
      }
a226b10
      else
a226b10
! 	/* Open toplevel window. */
a226b10
  	s_hwnd = CreateWindow(
a226b10
! 	    szVimWndClass, "Vim MSWindows GUI",
a226b10
! 	    WS_OVERLAPPEDWINDOW,
a226b10
! 	    gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
a226b10
! 	    gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
a226b10
! 	    100,				/* Any value will do */
a226b10
! 	    100,				/* Any value will do */
a226b10
! 	    NULL, NULL,
a226b10
! 	    s_hinst, NULL);
a226b10
  
a226b10
      if (s_hwnd == NULL)
a226b10
  	return FAIL;
a226b10
--- 1434,1462 ----
a226b10
  	}
a226b10
      }
a226b10
      else
a226b10
!     {
a226b10
! 	/* If the provided windowid is not valid reset it to zero, so that it
a226b10
! 	 * is ignored and we open our own window. */
a226b10
! 	if (IsWindow((HWND)win_socket_id) <= 0)
a226b10
! 	    win_socket_id = 0;
a226b10
! 
a226b10
! 	/* Create a window.  If win_socket_id is not zero without border and
a226b10
! 	 * titlebar, it will be reparented below. */
a226b10
  	s_hwnd = CreateWindow(
a226b10
! 		szVimWndClass, "Vim MSWindows GUI",
a226b10
! 		win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP,
a226b10
! 		gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
a226b10
! 		gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
a226b10
! 		100,				/* Any value will do */
a226b10
! 		100,				/* Any value will do */
a226b10
! 		NULL, NULL,
a226b10
! 		s_hinst, NULL);
a226b10
! 	if (s_hwnd != NULL && win_socket_id != 0)
a226b10
! 	{
a226b10
! 	    SetParent(s_hwnd, (HWND)win_socket_id);
a226b10
! 	    ShowWindow(s_hwnd, SW_SHOWMAXIMIZED);
a226b10
! 	}
a226b10
!     }
a226b10
  
a226b10
      if (s_hwnd == NULL)
a226b10
  	return FAIL;
a226b10
*** ../vim-7.1.090/src/main.c	Fri Aug 10 21:32:41 2007
a226b10
--- src/main.c	Tue Aug 14 17:22:52 2007
a226b10
***************
a226b10
*** 275,280 ****
a226b10
--- 275,281 ----
a226b10
       *   -display or --display
a226b10
       *   --server...
a226b10
       *   --socketid
a226b10
+      *   --windowid
a226b10
       */
a226b10
      early_arg_scan(&params);
a226b10
  
a226b10
***************
a226b10
*** 1489,1495 ****
a226b10
   * Get the name of the display, before gui_prepare() removes it from
a226b10
   * argv[].  Used for the xterm-clipboard display.
a226b10
   *
a226b10
!  * Also find the --server... arguments and --socketid
a226b10
   */
a226b10
  /*ARGSUSED*/
a226b10
      static void
a226b10
--- 1490,1496 ----
a226b10
   * Get the name of the display, before gui_prepare() removes it from
a226b10
   * argv[].  Used for the xterm-clipboard display.
a226b10
   *
a226b10
!  * Also find the --server... arguments and --socketid and --windowid
a226b10
   */
a226b10
  /*ARGSUSED*/
a226b10
      static void
a226b10
***************
a226b10
*** 1536,1559 ****
a226b10
  #  endif
a226b10
  	}
a226b10
  # endif
a226b10
! # ifdef FEAT_GUI_GTK
a226b10
  	else if (STRICMP(argv[i], "--socketid") == 0)
a226b10
  	{
a226b10
! 	    unsigned int    socket_id;
a226b10
  	    int		    count;
a226b10
  
a226b10
  	    if (i == argc - 1)
a226b10
  		mainerr_arg_missing((char_u *)argv[i]);
a226b10
  	    if (STRNICMP(argv[i+1], "0x", 2) == 0)
a226b10
! 		count = sscanf(&(argv[i + 1][2]), "%x", &socket_id);
a226b10
  	    else
a226b10
! 		count = sscanf(argv[i+1], "%u", &socket_id);
a226b10
  	    if (count != 1)
a226b10
  		mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
a226b10
  	    else
a226b10
! 		gtk_socket_id = socket_id;
a226b10
  	    i++;
a226b10
  	}
a226b10
  	else if (STRICMP(argv[i], "--echo-wid") == 0)
a226b10
  	    echo_wid_arg = TRUE;
a226b10
  # endif
a226b10
--- 1537,1571 ----
a226b10
  #  endif
a226b10
  	}
a226b10
  # endif
a226b10
! 
a226b10
! # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)
a226b10
! #  ifdef FEAT_GUI_W32
a226b10
! 	else if (STRICMP(argv[i], "--windowid") == 0)
a226b10
! #  else
a226b10
  	else if (STRICMP(argv[i], "--socketid") == 0)
a226b10
+ #  endif
a226b10
  	{
a226b10
! 	    unsigned int    id;
a226b10
  	    int		    count;
a226b10
  
a226b10
  	    if (i == argc - 1)
a226b10
  		mainerr_arg_missing((char_u *)argv[i]);
a226b10
  	    if (STRNICMP(argv[i+1], "0x", 2) == 0)
a226b10
! 		count = sscanf(&(argv[i + 1][2]), "%x", &id;;
a226b10
  	    else
a226b10
! 		count = sscanf(argv[i+1], "%u", &id;;
a226b10
  	    if (count != 1)
a226b10
  		mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
a226b10
  	    else
a226b10
! #  ifdef FEAT_GUI_W32
a226b10
! 		win_socket_id = id;
a226b10
! #  else
a226b10
! 		gtk_socket_id = id;
a226b10
! #  endif
a226b10
  	    i++;
a226b10
  	}
a226b10
+ # endif
a226b10
+ # ifdef FEAT_GUI_GTK
a226b10
  	else if (STRICMP(argv[i], "--echo-wid") == 0)
a226b10
  	    echo_wid_arg = TRUE;
a226b10
  # endif
a226b10
***************
a226b10
*** 1683,1690 ****
a226b10
  		    }
a226b10
  		}
a226b10
  #endif
a226b10
! #ifdef FEAT_GUI_GTK
a226b10
  		else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0)
a226b10
  		{
a226b10
  		    /* already processed -- snatch the following arg */
a226b10
  		    if (argc > 1)
a226b10
--- 1695,1706 ----
a226b10
  		    }
a226b10
  		}
a226b10
  #endif
a226b10
! #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)
a226b10
! # ifdef FEAT_GUI_GTK
a226b10
  		else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0)
a226b10
+ # else
a226b10
+ 		else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0)
a226b10
+ # endif
a226b10
  		{
a226b10
  		    /* already processed -- snatch the following arg */
a226b10
  		    if (argc > 1)
a226b10
***************
a226b10
*** 1693,1698 ****
a226b10
--- 1709,1716 ----
a226b10
  			++argv;
a226b10
  		    }
a226b10
  		}
a226b10
+ #endif
a226b10
+ #ifdef FEAT_GUI_GTK
a226b10
  		else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0)
a226b10
  		{
a226b10
  		    /* already processed, skip */
a226b10
***************
a226b10
*** 3120,3125 ****
a226b10
--- 3138,3144 ----
a226b10
  #endif
a226b10
  #ifdef FEAT_GUI_W32
a226b10
      main_msg(_("-P <parent title>\tOpen Vim inside parent application"));
a226b10
+     main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget"));
a226b10
  #endif
a226b10
  
a226b10
  #ifdef FEAT_GUI_GNOME
a226b10
*** ../vim-7.1.090/src/version.c	Thu Aug 30 11:46:46 2007
a226b10
--- src/version.c	Thu Aug 30 12:21:02 2007
a226b10
***************
a226b10
*** 668,669 ****
a226b10
--- 668,671 ----
a226b10
  {   /* Add new patch number below this line */
a226b10
+ /**/
a226b10
+     91,
a226b10
  /**/
a226b10
a226b10
-- 
a226b10
       We're knights of the Round Table
a226b10
       Our shows are formidable
a226b10
       But many times
a226b10
       We're given rhymes
a226b10
       That are quite unsingable
a226b10
       We're opera mad in Camelot
a226b10
       We sing from the diaphragm a lot.
a226b10
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
a226b10
a226b10
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
a226b10
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
a226b10
\\\        download, build and distribute -- http://www.A-A-P.org        ///
a226b10
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///