dmenu.c (15091) | dmenu.c (15242) |
---|---|
1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last attempt in the `sysinstall' line, the next 5 * generation being slated for what's essentially a complete rewrite. 6 * | 1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last attempt in the `sysinstall' line, the next 5 * generation being slated for what's essentially a complete rewrite. 6 * |
7 * $Id: dmenu.c,v 1.14 1996/03/02 07:31:51 jkh Exp $ | 7 * $Id: dmenu.c,v 1.15 1996/04/07 03:52:23 jkh Exp $ |
8 * 9 * Copyright (c) 1995 10 * Jordan Hubbard. All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer, 17 * verbatim and that no modifications are made prior to this 18 * point in the file. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. | 8 * 9 * Copyright (c) 1995 10 * Jordan Hubbard. All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer, 17 * verbatim and that no modifications are made prior to this 18 * point in the file. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. |
22 * 3. All advertising materials mentioning features or use of this software 23 * must display the following acknowledgement: 24 * This product includes software developed by Jordan Hubbard 25 * for the FreeBSD Project. 26 * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to 27 * endorse or promote products derived from this software without specific 28 * prior written permission. | |
29 * 30 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND 31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) --- 10 unchanged lines hidden (view full) --- 47#define MAX_MENU 15 48 49static Boolean cancelled; 50 51int 52dmenuDisplayFile(dialogMenuItem *tmp) 53{ 54 systemDisplayHelp((char *)tmp->data); | 22 * 23 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) --- 10 unchanged lines hidden (view full) --- 40#define MAX_MENU 15 41 42static Boolean cancelled; 43 44int 45dmenuDisplayFile(dialogMenuItem *tmp) 46{ 47 systemDisplayHelp((char *)tmp->data); |
55 return RET_SUCCESS; | 48 return DITEM_SUCCESS; |
56} 57 58int 59dmenuSubmenu(dialogMenuItem *tmp) 60{ | 49} 50 51int 52dmenuSubmenu(dialogMenuItem *tmp) 53{ |
54 WINDOW *w; 55 56 w = savescr(); |
|
61 dialog_clear(); | 57 dialog_clear(); |
62 return dmenuOpenSimple((DMenu *)tmp->data); | 58 (void)dmenuOpenSimple((DMenu *)tmp->data); 59 restorescr(w); 60 return DITEM_SUCCESS; |
63} 64 65int 66dmenuSystemCommand(dialogMenuItem *tmp) 67{ | 61} 62 63int 64dmenuSystemCommand(dialogMenuItem *tmp) 65{ |
68 int i; | 66 WINDOW *w; |
69 | 67 |
70 i = systemExecute((char *)tmp->data) ? RET_FAIL : RET_SUCCESS; | 68 w = savescr(); 69 systemExecute((char *)tmp->data); |
71 dialog_clear(); | 70 dialog_clear(); |
72 return i; | 71 restorescr(w); 72 return DITEM_SUCCESS; |
73} 74 75int 76dmenuSystemCommandBox(dialogMenuItem *tmp) 77{ | 73} 74 75int 76dmenuSystemCommandBox(dialogMenuItem *tmp) 77{ |
78 WINDOW *w; 79 80 w = savescr(); |
|
78 use_helpfile(NULL); 79 use_helpline("Select OK to dismiss this dialog"); 80 dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1); 81 dialog_clear(); | 81 use_helpfile(NULL); 82 use_helpline("Select OK to dismiss this dialog"); 83 dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1); 84 dialog_clear(); |
82 return RET_SUCCESS; | 85 restorescr(w); 86 return DITEM_SUCCESS; |
83} 84 85int 86dmenuCancel(dialogMenuItem *tmp) 87{ 88 cancelled = TRUE; | 87} 88 89int 90dmenuCancel(dialogMenuItem *tmp) 91{ 92 cancelled = TRUE; |
89 return RET_SUCCESS; | 93 return DITEM_LEAVE_MENU; |
90} 91 92int 93dmenuSetVariable(dialogMenuItem *tmp) 94{ 95 variable_set((char *)tmp->data); 96 msgInfo("Set %s", tmp->data); | 94} 95 96int 97dmenuSetVariable(dialogMenuItem *tmp) 98{ 99 variable_set((char *)tmp->data); 100 msgInfo("Set %s", tmp->data); |
97 return RET_SUCCESS; | 101 return DITEM_SUCCESS; |
98} 99 100int 101dmenuSetFlag(dialogMenuItem *tmp) 102{ | 102} 103 104int 105dmenuSetFlag(dialogMenuItem *tmp) 106{ |
103 *((unsigned int *)tmp->data) |= tmp->aux; 104 return RET_SUCCESS; | 107 if (*((unsigned int *)tmp->data) & tmp->aux) 108 *((unsigned int *)tmp->data) &= ~tmp->aux; 109 else 110 *((unsigned int *)tmp->data) |= tmp->aux; 111 return DITEM_SUCCESS; |
105} 106 107int 108dmenuSetValue(dialogMenuItem *tmp) 109{ 110 *((unsigned int *)tmp->data) = tmp->aux; | 112} 113 114int 115dmenuSetValue(dialogMenuItem *tmp) 116{ 117 *((unsigned int *)tmp->data) = tmp->aux; |
111 return RET_SUCCESS; | 118 return DITEM_SUCCESS; |
112} 113 114/* Traverse menu but give user no control over positioning */ 115Boolean 116dmenuOpenSimple(DMenu *menu) 117{ 118 int choice, scroll, curr, max; 119 --- 63 unchanged lines hidden (view full) --- 183 while (1) { 184 char buf[FILENAME_MAX]; 185 186 /* Any helpful hints, put 'em up! */ 187 use_helpline(menu->helpline); 188 use_helpfile(systemHelpFile(menu->helpfile, buf)); 189 190 /* Pop up that dialog! */ | 119} 120 121/* Traverse menu but give user no control over positioning */ 122Boolean 123dmenuOpenSimple(DMenu *menu) 124{ 125 int choice, scroll, curr, max; 126 --- 63 unchanged lines hidden (view full) --- 190 while (1) { 191 char buf[FILENAME_MAX]; 192 193 /* Any helpful hints, put 'em up! */ 194 use_helpline(menu->helpline); 195 use_helpfile(systemHelpFile(menu->helpfile, buf)); 196 197 /* Pop up that dialog! */ |
191 if (menu->type == DMENU_NORMAL_TYPE) | 198 if (menu->type & DMENU_NORMAL_TYPE) |
192 rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, 193 menu_height(menu, n), -n, menu->items, NULL, choice, scroll); 194 | 199 rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, 200 menu_height(menu, n), -n, menu->items, NULL, choice, scroll); 201 |
195 else if (menu->type == DMENU_RADIO_TYPE) | 202 else if (menu->type & DMENU_RADIO_TYPE) |
196 rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, 197 menu_height(menu, n), -n, menu->items, NULL); 198 | 203 rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, 204 menu_height(menu, n), -n, menu->items, NULL); 205 |
199 else if (menu->type == DMENU_CHECKLIST_TYPE) | 206 else if (menu->type & DMENU_CHECKLIST_TYPE) |
200 rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, 201 menu_height(menu, n), -n, menu->items, NULL); | 207 rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, 208 menu_height(menu, n), -n, menu->items, NULL); |
209 else 210 msgFatal("Menu: `%s' is of an unknown type\n", menu->title); |
|
202 203 /* This seems to be the only technique that works for getting the display to look right */ 204 dialog_clear(); | 211 212 /* This seems to be the only technique that works for getting the display to look right */ 213 dialog_clear(); |
205 if (rval) | 214 if (rval || menu->type & (DMENU_SELECTION_RETURNS | DMENU_RADIO_TYPE | DMENU_CHECKLIST_TYPE)) |
206 return FALSE; 207 else if (cancelled) { 208 cancelled = FALSE; 209 return TRUE; 210 } 211 } 212} | 215 return FALSE; 216 else if (cancelled) { 217 cancelled = FALSE; 218 return TRUE; 219 } 220 } 221} |