[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ncurses applications: best practices

From: Craig Forbes
Subject: Re: ncurses applications: best practices
Date: Tue, 23 Sep 2008 10:00:55 -0500

--On Tuesday, September 23, 2008 10:19:29 AM +0530 Sentinel <address@hidden> wrote:
1. Do you implement help messages, error messages etc as fields or do you
just mvwaddstr them? In the latter case, often the previous value can be
seen. I first implemented a help line as a field. That was great, it was
part of the form. Later i removed it, since whenever I looped through
"fields" i would have to ignore the help field.

But now I am wondering whether all labels, message fields etc should be
form fields for better manageability.

I use Fields (with the O_EDIT and O_ACTIVE options off) for labels in my forms but for a help messages I split the screen into 2 panels one for the form covering all but the bottom 2 lines and a second panel for messages covering the bottom 2 lines of the screen.

I can then clear the lower panel independent of the form.

2. Multi-line field handing. I am slowly learning things here -- it wuld
really help if there is some place where someone has documented this.

I don't use multi line field so I haven't run into this

How do you implement navigation. I was unhappy using KEY_UP and DOWN for
navigation across fields, and using something else for lines. So i use
the same for lines as well, checking for an error. I first try to move to
prev/next line, if that fails then i move to next/prev field.

I use tab and up/down arrows and emacs style ^N/^P for field navigation. My app was originally for VT220 terminals which did not have a Shift-Tab so that was not an option. Again I don't have multiline fields so navigating within a field doesn't impact me.

3. Saving. Unless I tab out of a field, the value is not stored. On
pressing the save key, i tried getting the formdriver to move to next
field but that did not result in the field value being set.

I call form_driver(FORM,REQ_VALIDATION) which saves the buffers for the current field and then validates the value before calling my save function.

4. the "field" object does not take a label or id of any kind. Do you
maintain another array of fieldnames to map a fieldname to a field object?

I have used the C++ bindings and subclassed formfields to give them additional attributes but you could also use the field_userptr to store arbitrary data in the field.

I just loop through the fields searching for the one with the right attributes.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]