I couldn't actually hold myself from doing some more work on this, so I added support for comboboxes (had to prove to myself that this is possible) and checkboxes. Now the sample form is a complete address entry with a combobox for state selection and checkbox to specify if it is a billing address.
I forgot to mention this, please try the plugin only in a fresh Vim instance, and don't use it in your regular Vim session. It is a pre-alpha quality code and though it is likely to erase your harddrive, it could probably do some harmful things such as crashing your Vim session resulting in loosing work. I am not liable for any damage it might cause. -- Thanks, Hari On Sat, 30 Sep 2006 at 6:01pm, Hari Krishna Dara wrote: > > As I was building complex code generation framework, I realized that > asking for user input for several options is cumbersome and unproductive > (especially when most of the options are anyway defaulted). I have seen > some very clever use of dialogs in the form of wizards before (I think in > the cream project), but it is cumbersome to build and not to my taste > either. All that I need is a very simple presentation of a form with > data and allow the user to change only the fields that are required, so > I started experimenting and came up with a few maps that allow form like > features such as tabbing between fields and pressing buttons. > > It works somewhat like the plugin that allows you to see and change Vim > settings in a buffer (can't recollect where I saw it), but allows ad-hoc > building of forms, more like a GUI (with no frills), so plugins can > define forms and show them for user input. It has a very simple > interface and forces some habbits on the user, but I think it is still > much better than not having anything. With some more improvements > (especially the syntax coloring) and more widget support, it can be very > useful. > > The plugin is still in a proof-of-concept stage, but you can actually > define forms and play with them. Before I go ahead and spend a lot more > time, I thought it is wise to get the opinion of the experts here and > get the feedback as a whole (and may be even generate some interest for > contribution). It is available from: > > http://haridara.googlepages.com/forms.vim > > I have included the definition of a demo form so to try, all that you > need to do is download the above file and put in your autoload directory > and execute: > > :call forms#ShowForm(forms#form) > > The hotkeys are not currently highlighted, but they are functional, so > try pressing the first letter of field names with the meta combination > (e.g., <M-f> for the "First Name:" field). > > Here are the features that I implemented so far: > - Supports "textfield" and "button" fields. > - Supports tabbing between fields. > - Hotkeys to jump to a field directly. > - Listeners for actions on buttons. > - Use <Esc> in fields to cancel changes and restore old value. > - Support for "default button" by hitting <Return> anywhere. > > I think support for combobox and checkbox will make this truly > distinguishable from using dialogs and such. Vim7 popup completion will > be a great fit for implementing combobox. Here are the TODO items I have > noted so far: > - Constructors/utilties for creating form objects (createForm(), addField() > getField(), etc.). > - Syntax highlighting: > - labels > - Buttons > - Hotkey (underline) > - ComboBox using completion popup. Optional user completion. > - CheckBox using True/False combobox or "[x]" style buttons. > - Support for disabling fields. > - Mouse support. > - Trap <C-C> and disable 'modifiable' > > I would appreciate any kind of feedback on this. > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com