Loading ...
Sorry, an error occurred while loading the content.

[PATCH] (10/?) Python interface improvements: add window.col and .row

Expand Messages
  • ZyX
    Note: it would be nice to have something to determine on-screen window position also in VimL. # HG changeset patch # User ZyX # Date 1366996654
    Message 1 of 49 , Apr 26, 2013
    • 0 Attachment
      Note: it would be nice to have something to determine on-screen window position also in VimL.

      # HG changeset patch
      # User ZyX <kp-pav@...>
      # 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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • ZyX
      ... Because you have problems with encoding somewhere: there were no question marks in the patch, but Russian text. I just was not aware of the strange choice:
      Message 49 of 49 , May 15, 2013
      • 0 Attachment
        > After including this patch the tests were failing. The .ok files had
        > "????" where the test results in "window". I assume those question
        > marks were wrong, so I fixed the .ok files for that. But I wonder why
        > this happened.

        Because you have problems with encoding somewhere: there were no question marks in the patch, but Russian text. I just was not aware of the strange choice: using translated strings in `repr()`. I think translated messages here are just as “good” as translated exceptions; needless to say I have never seen them translated in other projects.

        --
        --
        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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.