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

Re: pumselected() function

Expand Messages
  • Bram Moolenaar
    ... Well, it s possible, but it s likely that others will then ask for the index. So it s better to return the pum_selected value. But why stop there? Might
    Message 1 of 2 , Jul 4, 2013
    • 0 Attachment
      Charles Peacech wrote:

      > Is it possible to add a pumselected() function to vim? I have a patch
      > but I'm not sure my implementation is correct, it works though.
      >
      > Here's why it is required. Suppose I want to map <CR> like this
      > 1) when popup is displayed but no item is selected, I want the popup
      > to close and <CR> is inserted
      > 2) when popup is displayed and an item is selected, I want the item to
      > be inserted but no <CR> is inserted
      > 3) when no popup is displayed I want <CR> to be inserted
      >
      > Currently AFAIK no. 2 is not possible, that's why a pumselected()
      > function is required.
      >
      > I simply implement it as
      >
      > int
      > pum_is_selected()
      > {
      > return pum_selected != -1;
      > }
      >
      > and then add pumselected() to the functions table.

      Well, it's possible, but it's likely that others will then ask for the
      index. So it's better to return the pum_selected value.

      But why stop there? Might also want to return the list of items.

      --
      If cars evolved at the same rate as computers have, they'd cost five euro,
      run for a year on a couple of liters of petrol, and explode once a day.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      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.