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

33586Re: Enhancements to the winnr() function

Expand Messages
  • Yegappan Lakshmanan
    Aug 31, 2003
    • 0 Attachment
      A small addition in the patch to the eval.txt help file below.

      --- Yegappan Lakshmanan <yegappan@...> wrote:
      > Hi all,
      >
      > The winnr() function currently returns only the current window
      > number. It is cumbersome to determine the last window number or
      > the previously accessed window number. The attached patch
      > enhances the winnr() function to return these values.
      >
      > winnr() (to be backward compatible)
      > winnr("")
      > winnr("%") - Return the current window number.
      > winnr("$") - Return the last window number.
      > winnr("#") - Return the previously accessed window number.
      >
      > - Yegappan
      >
      > ----------------------------------------------------------------
      > *** src/eval.c.orig Fri May 30 12:11:19 2003
      > --- src/eval.c Sun Aug 31 17:59:32 2003
      > ***************
      > *** 2818,2824 ****
      > {"wincol", 0, 0, f_wincol},
      > {"winheight", 1, 1, f_winheight},
      > {"winline", 0, 0, f_winline},
      > ! {"winnr", 0, 0, f_winnr},
      > {"winwidth", 1, 1, f_winwidth},
      > };
      >
      > --- 2818,2824 ----
      > {"wincol", 0, 0, f_wincol},
      > {"winheight", 1, 1, f_winheight},
      > {"winline", 0, 0, f_winline},
      > ! {"winnr", 0, 1, f_winnr},
      > {"winwidth", 1, 1, f_winwidth},
      > };
      >
      > ***************
      > *** 7193,7200 ****
      > int nr = 1;
      > #ifdef FEAT_WINDOWS
      > win_T *wp;
      >
      > ! for (wp = firstwin; wp != curwin; wp = wp->w_next)
      > ++nr;
      > #endif
      > retvar->var_val.var_number = nr;
      > --- 7193,7219 ----
      > int nr = 1;
      > #ifdef FEAT_WINDOWS
      > win_T *wp;
      > + char_u *name;
      > + win_T *search_wp;
      >
      > ! if (argvars[0].var_type != VAR_UNKNOWN)
      > ! name = argvars[0].var_val.var_string;
      > ! else
      > ! name = NULL;
      > !
      > ! search_wp = NULL;
      > ! if ((name == NULL) || (*name == NUL) || (name[0] == '%'))
      > ! search_wp = curwin;
      > ! else if ((name[0] == '#') && (prevwin != NULL))
      > ! search_wp = prevwin;
      > ! else if (name[0] == '$')
      > ! search_wp = lastwin;
      > ! else {
      > ! retvar->var_val.var_number = -1;
      > ! return;
      > ! }
      > !
      > ! for (wp = firstwin; wp != search_wp; wp = wp->w_next)
      > ++nr;
      > #endif
      > retvar->var_val.var_number = nr;
      > *** runtime/doc/eval.txt.orig Sun Jun 1 05:45:23 2003
      > --- runtime/doc/eval.txt Sun Aug 31 18:01:06 2003
      > ***************
      > *** 2572,2579 ****
      > the window. The first line is one.
      >
      > *winnr()*
      > ! winnr() The result is a Number, which is the number of the
      > current
      > ! window. The top window has number 1.
      >
      > winwidth({nr}) *winwidth()*
      > The result is a Number, which is the width of window {nr}.
      > --- 2572,2583 ----
      > the window. The first line is one.
      >
      > *winnr()*
      > ! winnr([expr]) The result is a Number, which is the number of the window
      > ! specified by {expr}. The top window has number 1. If {expr}
      > ! is not specified or if the {expr} is either "" or "%", then
      > ! the current window number is returned. If {expr} is "$", then
      > ! the last window number is returned. If {expr} is "#", then
      > ! the previously accessed window number is returned.

      If an invalid {expr} is specified, then -1 is returned.

      - Yegappan

      >
      > winwidth({nr}) *winwidth()*
      > The result is a Number, which is the width of window {nr}.
      >
      >
      >


      __________________________________
      Do you Yahoo!?
      Yahoo! SiteBuilder - Free, easy-to-use web site design software
      http://sitebuilder.yahoo.com
    • Show all 3 messages in this topic