On Wed, 13 Oct 2010, Bram Moolenaar wrote:

Christian J. Robinson wrote:

Attached is a small patch that adds a v:windowid variable which is set whenever an X11 based GUI is running; it is 0 in all other cases.

Can you move the declarations close to the call? Reduces the number of #ifdefs.

Done.

Also, I don't think they need to be initialized.

Force of habit, but you're right, so I removed the initializations.

The revised patch is attached.

-- Christian

--
Christian J. Robinson <[email protected]> -- http://christianrobinson.name/

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 10ce04af8c5b runtime/doc/eval.txt
--- a/runtime/doc/eval.txt      Sun Oct 10 17:08:43 2010 +0200
+++ b/runtime/doc/eval.txt      Wed Oct 13 11:15:47 2010 -0600
@@ -1657,6 +1657,10 @@
                                        *v:warningmsg* *warningmsg-variable*
 v:warningmsg   Last given warning message.  It's allowed to set this variable.
 
+                                       *v:windowid* *windowid-variable*
+v:windowid     When any X11 based GUI is running this will be set to the
+               window ID, the value is 0 in all other cases.
+
 ==============================================================================
 4. Builtin Functions                                   *functions*
 
diff -r 10ce04af8c5b src/eval.c
--- a/src/eval.c        Sun Oct 10 17:08:43 2010 +0200
+++ b/src/eval.c        Wed Oct 13 11:15:47 2010 -0600
@@ -362,6 +362,7 @@
     {VV_NAME("operator",        VAR_STRING), VV_RO},
     {VV_NAME("searchforward",   VAR_NUMBER), 0},
     {VV_NAME("oldfiles",        VAR_LIST), 0},
+    {VV_NAME("windowid",        VAR_NUMBER), VV_RO},
 };
 
 /* shorthand */
diff -r 10ce04af8c5b src/gui.c
--- a/src/gui.c Sun Oct 10 17:08:43 2010 +0200
+++ b/src/gui.c Wed Oct 13 11:15:47 2010 -0600
@@ -104,9 +104,23 @@
     vim_free(old_term);
 
 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
+    Window         x11_window;
+    Display        *x11_display;
+
     if (gui.in_use)
+    {
+# ifdef FEAT_EVAL
+       set_vim_var_nr(VV_WINDOWID, 0);
+
+       if (gui_get_x11_windis(&x11_window, &x11_display) == OK)
+       {
+           set_vim_var_nr(VV_WINDOWID, x11_window);
+       }
+# endif
+
        /* Display error messages in a dialog now. */
        display_errors();
+    }
 #endif
 
 #if defined(MAY_FORK) && !defined(__QNXNTO__)
diff -r 10ce04af8c5b src/vim.h
--- a/src/vim.h Sun Oct 10 17:08:43 2010 +0200
+++ b/src/vim.h Wed Oct 13 11:15:47 2010 -0600
@@ -1842,7 +1842,8 @@
 #define VV_OP          52
 #define VV_SEARCHFORWARD 53
 #define VV_OLDFILES    54
-#define VV_LEN         55      /* number of v: vars */
+#define VV_WINDOWID    55
+#define VV_LEN         56      /* number of v: vars */
 
 #ifdef FEAT_CLIPBOARD
 

Raspunde prin e-mail lui