~ubuntu-branches/ubuntu/vivid/newt/vivid

« back to all changes in this revision

Viewing changes to .pc/messagebox_escape.patch/dialogboxes.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-11-08 14:50:00 UTC
  • mfrom: (2.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20121108145000-0yfrol7obct0jufq
Tags: 0.52.14-11ubuntu1
* Merge with Debian; remaining changes:
  - Port python module to python3.
  - Fix installation for multiple python3 versions.
  - Move libnewt to /lib and whiptail to /bin so they can be used by
    friendly-recovery on systems that have a separate /usr.
  - debian/libnewt0.52.install, debian/libnewt0.52.postinst,
    debian/palette => debian/palette.original:
    - move palette from /usr to /etc such that they can be edited by an
      admin.
* Configure --with-colorsfile=/etc/newt/palette.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* simple dialog boxes, used by both whiptail and tcl dialog bindings */
 
2
 
 
3
#include "config.h"
 
4
#include <fcntl.h>
 
5
#include <stdio.h>
 
6
#include <string.h>
 
7
#include <stdlib.h>
 
8
#include <unistd.h>
 
9
#include <wchar.h>
 
10
#include <slang.h>
 
11
 
 
12
#include "nls.h"
 
13
#include "dialogboxes.h"
 
14
#include "newt.h"
 
15
#include "newt_pr.h"
 
16
#include "popt.h"
 
17
 
 
18
#define MAXBUF    200
 
19
#define MAXFORMAT 20
 
20
#define BUTTONS   4
 
21
 
 
22
/* globals -- ick */
 
23
static int buttonHeight = 1;
 
24
static const char * buttonText[BUTTONS];
 
25
 
 
26
int max (int a, int b)
 
27
{
 
28
        return (a > b) ? a : b;
 
29
}
 
30
 
 
31
int min (int a, int b)
 
32
{
 
33
        return ( a < b) ? a : b ;
 
34
}
 
35
 
 
36
static newtComponent (*makeButton)(int left, int right, const char * text) = 
 
37
                newtCompactButton;
 
38
 
 
39
static const char * getButtonText(int button) {
 
40
    const char * text;
 
41
    if (button < 0 || button >= BUTTONS)
 
42
        return NULL;
 
43
 
 
44
    text = buttonText[button];
 
45
    if (text)
 
46
        return text;
 
47
 
 
48
    switch (button) {
 
49
        case 0: return dgettext(PACKAGE, "Ok");
 
50
        case 1: return dgettext(PACKAGE, "Cancel");
 
51
        case 2: return dgettext(PACKAGE, "Yes");
 
52
        case 3: return dgettext(PACKAGE, "No");
 
53
        default:
 
54
                return NULL;
 
55
    }
 
56
}
 
57
 
 
58
static void addButtons(int height, int width, newtComponent form, 
 
59
                       newtComponent * okay, newtComponent * cancel, 
 
60
                       int flags) {
 
61
        // FIXME: DO SOMETHING ABOUT THE HARD-CODED CONSTANTS
 
62
    if (flags & FLAG_NOCANCEL) {
 
63
           *okay = makeButton((width - 8) / 2, height - buttonHeight - 1,
 
64
                              getButtonText(BUTTON_OK));
 
65
            *cancel = NULL;
 
66
        newtFormAddComponent(form, *okay);
 
67
    } else {
 
68
        *okay = makeButton((width - 18) / 3, height - buttonHeight - 1, 
 
69
                           getButtonText(BUTTON_OK));
 
70
        *cancel = makeButton(((width - 18) / 3) * 2 + 9, 
 
71
                                height - buttonHeight - 1, 
 
72
                                getButtonText(BUTTON_CANCEL));
 
73
        newtFormAddComponents(form, *okay, *cancel, NULL);
 
74
    }
 
75
}
 
76
 
 
77
static void cleanNewlines(char *text)
 
78
{
 
79
    char *p, *q;
 
80
 
 
81
    for (p = q = text; *p; p++, q++)
 
82
        if (*p == '\\' && p[1] == 'n') {
 
83
            p++;
 
84
            *q = '\n';
 
85
        } else
 
86
            *q = *p;
 
87
    *q = '\0';
 
88
}
 
89
 
 
90
static newtComponent textbox(int maxHeight, int width, const char * text,
 
91
                        int flags, int * height) {
 
92
    newtComponent tb;
 
93
    int sFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
 
94
    int i;
 
95
    char *buf;
 
96
 
 
97
    buf = alloca(strlen(text) + 1);
 
98
    strcpy(buf, text);
 
99
    cleanNewlines(buf);
 
100
 
 
101
    tb = newtTextbox(1, 0, width, maxHeight, NEWT_FLAG_WRAP | sFlag);
 
102
    newtTextboxSetText(tb, buf);
 
103
 
 
104
    i = newtTextboxGetNumLines(tb);
 
105
    if (i < maxHeight) {
 
106
        newtTextboxSetHeight(tb, i);
 
107
        maxHeight = i;
 
108
    }
 
109
 
 
110
    *height = maxHeight;
 
111
 
 
112
    return tb;
 
113
}
 
114
 
 
115
int gauge(const char * text, int height, int width, poptContext optCon, int fd, 
 
116
                int flags) {
 
117
    newtComponent form, scale, tb;
 
118
    int top;
 
119
    const char * arg;
 
120
    char * end;
 
121
    int val;
 
122
    FILE * f = fdopen(fd, "r");
 
123
    char buf[3000];
 
124
    char buf3[50];
 
125
    int i;
 
126
 
 
127
    setlinebuf(f);
 
128
 
 
129
    if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
 
130
    val = strtoul(arg, &end, 10);
 
131
    if (*end) return DLG_ERROR;
 
132
 
 
133
    tb = textbox(height - 3, width - 2, text, flags, &top);
 
134
 
 
135
    form = newtForm(NULL, NULL, 0);
 
136
 
 
137
    scale = newtScale(2, height - 2, width - 4, 100);
 
138
    newtScaleSet(scale, val);
 
139
 
 
140
    newtFormAddComponents(form, tb, scale, NULL);
 
141
 
 
142
    newtDrawForm(form);
 
143
    newtRefresh();
 
144
 
 
145
    do {
 
146
        if (!fgets(buf, sizeof(buf) - 1, f))
 
147
            continue;
 
148
        buf[strlen(buf) - 1] = '\0';
 
149
 
 
150
        if (!strcmp(buf, "XXX")) {
 
151
            while (!fgets(buf3, sizeof(buf3) - 1, f) && !feof(f))
 
152
                ;
 
153
            if (feof(f))
 
154
                break;
 
155
            buf3[strlen(buf3) - 1] = '\0';
 
156
 
 
157
            i = 0;
 
158
            do {
 
159
                if (!fgets(buf + i, sizeof(buf) - 1 - i, f))
 
160
                    continue;
 
161
                if (!strcmp(buf + i, "XXX\n")) {
 
162
                    *(buf + i) = '\0';
 
163
                    break;
 
164
                }
 
165
                i = strlen(buf);
 
166
            } while (!feof(f));
 
167
 
 
168
            if (i > 0)
 
169
                buf[strlen(buf) - 1] = '\0';
 
170
            else
 
171
                buf[0] = '\0';
 
172
 
 
173
            cleanNewlines(buf);
 
174
            newtTextboxSetText(tb, buf);
 
175
 
 
176
            arg = buf3;
 
177
        } else {
 
178
            arg = buf;
 
179
        }
 
180
 
 
181
        val = strtoul(arg, &end, 10);
 
182
        if (!*end) {
 
183
            newtScaleSet(scale, val);
 
184
            newtDrawForm(form);
 
185
            newtRefresh();
 
186
        }
 
187
    } while (!feof(f));
 
188
 
 
189
    newtFormDestroy(form);
 
190
 
 
191
    return DLG_OKAY;
 
192
}
 
193
 
 
194
int inputBox(const char * text, int height, int width, poptContext optCon, 
 
195
                int flags, char ** result) {
 
196
    newtComponent form, entry, okay, cancel, answer, tb;
 
197
    const char * val;
 
198
    int pFlag = (flags & FLAG_PASSWORD) ? NEWT_FLAG_PASSWORD : 0;
 
199
    int rc = DLG_OKAY;
 
200
    int top;
 
201
 
 
202
    val = poptGetArg(optCon);
 
203
    tb = textbox(height - 3 - buttonHeight, width - 2,
 
204
                        text, flags, &top);
 
205
 
 
206
    form = newtForm(NULL, NULL, 0);
 
207
    entry = newtEntry(1, top + 1, val, width - 2, &val, 
 
208
                        NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT | pFlag);
 
209
 
 
210
    newtFormAddComponents(form, tb, entry, NULL);
 
211
 
 
212
    addButtons(height, width, form, &okay, &cancel, flags);
 
213
 
 
214
    answer = newtRunForm(form);
 
215
    *result = NULL;
 
216
    if (answer == cancel)
 
217
        rc = DLG_CANCEL;
 
218
    else if (answer == NULL)
 
219
        rc = DLG_ESCAPE;
 
220
    else
 
221
        *result = strdup(val);
 
222
 
 
223
    newtFormDestroy(form);
 
224
 
 
225
    return rc;
 
226
}
 
227
 
 
228
static int mystrncpyw(char *dest, const char *src, int n, int *maxwidth)
 
229
{
 
230
    int i = 0;
 
231
    int w = 0, cw;
 
232
    wchar_t c;
 
233
    mbstate_t ps;
 
234
    const char *p = src;
 
235
    char *d = dest;
 
236
    
 
237
    memset(&ps, 0, sizeof(ps));
 
238
    
 
239
    for (;;) {
 
240
        int ret = mbrtowc(&c, p, MB_CUR_MAX, &ps);
 
241
        if (ret <= 0) break;
 
242
        if (ret + i >= n) break;
 
243
        cw = wcwidth(c);
 
244
        if (cw < 0) break;
 
245
        if (cw + w > *maxwidth) break;
 
246
        w += cw;
 
247
        memcpy(d, p, ret);
 
248
        d += ret;
 
249
        p += ret;
 
250
        i += ret;
 
251
    }
 
252
    dest[i] = '\0';
 
253
    *maxwidth = w;
 
254
    return i;
 
255
}
 
256
 
 
257
int listBox(const char * text, int height, int width, poptContext optCon,
 
258
                int flags, const char *default_item, char ** result) {
 
259
    newtComponent form, okay, tb, answer, listBox;
 
260
    newtComponent cancel = NULL;
 
261
    const char * arg;
 
262
    char * end;
 
263
    int listHeight;
 
264
    int numItems = 0;
 
265
    int allocedItems = 5;
 
266
    int i, top;
 
267
    int rc = DLG_OKAY;
 
268
    char buf[MAXBUF];
 
269
    int maxTagWidth = 0;
 
270
    int maxTextWidth = 0;
 
271
    int defItem = -1;
 
272
    int scrollFlag;
 
273
    int lineWidth, textWidth, tagWidth;
 
274
    struct {
 
275
        const char * text;
 
276
        const char * tag;
 
277
    } * itemInfo = malloc(allocedItems * sizeof(*itemInfo));
 
278
 
 
279
    if (itemInfo == NULL) return DLG_ERROR;
 
280
    if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
 
281
    listHeight = strtoul(arg, &end, 10);
 
282
    if (*end) return DLG_ERROR;
 
283
 
 
284
    while ((arg = poptGetArg(optCon))) {
 
285
        if (allocedItems == numItems) {
 
286
            allocedItems += 5;
 
287
            itemInfo = realloc(itemInfo, sizeof(*itemInfo) * allocedItems);
 
288
            if (itemInfo == NULL) return DLG_ERROR;
 
289
        }
 
290
 
 
291
        itemInfo[numItems].tag = arg;
 
292
        if (default_item && (strcmp(default_item, arg) == 0)) {
 
293
                defItem = numItems;
 
294
        }
 
295
        if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
 
296
 
 
297
        if (!(flags & FLAG_NOITEM)) {
 
298
            itemInfo[numItems].text = arg;
 
299
        } else
 
300
            itemInfo[numItems].text = "";
 
301
 
 
302
        if (wstrlen(itemInfo[numItems].text,-1) > (unsigned int)maxTextWidth)
 
303
            maxTextWidth = wstrlen(itemInfo[numItems].text,-1);
 
304
        if (wstrlen(itemInfo[numItems].tag,-1) > (unsigned int)maxTagWidth)
 
305
            maxTagWidth = wstrlen(itemInfo[numItems].tag,-1);
 
306
 
 
307
        numItems++;
 
308
    }
 
309
    if (numItems == 0)
 
310
        return DLG_ERROR;
 
311
 
 
312
    if (flags & FLAG_NOTAGS) {
 
313
            maxTagWidth = 0;
 
314
    }
 
315
 
 
316
    form = newtForm(NULL, NULL, 0);
 
317
 
 
318
    tb = textbox(height - 4 - buttonHeight - listHeight, width - 2,
 
319
                        text, flags, &top);
 
320
 
 
321
    if (listHeight >= numItems) {
 
322
        scrollFlag = 0;
 
323
        i = 0;
 
324
    } else {
 
325
        scrollFlag = NEWT_FLAG_SCROLL;
 
326
        i = 2;
 
327
    }
 
328
 
 
329
    lineWidth = min(maxTagWidth + maxTextWidth + i, SLtt_Screen_Cols - 10);
 
330
    listBox = newtListbox( (width - lineWidth) / 2 , top + 1, listHeight,
 
331
                          NEWT_FLAG_RETURNEXIT | scrollFlag);
 
332
 
 
333
    textWidth = maxTextWidth;
 
334
    tagWidth = maxTagWidth;
 
335
    if (maxTextWidth == 0) {
 
336
        tagWidth = lineWidth;
 
337
    } else {
 
338
       if (maxTextWidth + maxTagWidth + i > lineWidth)
 
339
               tagWidth = textWidth = (lineWidth / 2) - 2;
 
340
       else {
 
341
               tagWidth++;
 
342
               textWidth++;
 
343
       }
 
344
    }
 
345
 
 
346
    if (!(flags & FLAG_NOTAGS)) {
 
347
       for (i = 0; i < numItems; i++) {
 
348
           int w = tagWidth;
 
349
           int len, j;
 
350
           len = mystrncpyw(buf, itemInfo[i].tag, MAXBUF, &w);
 
351
           for (j = 0; j < tagWidth - w; j++) {
 
352
                   if (len + 1 >= MAXBUF)
 
353
                       break;
 
354
                   buf[len++] = ' ';
 
355
           }
 
356
           buf[len] = '\0';
 
357
           w = textWidth;
 
358
           mystrncpyw(buf + len, itemInfo[i].text, MAXBUF-len, &w);
 
359
           newtListboxAddEntry(listBox, buf, (void *)(long) i);
 
360
       }
 
361
     } else {
 
362
        for (i = 0; i < numItems; i++) {
 
363
           snprintf(buf, MAXBUF, "%s", itemInfo[i].text);
 
364
           newtListboxAddEntry(listBox, buf, (void *)(long) i);
 
365
      }
 
366
   }
 
367
 
 
368
    if (defItem != -1)
 
369
        newtListboxSetCurrent (listBox, defItem);
 
370
 
 
371
    newtFormAddComponents(form, tb, listBox, NULL);
 
372
 
 
373
    addButtons(height, width, form, &okay, &cancel, flags);
 
374
 
 
375
    answer = newtRunForm(form);
 
376
    *result = NULL;
 
377
    if (answer == cancel)
 
378
        rc = DLG_CANCEL;
 
379
    if (answer == NULL)
 
380
        rc = DLG_ESCAPE;
 
381
    else {
 
382
        i = (long) newtListboxGetCurrent(listBox);
 
383
        *result = strdup(itemInfo[i].tag);
 
384
    }
 
385
 
 
386
    newtFormDestroy(form);
 
387
    free(itemInfo);
 
388
 
 
389
    return rc;
 
390
}
 
391
 
 
392
int checkList(const char * text, int height, int width, poptContext optCon,
 
393
                int useRadio, int flags, char *** selections) {
 
394
    newtComponent form, okay, tb, subform, answer;
 
395
    newtComponent sb = NULL, cancel = NULL;
 
396
    const char * arg;
 
397
    char * end;
 
398
    int listHeight;
 
399
    int numBoxes = 0;
 
400
    int allocedBoxes = 5;
 
401
    int i;
 
402
    int numSelected;
 
403
    int rc = DLG_OKAY;
 
404
    char buf[MAXBUF], format[MAXFORMAT];
 
405
    int maxWidth = 0;
 
406
    int top;
 
407
    struct {
 
408
        const char * text;
 
409
        const char * tag;
 
410
        newtComponent comp;
 
411
    } * cbInfo = malloc(allocedBoxes * sizeof(*cbInfo));
 
412
    char * cbStates = malloc(allocedBoxes * sizeof(*cbStates));
 
413
 
 
414
    if ( (cbInfo == NULL) || (cbStates == NULL)) return DLG_ERROR;
 
415
    if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
 
416
    listHeight = strtoul(arg, &end, 10);
 
417
    if (*end) return DLG_ERROR;
 
418
 
 
419
    while ((arg = poptGetArg(optCon))) {
 
420
        if (allocedBoxes == numBoxes) {
 
421
            allocedBoxes += 5;
 
422
            cbInfo = realloc(cbInfo, sizeof(*cbInfo) * allocedBoxes);
 
423
            cbStates = realloc(cbStates, sizeof(*cbStates) * allocedBoxes);
 
424
            if ((cbInfo == NULL) || (cbStates == NULL)) return DLG_ERROR;
 
425
        }
 
426
 
 
427
        cbInfo[numBoxes].tag = arg;
 
428
        if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
 
429
 
 
430
        if (!(flags & FLAG_NOITEM)) {
 
431
            cbInfo[numBoxes].text = arg;
 
432
            if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
 
433
        } else
 
434
            cbInfo[numBoxes].text = "";
 
435
 
 
436
        if (!strcmp(arg, "1") || !strcasecmp(arg, "on") || 
 
437
                !strcasecmp(arg, "yes"))
 
438
            cbStates[numBoxes] = '*';
 
439
        else
 
440
            cbStates[numBoxes] = ' ';
 
441
 
 
442
        if (wstrlen(cbInfo[numBoxes].tag,-1) > (unsigned int)maxWidth)
 
443
            maxWidth = wstrlen(cbInfo[numBoxes].tag,-1);
 
444
 
 
445
        numBoxes++;
 
446
    }
 
447
 
 
448
    form = newtForm(NULL, NULL, 0);
 
449
 
 
450
    tb = textbox(height - 3 - buttonHeight - listHeight, width - 2,
 
451
                        text, flags, &top);
 
452
 
 
453
    if (listHeight < numBoxes) { 
 
454
        sb = newtVerticalScrollbar(width - 4, 
 
455
                                   top + 1,
 
456
                                   listHeight, NEWT_COLORSET_CHECKBOX,
 
457
                                   NEWT_COLORSET_ACTCHECKBOX);
 
458
        newtFormAddComponent(form, sb);
 
459
    }
 
460
    subform = newtForm(sb, NULL, 0);
 
461
    newtFormSetBackground(subform, NEWT_COLORSET_CHECKBOX);
 
462
 
 
463
    snprintf(format, MAXFORMAT, "%%-%ds  %%s", maxWidth);
 
464
    for (i = 0; i < numBoxes; i++) {
 
465
        snprintf(buf, MAXBUF, format, cbInfo[i].tag, cbInfo[i].text);
 
466
 
 
467
        if (useRadio)
 
468
            cbInfo[i].comp = newtRadiobutton(4, top + 1 + i, buf,
 
469
                                        cbStates[i] != ' ', 
 
470
                                        i ? cbInfo[i - 1].comp : NULL);
 
471
        else
 
472
            cbInfo[i].comp = newtCheckbox(4, top + 1 + i, buf,
 
473
                              cbStates[i], NULL, cbStates + i);
 
474
 
 
475
        newtCheckboxSetFlags(cbInfo[i].comp, NEWT_FLAG_RETURNEXIT, NEWT_FLAGS_SET);
 
476
        newtFormAddComponent(subform, cbInfo[i].comp);
 
477
    }
 
478
 
 
479
    newtFormSetHeight(subform, listHeight);
 
480
    newtFormSetWidth(subform, width - 10);
 
481
 
 
482
    newtFormAddComponents(form, tb, subform, NULL);
 
483
 
 
484
    addButtons(height, width, form, &okay, &cancel, flags);
 
485
 
 
486
    answer = newtRunForm(form);
 
487
    *selections = NULL;
 
488
    if (answer == cancel)
 
489
        rc = DLG_CANCEL;
 
490
    if (answer == NULL)
 
491
        rc = DLG_ESCAPE;
 
492
    else {
 
493
        if (useRadio) {
 
494
            answer = newtRadioGetCurrent(cbInfo[0].comp);
 
495
            *selections = malloc(sizeof(char *) * 2);
 
496
            if (*selections == NULL)
 
497
                return DLG_ERROR;
 
498
            (*selections)[0] = (*selections)[1] = NULL;
 
499
            for (i = 0; i < numBoxes; i++)
 
500
                if (cbInfo[i].comp == answer) {
 
501
                    (*selections)[0] = strdup(cbInfo[i].tag);
 
502
                    break;
 
503
                }
 
504
        } else {
 
505
            numSelected = 0;
 
506
            for (i = 0; i < numBoxes; i++) {
 
507
                if (cbStates[i] != ' ') numSelected++;
 
508
            }
 
509
 
 
510
            *selections = malloc(sizeof(char *) * (numSelected + 1));
 
511
            if (*selections == NULL)
 
512
                return DLG_ERROR;
 
513
 
 
514
            numSelected = 0;
 
515
            for (i = 0; i < numBoxes; i++) {
 
516
                if (cbStates[i] != ' ')
 
517
                    (*selections)[numSelected++] = strdup(cbInfo[i].tag);
 
518
            }
 
519
 
 
520
            (*selections)[numSelected] = NULL;
 
521
        }
 
522
    }
 
523
 
 
524
    free(cbInfo);
 
525
    free(cbStates);
 
526
    newtFormDestroy(form);
 
527
 
 
528
    return rc;
 
529
}
 
530
 
 
531
int messageBox(const char * text, int height, int width, int type, int flags) {
 
532
    newtComponent form, yes, tb, answer;
 
533
    newtComponent no = NULL;
 
534
    int rc = DLG_OKAY;
 
535
    int tFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
 
536
 
 
537
    form = newtForm(NULL, NULL, 0);
 
538
 
 
539
    tb = newtTextbox(1, 1, width - 2, height - 3 - buttonHeight, 
 
540
                        NEWT_FLAG_WRAP | tFlag);
 
541
    newtTextboxSetText(tb, text);
 
542
 
 
543
    newtFormAddComponent(form, tb);
 
544
 
 
545
    switch ( type ) {
 
546
    case MSGBOX_INFO:
 
547
        break;
 
548
    case MSGBOX_MSG:
 
549
        // FIXME Do something about the hard-coded constants
 
550
        yes = makeButton((width - 8) / 2, height - 1 - buttonHeight, 
 
551
                          getButtonText(BUTTON_OK));
 
552
        newtFormAddComponent(form, yes);
 
553
        break;
 
554
    default:
 
555
        yes = makeButton((width - 16) / 3, height - 1 - buttonHeight, 
 
556
                         getButtonText(BUTTON_YES));
 
557
        no = makeButton(((width - 16) / 3) * 2 + 9, height - 1 - buttonHeight, 
 
558
                         getButtonText(BUTTON_NO));
 
559
        newtFormAddComponents(form, yes, no, NULL);
 
560
 
 
561
        if (flags & FLAG_DEFAULT_NO)
 
562
            newtFormSetCurrent(form, no);
 
563
    }
 
564
 
 
565
    if ( type != MSGBOX_INFO ) {
 
566
        if (newtRunForm(form) == NULL)
 
567
                rc = DLG_ESCAPE;
 
568
 
 
569
        answer = newtFormGetCurrent(form);
 
570
 
 
571
        if (answer == no)
 
572
            return DLG_CANCEL;
 
573
    }
 
574
    else {
 
575
        newtDrawForm(form);
 
576
        newtRefresh();
 
577
    }
 
578
 
 
579
    newtFormDestroy(form);
 
580
 
 
581
    return rc;
 
582
}
 
583
 
 
584
void useFullButtons(int state) {
 
585
    if (state) {
 
586
        buttonHeight = 3;
 
587
        makeButton = newtButton;
 
588
   } else {
 
589
        buttonHeight = 1;
 
590
        makeButton = newtCompactButton;
 
591
   }
 
592
}
 
593
 
 
594
void setButtonText(const char * text, int button) {
 
595
    if (button < 0 || button >= BUTTONS)
 
596
        return;
 
597
    buttonText[button] = text;
 
598
}