summaryrefslogtreecommitdiffstats
path: root/lib/libforms
diff options
context:
space:
mode:
authorpaul <paul@FreeBSD.org>1995-01-25 08:26:17 +0000
committerpaul <paul@FreeBSD.org>1995-01-25 08:26:17 +0000
commit3d46fa5ebf1b6cea582cd88264abe1242c94b559 (patch)
tree09bff76a4dc4962d081aec36809cf964bdfcb7cd /lib/libforms
parent3b2b35819c2c40c73aaf5b14631ab7bc50e15a92 (diff)
downloadFreeBSD-src-3d46fa5ebf1b6cea582cd88264abe1242c94b559.zip
FreeBSD-src-3d46fa5ebf1b6cea582cd88264abe1242c94b559.tar.gz
Truncate any default inputs to the input width.
Update the example so it works properly.
Diffstat (limited to 'lib/libforms')
-rw-r--r--lib/libforms/examples/example.c6
-rw-r--r--lib/libforms/examples/example.frm16
-rw-r--r--lib/libforms/forms.c8
3 files changed, 17 insertions, 13 deletions
diff --git a/lib/libforms/examples/example.c b/lib/libforms/examples/example.c
index f9ce588..120dc20 100644
--- a/lib/libforms/examples/example.c
+++ b/lib/libforms/examples/example.c
@@ -56,9 +56,9 @@ main()
if (res == F_DONE) {
printf("You're entries were:\n\n");
- printf("%s\n",example_fields[3].field.input->input);
- printf("%s\n",example_fields[5].field.input->input);
- printf("%s\n",example_fields[7].field.menu->options[example_fields[7].field.menu->selected]);
+ printf("%s\n",input1.input);
+ printf("%s\n",input2.input);
+ printf("%s\n",menu1.options[example_fields[7].field.menu->selected]);
} else if (res == F_CANCEL)
printf("You cancelled the form\n");
diff --git a/lib/libforms/examples/example.frm b/lib/libforms/examples/example.frm
index 66d53c9..542d909 100644
--- a/lib/libforms/examples/example.frm
+++ b/lib/libforms/examples/example.frm
@@ -13,9 +13,9 @@ Field field2 {
}
Field field3 {
- width = 30
+ width = 10
default = "This is a default entry"
- limit = 10
+ limit = 30
}
Field field4 {
@@ -60,12 +60,12 @@ Link input2 as field5 {
}
Link menu1 as field7 {
- next = exit
+ next = quit
up = input2
- down = exit
+ down = quit
}
-Link exit as field8 {
+Link quit as field8 {
up = menu1
right = cancel
}
@@ -73,7 +73,7 @@ Link exit as field8 {
Link cancel as field9 {
up = input1
down = input1
- left = exit
+ left = quit
right = input1
}
@@ -81,7 +81,7 @@ Form example at 0,0 {
height = 24
width = 80
- Field Title at 0,15
+ Field Title at 0,30
Field field1 at 3,23
Field field2 at 7, 2
@@ -91,6 +91,6 @@ Form example at 0,0 {
Field input1 at 7,45
Field input2 at 11,45
Field menu1 at 15,45
- Field exit at 20,20
+ Field quit at 20,20
Field cancel at 20,43
}
diff --git a/lib/libforms/forms.c b/lib/libforms/forms.c
index f57c103..b0b2acf 100644
--- a/lib/libforms/forms.c
+++ b/lib/libforms/forms.c
@@ -66,8 +66,12 @@ initfrm(struct form *form)
*/
if (field->field.input->lbl_flag)
field->field.input->input[0] = '\0';
- else if (field->field.input->label)
- strcpy(field->field.input->input, field->field.input->label);
+ else if (field->field.input->label) {
+ strncpy(field->field.input->input,
+ field->field.input->label,
+ field->field.input->limit);
+ field->field.input->input[field->field.input->limit] = 0;
+ }
} else if ((field->type != F_TEXT) && (field->type != F_MENU) &&
(field->type != F_ACTION)) {
print_status("Unknown field type, closing form");
OpenPOWER on IntegriCloud