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

bug in confirm() and default option

Expand Messages
  • Hari Krishna Dara
    According to the help, if you specify a value of 0 for default, none of the choices should be selected, but this is not how it is working. I tried both on
    Message 1 of 15 , Sep 2, 2006
      According to the help, if you specify a value of 0 for default, none of
      the choices should be selected, but this is not how it is working. I
      tried both on win32 and cygwin (X) gvim and both default to 1 instead.
      Is there another trick to not select any of the choices?

      --
      Thanks,
      Hari

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    • Benji Fisher
      ... I get the same behavior on Linux (FC2). In vim (not gvim), ... echoes 0 if I hit without making a choice. HTH --Benji Fisher
      Message 2 of 15 , Sep 2, 2006
        On Sat, Sep 02, 2006 at 12:05:57AM -0700, Hari Krishna Dara wrote:
        >
        > According to the help, if you specify a value of 0 for default, none of
        > the choices should be selected, but this is not how it is working. I
        > tried both on win32 and cygwin (X) gvim and both default to 1 instead.
        > Is there another trick to not select any of the choices?

        I get the same behavior on Linux (FC2). In vim (not gvim),

        :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)

        echoes 0 if I hit <CR> without making a choice.

        HTH --Benji Fisher
      • Bram Moolenaar
        ... Please give information about the GUI you are using. There is at least a known problem with Motif. -- DINGO: You must spank her well and after you have
        Message 3 of 15 , Sep 2, 2006
          Hari Krishna Dara wrote:

          > According to the help, if you specify a value of 0 for default, none of
          > the choices should be selected, but this is not how it is working. I
          > tried both on win32 and cygwin (X) gvim and both default to 1 instead.
          > Is there another trick to not select any of the choices?

          Please give information about the GUI you are using. There is at least
          a known problem with Motif.

          --
          DINGO: You must spank her well and after you have spanked her you
          may deal with her as you like and then ... spank me.
          AMAZING: And spank me!
          STUNNER: And me.
          LOVELY: And me.
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ download, build and distribute -- http://www.A-A-P.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
        • Hari Krishna Dara
          ... This is working as expected. The index starts from 1, so 0 is invalid and is right in this case. Interestingly, if you pass an invalid number, say 4,
          Message 4 of 15 , Sep 2, 2006
            On Sat, 2 Sep 2006 at 8:20am, Benji Fisher wrote:

            > On Sat, Sep 02, 2006 at 12:05:57AM -0700, Hari Krishna Dara wrote:
            > >
            > > According to the help, if you specify a value of 0 for default, none of
            > > the choices should be selected, but this is not how it is working. I
            > > tried both on win32 and cygwin (X) gvim and both default to 1 instead.
            > > Is there another trick to not select any of the choices?
            >
            > I get the same behavior on Linux (FC2). In vim (not gvim),
            >
            > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
            >
            > echoes 0 if I hit <CR> without making a choice.
            >
            > HTH --Benji Fisher

            This is working as expected. The index starts from 1, so 0 is invalid
            and is right in this case. Interestingly, if you pass an invalid number,
            say 4, console vim returns 4 back (not 0) but the gui version returns 1.

            --
            Thanks,
            Hari

            __________________________________________________
            Do You Yahoo!?
            Tired of spam? Yahoo! Mail has the best spam protection around
            http://mail.yahoo.com
          • Hari Krishna Dara
            ... I don t know what other information you need, but the win32 version is the GA version compiled by you. I don t know what GUI libraries the cygwin X version
            Message 5 of 15 , Sep 2, 2006
              On Sat, 2 Sep 2006 at 2:25pm, Bram Moolenaar wrote:

              >
              > Hari Krishna Dara wrote:
              >
              > > According to the help, if you specify a value of 0 for default, none of
              > > the choices should be selected, but this is not how it is working. I
              > > tried both on win32 and cygwin (X) gvim and both default to 1 instead.
              > > Is there another trick to not select any of the choices?
              >
              > Please give information about the GUI you are using. There is at least
              > a known problem with Motif.

              I don't know what other information you need, but the win32 version is
              the GA version compiled by you. I don't know what GUI libraries the
              cygwin X version uses, but neither should be Motif (isn't it used only
              on solaris?).

              --
              Thanks,
              Hari

              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com
            • Bram Moolenaar
              ... Motif is supported by all Unix systems. Don t know about Cygwin. I assume Cygwin uses the GTK libraries. I don t have this setup, thus I ll have to leave
              Message 6 of 15 , Sep 3, 2006
                Hari Krishna Dara wrote:

                > > > According to the help, if you specify a value of 0 for default, none of
                > > > the choices should be selected, but this is not how it is working. I
                > > > tried both on win32 and cygwin (X) gvim and both default to 1 instead.
                > > > Is there another trick to not select any of the choices?
                > >
                > > Please give information about the GUI you are using. There is at least
                > > a known problem with Motif.
                >
                > I don't know what other information you need, but the win32 version is
                > the GA version compiled by you. I don't know what GUI libraries the
                > cygwin X version uses, but neither should be Motif (isn't it used only
                > on solaris?).

                Motif is supported by all Unix systems. Don't know about Cygwin.

                I assume Cygwin uses the GTK libraries. I don't have this setup, thus
                I'll have to leave reproducing and fixing this problem to someone else.

                --
                "Never be afraid to tell the world who you are."
                -- Anonymous

                /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                \\\ download, build and distribute -- http://www.A-A-P.org ///
                \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
              • Hari Krishna Dara
                ... But this happens on the vanilla win32 version also, so doesn t that mean this is in some common place above platform specific code? -- Thanks, Hari
                Message 7 of 15 , Sep 3, 2006
                  On Sun, 3 Sep 2006 at 12:53pm, Bram Moolenaar wrote:

                  >
                  > Hari Krishna Dara wrote:
                  >
                  > > > > According to the help, if you specify a value of 0 for default, none of
                  > > > > the choices should be selected, but this is not how it is working. I
                  > > > > tried both on win32 and cygwin (X) gvim and both default to 1 instead.
                  > > > > Is there another trick to not select any of the choices?
                  > > >
                  > > > Please give information about the GUI you are using. There is at least
                  > > > a known problem with Motif.
                  > >
                  > > I don't know what other information you need, but the win32 version is
                  > > the GA version compiled by you. I don't know what GUI libraries the
                  > > cygwin X version uses, but neither should be Motif (isn't it used only
                  > > on solaris?).
                  >
                  > Motif is supported by all Unix systems. Don't know about Cygwin.
                  >
                  > I assume Cygwin uses the GTK libraries. I don't have this setup, thus
                  > I'll have to leave reproducing and fixing this problem to someone else.

                  But this happens on the vanilla win32 version also, so doesn't that mean
                  this is in some common place above platform specific code?

                  --
                  Thanks,
                  Hari

                  __________________________________________________
                  Do You Yahoo!?
                  Tired of spam? Yahoo! Mail has the best spam protection around
                  http://mail.yahoo.com
                • Bram Moolenaar
                  ... I have tried the win32 console version and it works properly there. Do you mean the GUI version? Please be specific, trying all kinds of things to find
                  Message 8 of 15 , Sep 3, 2006
                    Hari Krishna Dara wrote:

                    > > > > > According to the help, if you specify a value of 0 for
                    > > > > > default, none of the choices should be selected, but this is
                    > > > > > not how it is working. I tried both on win32 and cygwin (X)
                    > > > > > gvim and both default to 1 instead. Is there another trick to
                    > > > > > not select any of the choices?
                    > > > >
                    > > > > Please give information about the GUI you are using. There is at least
                    > > > > a known problem with Motif.
                    > > >
                    > > > I don't know what other information you need, but the win32 version is
                    > > > the GA version compiled by you. I don't know what GUI libraries the
                    > > > cygwin X version uses, but neither should be Motif (isn't it used only
                    > > > on solaris?).
                    > >
                    > > Motif is supported by all Unix systems. Don't know about Cygwin.
                    > >
                    > > I assume Cygwin uses the GTK libraries. I don't have this setup, thus
                    > > I'll have to leave reproducing and fixing this problem to someone else.
                    >
                    > But this happens on the vanilla win32 version also, so doesn't that mean
                    > this is in some common place above platform specific code?

                    I have tried the win32 console version and it works properly there. Do
                    you mean the GUI version? Please be specific, trying all kinds of
                    things to find out what you mean is a waste of time.

                    --
                    You were lucky to have a LAKE! There were a hundred and sixty of
                    us living in a small shoebox in the middle of the road.

                    /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                    /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                    \\\ download, build and distribute -- http://www.A-A-P.org ///
                    \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                  • Hari Krishna Dara
                    ... least ... I reported that the console version works fine in a separate email, so yes, it is the GUI version. Sorry for not being clear. -- Thanks, Hari
                    Message 9 of 15 , Sep 3, 2006
                      On Sun, 3 Sep 2006 at 8:21pm, Bram Moolenaar wrote:

                      >
                      > Hari Krishna Dara wrote:
                      >
                      > > > > > > According to the help, if you specify a value of 0 for
                      > > > > > > default, none of the choices should be selected, but this is
                      > > > > > > not how it is working. I tried both on win32 and cygwin (X)
                      > > > > > > gvim and both default to 1 instead. Is there another trick to
                      > > > > > > not select any of the choices?
                      > > > > >
                      > > > > > Please give information about the GUI you are using. There is at
                      least
                      > > > > > a known problem with Motif.
                      > > > >
                      > > > > I don't know what other information you need, but the win32 version is
                      > > > > the GA version compiled by you. I don't know what GUI libraries the
                      > > > > cygwin X version uses, but neither should be Motif (isn't it used only
                      > > > > on solaris?).
                      > > >
                      > > > Motif is supported by all Unix systems. Don't know about Cygwin.
                      > > >
                      > > > I assume Cygwin uses the GTK libraries. I don't have this setup, thus
                      > > > I'll have to leave reproducing and fixing this problem to someone else.
                      > >
                      > > But this happens on the vanilla win32 version also, so doesn't that mean
                      > > this is in some common place above platform specific code?
                      >
                      > I have tried the win32 console version and it works properly there. Do
                      > you mean the GUI version? Please be specific, trying all kinds of
                      > things to find out what you mean is a waste of time.

                      I reported that the console version works fine in a separate email, so
                      yes, it is the GUI version. Sorry for not being clear.

                      --
                      Thanks,
                      Hari

                      __________________________________________________
                      Do You Yahoo!?
                      Tired of spam? Yahoo! Mail has the best spam protection around
                      http://mail.yahoo.com
                    • Benji Fisher
                      ... In the original post, Hari did say gvim . On Linux (FC2, GTK-2) I find that it works as expected in vim (with the GUI not running) but shows the same
                      Message 10 of 15 , Sep 5, 2006
                        On Sun, Sep 03, 2006 at 11:54:11AM -0700, Hari Krishna Dara wrote:
                        >
                        > On Sun, 3 Sep 2006 at 8:21pm, Bram Moolenaar wrote:
                        >
                        > > I have tried the win32 console version and it works properly there. Do
                        > > you mean the GUI version? Please be specific, trying all kinds of
                        > > things to find out what you mean is a waste of time.
                        >
                        > I reported that the console version works fine in a separate email, so
                        > yes, it is the GUI version. Sorry for not being clear.

                        In the original post, Hari did say "gvim". On Linux (FC2, GTK-2) I
                        find that it works as expected in vim (with the GUI not running) but
                        shows the same problem in gvim (with the GUI running).

                        $ vim
                        :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                        <user types <CR>>
                        0
                        :gui
                        :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                        <user types <CR>>
                        1

                        I did it that way to make sure that I was actually using the same binary
                        with and without the GUI running. The second time I invoked confirm(),
                        a dialogue box popped up with the "Yes" button highlighted.

                        HTH --Benji Fisher
                      • Bram Moolenaar
                        ... Many GUIs don t support a dialog without a button selected. Disabling the use of Enter to select a button isn t a good idea either. Thus for some GUIs it
                        Message 11 of 15 , Sep 5, 2006
                          Benji Fisher wrote:

                          > On Sun, Sep 03, 2006 at 11:54:11AM -0700, Hari Krishna Dara wrote:
                          > >
                          > > On Sun, 3 Sep 2006 at 8:21pm, Bram Moolenaar wrote:
                          > >
                          > > > I have tried the win32 console version and it works properly there. Do
                          > > > you mean the GUI version? Please be specific, trying all kinds of
                          > > > things to find out what you mean is a waste of time.
                          > >
                          > > I reported that the console version works fine in a separate email, so
                          > > yes, it is the GUI version. Sorry for not being clear.
                          >
                          > In the original post, Hari did say "gvim". On Linux (FC2, GTK-2) I
                          > find that it works as expected in vim (with the GUI not running) but
                          > shows the same problem in gvim (with the GUI running).
                          >
                          > $ vim
                          > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                          > <user types <CR>>
                          > 0
                          > :gui
                          > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                          > <user types <CR>>
                          > 1
                          >
                          > I did it that way to make sure that I was actually using the same binary
                          > with and without the GUI running. The second time I invoked confirm(),
                          > a dialogue box popped up with the "Yes" button highlighted.

                          Many GUIs don't support a dialog without a button selected. Disabling
                          the use of Enter to select a button isn't a good idea either. Thus for
                          some GUIs it simply won't work to have a dialog without a default.

                          --
                          LAUNCELOT leaps into SHOT with a mighty cry and runs the GUARD through and
                          hacks him to the floor. Blood. Swashbuckling music (perhaps).
                          LAUNCELOT races through into the castle screaming.
                          SECOND SENTRY: Hey!
                          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

                          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                          \\\ download, build and distribute -- http://www.A-A-P.org ///
                          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                        • Benji Fisher
                          ... I do not like the way it works now, since the GUI is not consistent with the terminal version. Would it be possible to add a Cancel button to the GUI
                          Message 12 of 15 , Sep 5, 2006
                            On Tue, Sep 05, 2006 at 03:38:52PM +0200, Bram Moolenaar wrote:
                            >
                            > Benji Fisher wrote:
                            >
                            > > $ vim
                            > > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                            > > <user types <CR>>
                            > > 0
                            > > :gui
                            > > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                            > > <user types <CR>>
                            > > 1
                            > >
                            > > I did it that way to make sure that I was actually using the same binary
                            > > with and without the GUI running. The second time I invoked confirm(),
                            > > a dialogue box popped up with the "Yes" button highlighted.
                            >
                            > Many GUIs don't support a dialog without a button selected. Disabling
                            > the use of Enter to select a button isn't a good idea either. Thus for
                            > some GUIs it simply won't work to have a dialog without a default.

                            I do not like the way it works now, since the GUI is not consistent
                            with the terminal version. Would it be possible to add a "Cancel"
                            button to the GUI dialogue box, and select this button if confirm() is
                            called with argument 0 as above? I am not sure how terminal vim
                            *should* respond to other out-of-range arguments (e.g., 4 instead of 0
                            in the above example).

                            I notice that the GUI confirm() returns 0 if I cancel the dialogue
                            box with <Esc>. Ditto for terminal vim, but then I have to type <Esc>
                            twice, which is odd. (Yes, I did wait more than 'timeoutlen' ms.)

                            HTH --Benji Fisher
                          • Bram Moolenaar
                            ... Adding a Cancel button completely goes against what the user specifies. If you want a default to cancel you can specify it. ... I see this too. -- Veni,
                            Message 13 of 15 , Sep 5, 2006
                              Benji Fisher wrote:

                              > > > $ vim
                              > > > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                              > > > <user types <CR>>
                              > > > 0
                              > > > :gui
                              > > > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                              > > > <user types <CR>>
                              > > > 1
                              > > >
                              > > > I did it that way to make sure that I was actually using the same binary
                              > > > with and without the GUI running. The second time I invoked confirm(),
                              > > > a dialogue box popped up with the "Yes" button highlighted.
                              > >
                              > > Many GUIs don't support a dialog without a button selected. Disabling
                              > > the use of Enter to select a button isn't a good idea either. Thus for
                              > > some GUIs it simply won't work to have a dialog without a default.
                              >
                              > I do not like the way it works now, since the GUI is not consistent
                              > with the terminal version. Would it be possible to add a "Cancel"
                              > button to the GUI dialogue box, and select this button if confirm() is
                              > called with argument 0 as above? I am not sure how terminal vim
                              > *should* respond to other out-of-range arguments (e.g., 4 instead of 0
                              > in the above example).

                              Adding a Cancel button completely goes against what the user specifies.
                              If you want a default to cancel you can specify it.

                              > I notice that the GUI confirm() returns 0 if I cancel the dialogue
                              > box with <Esc>. Ditto for terminal vim, but then I have to type <Esc>
                              > twice, which is odd. (Yes, I did wait more than 'timeoutlen' ms.)

                              I see this too.

                              --
                              Veni, Vidi, Video -- I came, I saw, I taped what I saw.

                              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                              \\\ download, build and distribute -- http://www.A-A-P.org ///
                              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                            • Hari Krishna Dara
                              ... I know for sure Windows native UI supports dialogs without a default button, and Motif also should support this as well. I will in fact be surprised if
                              Message 14 of 15 , Sep 5, 2006
                                On Tue, 5 Sep 2006 at 3:38pm, Bram Moolenaar wrote:

                                >
                                > Benji Fisher wrote:
                                >
                                > > On Sun, Sep 03, 2006 at 11:54:11AM -0700, Hari Krishna Dara wrote:
                                > > >
                                > > > On Sun, 3 Sep 2006 at 8:21pm, Bram Moolenaar wrote:
                                > > >
                                > > > > I have tried the win32 console version and it works properly there. Do
                                > > > > you mean the GUI version? Please be specific, trying all kinds of
                                > > > > things to find out what you mean is a waste of time.
                                > > >
                                > > > I reported that the console version works fine in a separate email, so
                                > > > yes, it is the GUI version. Sorry for not being clear.
                                > >
                                > > In the original post, Hari did say "gvim". On Linux (FC2, GTK-2) I
                                > > find that it works as expected in vim (with the GUI not running) but
                                > > shows the same problem in gvim (with the GUI running).
                                > >
                                > > $ vim
                                > > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                                > > <user types <CR>>
                                > > 0
                                > > :gui
                                > > :echo confirm("Save changes?", "&Yes\n&No\n&Cancel", 0)
                                > > <user types <CR>>
                                > > 1
                                > >
                                > > I did it that way to make sure that I was actually using the same binary
                                > > with and without the GUI running. The second time I invoked confirm(),
                                > > a dialogue box popped up with the "Yes" button highlighted.
                                >
                                > Many GUIs don't support a dialog without a button selected. Disabling
                                > the use of Enter to select a button isn't a good idea either. Thus for
                                > some GUIs it simply won't work to have a dialog without a default.

                                I know for sure Windows native UI supports dialogs without a default
                                button, and Motif also should support this as well. I will in fact be
                                surprised if GUIs always force the programmer to specify a default
                                button, as there should be a choice not to have one (especially when
                                there is a complex interface).

                                In my case, I was trying to set no default button when I know there is
                                some important information to read, but the user might routinely press
                                <Space> or <Enter> to get rid off it. If the dialog doesn't get hidden,
                                the user will more likely read it. Right now I resorted to doing an
                                echohl with WarningMsg followed by an input(), but this introduces a
                                drastic difference from the routine case where the user still sees a
                                dialog.

                                --
                                Thanks,
                                Hari

                                __________________________________________________
                                Do You Yahoo!?
                                Tired of spam? Yahoo! Mail has the best spam protection around
                                http://mail.yahoo.com
                              • Bram Moolenaar
                                ... On MS-Windows it works to avoid Enter selecting a default button, but Space still does. I doubt it is possible to disable this, it seems there always must
                                Message 15 of 15 , Sep 6, 2006
                                  Hari Krishna Dara wrote:

                                  > > Many GUIs don't support a dialog without a button selected. Disabling
                                  > > the use of Enter to select a button isn't a good idea either. Thus for
                                  > > some GUIs it simply won't work to have a dialog without a default.
                                  >
                                  > I know for sure Windows native UI supports dialogs without a default
                                  > button, and Motif also should support this as well. I will in fact be
                                  > surprised if GUIs always force the programmer to specify a default
                                  > button, as there should be a choice not to have one (especially when
                                  > there is a complex interface).

                                  On MS-Windows it works to avoid Enter selecting a default button, but
                                  Space still does. I doubt it is possible to disable this, it seems
                                  there always must be a button with the dashed line in it.

                                  > In my case, I was trying to set no default button when I know there is
                                  > some important information to read, but the user might routinely press
                                  > <Space> or <Enter> to get rid off it. If the dialog doesn't get hidden,
                                  > the user will more likely read it. Right now I resorted to doing an
                                  > echohl with WarningMsg followed by an input(), but this introduces a
                                  > drastic difference from the routine case where the user still sees a
                                  > dialog.

                                  Using a zero default is supposed to do this, but there are
                                  implementation problems. Hopefully someone who knows the specific GUI
                                  library can find a solution. I don't work on these unusual GUI things,
                                  it takes too much of my time.

                                  --
                                  MORTICIAN: What?
                                  CUSTOMER: Nothing -- here's your nine pence.
                                  DEAD PERSON: I'm not dead!
                                  MORTICIAN: Here -- he says he's not dead!
                                  CUSTOMER: Yes, he is.
                                  DEAD PERSON: I'm not!
                                  The Quest for the Holy Grail (Monty Python)

                                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                                  \\\ download, build and distribute -- http://www.A-A-P.org ///
                                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                                Your message has been successfully submitted and would be delivered to recipients shortly.