Ndialog is built around a collection of display objects, built into
chains and fed to the MENU()
function. It supports editable strings,
check buttons, pushbuttons, menu lists, checklists, radio checklists,
readonly text boxes, and readonly help
(html subset)
boxes.
To compile something with ndialog, you need to include the
header file ndialog.h
(if you also want to use the dialog
compatability functions, you also need to include dialog.h
header file.) When linking, you need to include libnd
(libnd_g
is the debugging version), and libcurses
(or libncurses
and libpanel
)
MENU()
function and object chainsMENU(objchain,width,depth,title,prompt,flags)
The core function of ndialog is MENU()
, which takes an object
chain, displays it, then lets the user type input
into it. Object chains are built up from objects by the
function ObjChain()
, and are disposed of by the function
deleteObjChain()
. The appearance of a MENU
form can be
slightly modified by passing a combination of the following
flags to it:
FANCY_MENU
ALIGN_LEFT
ALIGN_RIGHT
ERROR_FLAG
MENU()
has the following return codes:
MENU_ERROR
MENU_OK
MENU_CANCEL
MENU_ESCAPE
Esc
to cancel the menu.MENU()
error function. You can override this with your
own error function, if you so desire.NULL
,
create a new object chain containing just the object.NULL
if something went
wrong.x,y
) coordinates of
the object in the chain.Objects are created by calling one of the object constructors listed below. Once created, you can do a few things with them:
display
, which is a pointer
to a magic object created by MENU()
that tells drawObj
how to display itself.editObj(obj,display,event,byevent)
Does editing on the given object. Event is a pointer to
an gpm
MEVENT
record, and byevent is set if there is an
even pending. The way ndialog events work is that when a
mouse event happens inside editObj
, editObj
returns eEVENT
so the caller can find out where the mouse even happened,
find out which object will get the event, then call that
object with byevent set to true.
editObj
has the following return codes:
eNOP
eERROR
eCANCEL
eTAB
[Tab]
to advance to the next field.
The callback for this object will not be
fired on a eTAB
event, so it will need to be manually
called when we’re finished with processing and are
ready to continue.eBACKTAB
eTAB
.eRETURN
[Return]
to advance to the next
field. The callback for this object is
called on a
eRETURN
event.eEVENT
eTAB
and eBACKTAB
,
the callback function will not be called.eESCAPE
Esc
to cancel changes to this field.eREFRESH
eEXITFORM
[editObj()may, and probably will, call
drawObj()` to refresh
fields while it is running.
Object constructers use some, or all, of the following arguments.
- x,y
- Place the object at (
x,y
) in the form. (x,y
) is relative to the first line in the form after the prompt.- width
- This is the width of the editable field. Any prefixes are not included in this width, nor are any fancy borders around the object.
- depth
- This is the depth of the editable field. The title is not counted in this depth, nor are any fancy borders around the object.
- prompt
- If a prompt is given, it will be drawn immediately above the editable area in the object.
- prefix
- A prefix is another type of prompt. It goes immediately to the left of the editable field, unless it contains a
|
, in which case it will be split into a prefix and a suffix (eg: a prefix offoo|bar
will display asfoo
editablebar
).- callback
- All objects support callback functions which are called when the user uses
[Enter]
to finish editing that object. Callback functions are passed a twovoid \*
arguments – a pointer to the object and a pointer to display information, which can be passed todrawObj
oreditObj
– and return an status flag (0
if the callback failed,1
if the callback succeeded, or-1
if the callback succeeded and wants the caller to close up shop right now.- help
- This argument, if given, is the name of a helpfile that gives help for this object. Helpfiles are an html subset and are processed by a Help object. Helpfiles can be pathnames or filenames, though it’s better to use
setHelpRoot()
to set the pathname instead of hardcoding it into the object.
x,y
) inside the
window and that has a width
column wide editing area.bfr[0]
, which is a character.number
argument (button #1 will be placed to the
left of button #2, for example.) The text on the button
is the label
argument.OK
button. An OK button is somewhat like a
regular button, except that when it’s pushed, and if the
callback approves, MENU()
will immediately return with
a code of MENU_OK.Cancel
button. It’s exactly like an OK button,
except that MENU()
immediately returns with a code of
MENU_CANCEL
.size
bytes of text in bfr
.help text
object. Document
is a local html
page (no file:, http:, url:, mailto:, or whatnot) which is
formatted and displayed by this object. newHelp does
not
support a full html specification, but it supports
enough of a subset to be able
to read minimal pages legibly.newList(x,y,width,height,nritems,items,prompt,prefix,flags,callback,help)
Create a list
object. Items
is an array of
ListItem
’s (defined in ndialog.h
as
typdef struct {
char *id;
char *item;
char *help;
char selected;
} ListItem;
where the id
field is the libdialog key field, and help
is context-sensitive help for this ListItem
. The flags
argument is a bitmap determining how the list will be
displayed.
CHECK_SELECTED
ListItem
.HIGHLIGHT_SELECTED
MENU_SELECTION
menu
list; when you select an item,
the list object will return control to the caller.SHOW_IDS
item
and the id
. (This is now libdialog works).NO_HOTKEYS
DEL_LIST
DEL
key, not when they double-click or press return.ALWAYS_HIGHLIT
MENU_SELECTION
list.DONT_CLIP_ITEMS
You can find out what items are selected inside the callback
function by using getObjList(void\* obj)
to get a pointer
to the array of ListItem
s, getObjListSize(void \*obj)
to get the number of items in the list, then walking the
list looking for selected
items.
percent
filled.Widgets are multipart display objects; they are manipulated exactly the same as other objects, but have wads of additional complexity tossed into them.
newListWidget(x, y, width, height, list, prompt, insert_callback, delete_callback, dummy, help); newEditableList(x, y, width, height, list, prompt, insert_callback, delete_callback, update_callback, help);
List widgets are made up of a string, a list, an ADD button,
a DELETE button, and, optionally, a MODIFY
button. They can be used for building lists of things, like,
oh, dns servers, domains to search, and search order. The
list they work on is a List Array object. You use the
newListWidget
or newEditableList
functions to create a list
widget.
x,y
width, height
list
; this is NOT the
width and the height of the entire widget. To compute
that, add 12 to the width and 3 (4 if you give it a title)
to the height.list
prompt
insert_callback, delete_callback
not
actually insert or delete items from the list; the list
widget does that all by itself. All these callbacks do is
validate the entry or deletion.update_callback
help
A List Array
is a way to encapsulate an array of ListItems.
It is primarily used in widget sets, though you can use it to manage
your own arrays. A List Array is called a LIA
.
addToLIA
returns
the number of rows in the list array.setObjData(obj,…) Set the data for the object. The arguments depend on the object:
String
Text
[Help
]Check
all others
O_STRING, O_BUTTON,
O_LIST, O_TEXT,
or O_GAUGE
ListItem
s that a list object contains.ListItems
s that a list object contains.not
to redisplay itself the next time the window is redrawn.<TITLE>
of a Help objectuse_helpfile
)getObjCursor()
and setObjCursor()
methods.0
, otherwise it
will return 1
Hello, world
using ndialog./sbin/login
.