Note: it would be nice to have something to determine on-screen window position
also in VimL.
# HG changeset patch
# User ZyX <[email protected]>
# Date 1366996654 -14400
# Branch python-extended-2
# Node ID fd568456bc93e7033e4befeeaecddf97d0dc7b74
# Parent 9ad3778f7284550c7dff2792f284ceea1e9c7bf1
Add vim.window.row and vim.window.col attributes
This adds a way to easily determine window layout. Previously it was impossible
at all (neither VimL nor other interfaces provided a way to get first window
cell coordinates).
diff -r 9ad3778f7284 -r fd568456bc93 runtime/doc/if_pyth.txt
--- a/runtime/doc/if_pyth.txt Fri Apr 26 20:42:49 2013 +0400
+++ b/runtime/doc/if_pyth.txt Fri Apr 26 21:17:34 2013 +0400
@@ -399,6 +399,7 @@
number (read-only) Window number or zero in case it cannot be
determined (e.g. when window object belongs to
other tab page).
+ row, col (read-only) On-screen window position in display cells.
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is split vertically.
diff -r 9ad3778f7284 -r fd568456bc93 src/if_py_both.h
--- a/src/if_py_both.h Fri Apr 26 20:42:49 2013 +0400
+++ b/src/if_py_both.h Fri Apr 26 21:17:34 2013 +0400
@@ -1839,9 +1839,15 @@
}
else if (strcmp(name, "height") == 0)
return PyLong_FromLong((long)(this->win->w_height));
+#ifdef FEAT_WINDOWS
+ else if (strcmp(name, "row") == 0)
+ return PyLong_FromLong((long)(this->win->w_winrow));
+#endif
#ifdef FEAT_VERTSPLIT
else if (strcmp(name, "width") == 0)
return PyLong_FromLong((long)(W_WIDTH(this->win)));
+ else if (strcmp(name, "col") == 0)
+ return PyLong_FromLong((long)(W_WINCOL(this->win)));
#endif
else if (strcmp(name, "vars") == 0)
return DictionaryNew(this->win->w_vars);
@@ -1851,8 +1857,8 @@
else if (strcmp(name, "number") == 0)
return PyLong_FromLong((long) get_win_number(this->win));
else if (strcmp(name,"__members__") == 0)
- return Py_BuildValue("[ssssss]", "buffer", "cursor", "height", "vars",
- "options", "number");
+ return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
+ "options", "number", "row", "col");
else
return NULL;
}
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -cr vim.9ad3778f7284/runtime/doc/if_pyth.txt vim.fd568456bc93/runtime/doc/if_pyth.txt
*** vim.9ad3778f7284/runtime/doc/if_pyth.txt 2013-04-26 21:20:17.500440193 +0400
--- vim.fd568456bc93/runtime/doc/if_pyth.txt 2013-04-26 21:20:17.507440130 +0400
***************
*** 399,404 ****
--- 399,405 ----
number (read-only) Window number or zero in case it cannot be
determined (e.g. when window object belongs to
other tab page).
+ row, col (read-only) On-screen window position in display cells.
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is split vertically.
diff -cr vim.9ad3778f7284/src/if_py_both.h vim.fd568456bc93/src/if_py_both.h
*** vim.9ad3778f7284/src/if_py_both.h 2013-04-26 21:20:17.499440203 +0400
--- vim.fd568456bc93/src/if_py_both.h 2013-04-26 21:20:17.509440112 +0400
***************
*** 1839,1847 ****
--- 1839,1853 ----
}
else if (strcmp(name, "height") == 0)
return PyLong_FromLong((long)(this->win->w_height));
+ #ifdef FEAT_WINDOWS
+ else if (strcmp(name, "row") == 0)
+ return PyLong_FromLong((long)(this->win->w_winrow));
+ #endif
#ifdef FEAT_VERTSPLIT
else if (strcmp(name, "width") == 0)
return PyLong_FromLong((long)(W_WIDTH(this->win)));
+ else if (strcmp(name, "col") == 0)
+ return PyLong_FromLong((long)(W_WINCOL(this->win)));
#endif
else if (strcmp(name, "vars") == 0)
return DictionaryNew(this->win->w_vars);
***************
*** 1851,1858 ****
else if (strcmp(name, "number") == 0)
return PyLong_FromLong((long) get_win_number(this->win));
else if (strcmp(name,"__members__") == 0)
! return Py_BuildValue("[ssssss]", "buffer", "cursor", "height", "vars",
! "options", "number");
else
return NULL;
}
--- 1857,1864 ----
else if (strcmp(name, "number") == 0)
return PyLong_FromLong((long) get_win_number(this->win));
else if (strcmp(name,"__members__") == 0)
! return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
! "options", "number", "row", "col");
else
return NULL;
}