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