Changeset f102b57751534d544f1270a3c10a048a29b3b3b7
- Timestamp:
- 11/09/07 12:55:01 (1 year ago)
- git-parent:
- Files:
-
- lxdialog/checklist.c (modified) (11 diffs)
- lxdialog/dialog.h (modified) (3 diffs)
- lxdialog/inputbox.c (modified) (5 diffs)
- lxdialog/lxdialog.c (modified) (6 diffs)
- lxdialog/menubox.c (modified) (20 diffs)
- lxdialog/msgbox.c (modified) (3 diffs)
- lxdialog/textbox.c (modified) (11 diffs)
- lxdialog/util.c (modified) (12 diffs)
- lxdialog/yesno.c (modified) (2 diffs)
- modules/codec/xvmc/cpu_accel.c (modified) (2 diffs)
- modules/codec/xvmc/decode.c (modified) (1 diff)
- modules/codec/xvmc/header.c (modified) (5 diffs)
- modules/codec/xvmc/motion_comp.c (modified) (2 diffs)
- modules/codec/xvmc/motion_comp_mmx.c (modified) (71 diffs)
- modules/codec/xvmc/mpeg2.h (modified) (4 diffs)
- modules/codec/xvmc/mpeg2_internal.h (modified) (3 diffs)
- modules/codec/xvmc/slice.c (modified) (5 diffs)
- modules/codec/xvmc/slice_xvmc_vld.c (modified) (3 diffs)
- modules/codec/xvmc/vlc.h (modified) (2 diffs)
- modules/codec/xvmc/xxmc-config.h (modified) (4 diffs)
- modules/codec/xvmc/xxmc.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lxdialog/checklist.c
r6ee1e19 rf102b57 31 31 static void 32 32 print_item (WINDOW * win, const char *item, int status, 33 int choice, int selected)33 int choice, int selected) 34 34 { 35 35 int i; … … 39 39 wmove (win, choice, 0); 40 40 for (i = 0; i < list_width; i++) 41 waddch (win, ' ');41 waddch (win, ' '); 42 42 43 43 wmove (win, choice, check_x); 44 44 wattrset (win, selected ? check_selected_attr : check_attr); 45 45 if (checkflag == FLAG_CHECK) 46 wprintw (win, "[%c]", status ? 'X' : ' ');46 wprintw (win, "[%c]", status ? 'X' : ' '); 47 47 else 48 wprintw (win, "(%c)", status ? 'X' : ' ');48 wprintw (win, "(%c)", status ? 'X' : ' '); 49 49 50 50 wattrset (win, selected ? tag_selected_attr : tag_attr); … … 53 53 waddstr (win, (char *)item+1); 54 54 if (selected) { 55 wmove (win, choice, check_x+1);56 wrefresh (win);55 wmove (win, choice, check_x+1); 56 wrefresh (win); 57 57 } 58 58 } … … 63 63 static void 64 64 print_arrows (WINDOW * win, int choice, int item_no, int scroll, 65 int y, int x, int height)65 int y, int x, int height) 66 66 { 67 67 wmove(win, y, x); 68 68 69 69 if (scroll > 0) { 70 wattrset (win, uarrow_attr);71 waddch (win, ACS_UARROW);72 waddstr (win, "(-)");70 wattrset (win, uarrow_attr); 71 waddch (win, ACS_UARROW); 72 waddstr (win, "(-)"); 73 73 } 74 74 else { 75 wattrset (win, menubox_attr);76 waddch (win, ACS_HLINE);77 waddch (win, ACS_HLINE);78 waddch (win, ACS_HLINE);79 waddch (win, ACS_HLINE);75 wattrset (win, menubox_attr); 76 waddch (win, ACS_HLINE); 77 waddch (win, ACS_HLINE); 78 waddch (win, ACS_HLINE); 79 waddch (win, ACS_HLINE); 80 80 } 81 81 … … 84 84 85 85 if ((height < item_no) && (scroll + choice < item_no - 1)) { 86 wattrset (win, darrow_attr);87 waddch (win, ACS_DARROW);88 waddstr (win, "(+)");86 wattrset (win, darrow_attr); 87 waddch (win, ACS_DARROW); 88 waddstr (win, "(+)"); 89 89 } 90 90 else { 91 wattrset (win, menubox_border_attr);92 waddch (win, ACS_HLINE);93 waddch (win, ACS_HLINE);94 waddch (win, ACS_HLINE);95 waddch (win, ACS_HLINE);91 wattrset (win, menubox_border_attr); 92 waddch (win, ACS_HLINE); 93 waddch (win, ACS_HLINE); 94 waddch (win, ACS_HLINE); 95 waddch (win, ACS_HLINE); 96 96 } 97 97 } … … 119 119 int 120 120 dialog_checklist (const char *title, const char *prompt, int height, int width, 121 int list_height, int item_no, const char * const * items, int flag)122 121 int list_height, int item_no, const char * const * items, int flag) 122 123 123 { 124 124 int i, x, y, box_x, box_y; … … 130 130 /* Allocate space for storing item on/off status */ 131 131 if ((status = malloc (sizeof (int) * item_no)) == NULL) { 132 endwin ();133 fprintf (stderr,134 "\nCan't allocate memory in dialog_checklist().\n");135 exit (-1);132 endwin (); 133 fprintf (stderr, 134 "\nCan't allocate memory in dialog_checklist().\n"); 135 exit (-1); 136 136 } 137 137 138 138 /* Initializes status */ 139 139 for (i = 0; i < item_no; i++) { 140 status[i] = !strcasecmp (items[i * 3 + 2], "on");141 if (!choice && status[i])140 status[i] = !strcasecmp (items[i * 3 + 2], "on"); 141 if (!choice && status[i]) 142 142 choice = i; 143 143 } … … 158 158 mvwaddch (dialog, height-3, 0, ACS_LTEE); 159 159 for (i = 0; i < width - 2; i++) 160 waddch (dialog, ACS_HLINE);160 waddch (dialog, ACS_HLINE); 161 161 wattrset (dialog, dialog_attr); 162 162 waddch (dialog, ACS_RTEE); 163 163 164 164 if (title != NULL && strlen(title) >= width-2 ) { 165 /* truncate long title -- mec */166 char * title2 = malloc(width-2+1);167 memcpy( title2, title, width-2 );168 title2[width-2] = '\0';169 title = title2;165 /* truncate long title -- mec */ 166 char * title2 = malloc(width-2+1); 167 memcpy( title2, title, width-2 ); 168 title2[width-2] = '\0'; 169 title = title2; 170 170 } 171 171 172 172 if (title != NULL) { 173 wattrset (dialog, title_attr);174 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');175 waddstr (dialog, (char *)title);176 waddch (dialog, ' ');173 wattrset (dialog, title_attr); 174 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); 175 waddstr (dialog, (char *)title); 176 waddch (dialog, ' '); 177 177 } 178 178 … … 191 191 /* draw a box around the list items */ 192 192 draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, 193 menubox_border_attr, menubox_attr);193 menubox_border_attr, menubox_attr); 194 194 195 195 /* Find length of longest item in order to center checklist */ 196 196 check_x = 0; 197 for (i = 0; i < item_no; i++) 198 check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4);197 for (i = 0; i < item_no; i++) 198 check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4); 199 199 200 200 check_x = (list_width - check_x) / 2; … … 202 202 203 203 if (choice >= list_height) { 204 scroll = choice - list_height + 1;205 choice -= scroll;204 scroll = choice - list_height + 1; 205 choice -= scroll; 206 206 } 207 207 208 208 /* Print the list */ 209 209 for (i = 0; i < max_choice; i++) { 210 print_item (list, items[(scroll+i) * 3 + 1],211 status[i+scroll], i, i == choice);210 print_item (list, items[(scroll+i) * 3 + 1], 211 status[i+scroll], i, i == choice); 212 212 } 213 213 214 214 print_arrows(dialog, choice, item_no, scroll, 215 box_y, box_x + check_x + 5, list_height);215 box_y, box_x + check_x + 5, list_height); 216 216 217 217 print_buttons(dialog, height, width, 0); … … 222 222 223 223 while (key != ESC) { 224 key = wgetch (dialog);225 226 for (i = 0; i < max_choice; i++)224 key = wgetch (dialog); 225 226 for (i = 0; i < max_choice; i++) 227 227 if (toupper(key) == toupper(items[(scroll+i)*3+1][0])) 228 228 break; 229 229 230 230 231 if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || 232 key == '+' || key == '-' ) { 233 if (key == KEY_UP || key == '-') { 234 if (!choice) { 235 if (!scroll) 236 continue; 237 /* Scroll list down */ 238 if (list_height > 1) { 239 /* De-highlight current first item */ 240 print_item (list, items[scroll * 3 + 1], 241 status[scroll], 0, FALSE); 242 scrollok (list, TRUE); 243 wscrl (list, -1); 244 scrollok (list, FALSE); 231 if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || 232 key == '+' || key == '-' ) { 233 if (key == KEY_UP || key == '-') { 234 if (!choice) { 235 if (!scroll) 236 continue; 237 /* Scroll list down */ 238 if (list_height > 1) { 239 /* De-highlight current first item */ 240 print_item (list, items[scroll * 3 + 1], 241 status[scroll], 0, FALSE); 242 scrollok (list, TRUE); 243 wscrl (list, -1); 244 scrollok (list, FALSE); 245 } 246 scroll--; 247 print_item (list, items[scroll * 3 + 1], 248 status[scroll], 0, TRUE); 249 wnoutrefresh (list); 250 251 print_arrows(dialog, choice, item_no, scroll, 252 box_y, box_x + check_x + 5, list_height); 253 254 wrefresh (dialog); 255 256 continue; /* wait for another key press */ 257 } else 258 i = choice - 1; 259 } else if (key == KEY_DOWN || key == '+') { 260 if (choice == max_choice - 1) { 261 if (scroll + choice >= item_no - 1) 262 continue; 263 /* Scroll list up */ 264 if (list_height > 1) { 265 /* De-highlight current last item before scrolling up */ 266 print_item (list, items[(scroll + max_choice - 1) * 3 + 1], 267 status[scroll + max_choice - 1], 268 max_choice - 1, FALSE); 269 scrollok (list, TRUE); 270 scroll (list); 271 scrollok (list, FALSE); 272 } 273 scroll++; 274 print_item (list, items[(scroll + max_choice - 1) * 3 + 1], 275 status[scroll + max_choice - 1], 276 max_choice - 1, TRUE); 277 wnoutrefresh (list); 278 279 print_arrows(dialog, choice, item_no, scroll, 280 box_y, box_x + check_x + 5, list_height); 281 282 wrefresh (dialog); 283 284 continue; /* wait for another key press */ 285 } else 286 i = choice + 1; 287 } 288 if (i != choice) { 289 /* De-highlight current item */ 290 print_item (list, items[(scroll + choice) * 3 + 1], 291 status[scroll + choice], choice, FALSE); 292 /* Highlight new item */ 293 choice = i; 294 print_item (list, items[(scroll + choice) * 3 + 1], 295 status[scroll + choice], choice, TRUE); 296 wnoutrefresh (list); 297 wrefresh (dialog); 298 } 299 continue; /* wait for another key press */ 300 } 301 switch (key) { 302 case 'H': 303 case 'h': 304 case '?': 305 delwin (dialog); 306 free (status); 307 return 1; 308 case TAB: 309 case KEY_LEFT: 310 case KEY_RIGHT: 311 button = ((key == KEY_LEFT ? --button : ++button) < 0) 312 ? 1 : (button > 1 ? 0 : button); 313 314 print_buttons(dialog, height, width, button); 315 wrefresh (dialog); 316 break; 317 case 'S': 318 case 's': 319 case ' ': 320 case '\n': 321 if (!button) { 322 if (flag == FLAG_CHECK) { 323 status[scroll + choice] = !status[scroll + choice]; 324 wmove (list, choice, check_x); 325 wattrset (list, check_selected_attr); 326 wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); 327 } else { 328 if (!status[scroll + choice]) { 329 for (i = 0; i < item_no; i++) 330 status[i] = 0; 331 status[scroll + choice] = 1; 332 for (i = 0; i < max_choice; i++) 333 print_item (list, items[(scroll + i) * 3 + 1], 334 status[scroll + i], i, i == choice); 335 } 336 } 337 wnoutrefresh (list); 338 wrefresh (dialog); 339 340 for (i = 0; i < item_no; i++) { 341 if (status[i]) { 342 if (flag == FLAG_CHECK) { 343 fprintf (stderr, "\"%s\" ", items[i * 3]); 344 } else { 345 fprintf (stderr, "%s", items[i * 3]); 346 } 347 348 } 349 } 245 350 } 246 scroll--; 247 print_item (list, items[scroll * 3 + 1], 248 status[scroll], 0, TRUE); 249 wnoutrefresh (list); 250 251 print_arrows(dialog, choice, item_no, scroll, 252 box_y, box_x + check_x + 5, list_height); 253 254 wrefresh (dialog); 255 256 continue; /* wait for another key press */ 257 } else 258 i = choice - 1; 259 } else if (key == KEY_DOWN || key == '+') { 260 if (choice == max_choice - 1) { 261 if (scroll + choice >= item_no - 1) 262 continue; 263 /* Scroll list up */ 264 if (list_height > 1) { 265 /* De-highlight current last item before scrolling up */ 266 print_item (list, items[(scroll + max_choice - 1) * 3 + 1], 267 status[scroll + max_choice - 1], 268 max_choice - 1, FALSE); 269 scrollok (list, TRUE); 270 scroll (list); 271 scrollok (list, FALSE); 272 } 273 scroll++; 274 print_item (list, items[(scroll + max_choice - 1) * 3 + 1], 275 status[scroll + max_choice - 1], 276 max_choice - 1, TRUE); 277 wnoutrefresh (list); 278 279 print_arrows(dialog, choice, item_no, scroll, 280 box_y, box_x + check_x + 5, list_height); 281 282 wrefresh (dialog); 283 284 continue; /* wait for another key press */ 285 } else 286 i = choice + 1; 287 } 288 if (i != choice) { 289 /* De-highlight current item */ 290 print_item (list, items[(scroll + choice) * 3 + 1], 291 status[scroll + choice], choice, FALSE); 292 /* Highlight new item */ 293 choice = i; 294 print_item (list, items[(scroll + choice) * 3 + 1], 295 status[scroll + choice], choice, TRUE); 296 wnoutrefresh (list); 297 wrefresh (dialog); 298 } 299 continue; /* wait for another key press */ 300 } 301 switch (key) { 302 case 'H': 303 case 'h': 304 case '?': 305 delwin (dialog); 306 free (status); 307 return 1; 308 case TAB: 309 case KEY_LEFT: 310 case KEY_RIGHT: 311 button = ((key == KEY_LEFT ? --button : ++button) < 0) 312 ? 1 : (button > 1 ? 0 : button); 313 314 print_buttons(dialog, height, width, button); 315 wrefresh (dialog); 316 break; 317 case 'S': 318 case 's': 319 case ' ': 320 case '\n': 321 if (!button) { 322 if (flag == FLAG_CHECK) { 323 status[scroll + choice] = !status[scroll + choice]; 324 wmove (list, choice, check_x); 325 wattrset (list, check_selected_attr); 326 wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); 327 } else { 328 if (!status[scroll + choice]) { 329 for (i = 0; i < item_no; i++) 330 status[i] = 0; 331 status[scroll + choice] = 1; 332 for (i = 0; i < max_choice; i++) 333 print_item (list, items[(scroll + i) * 3 + 1], 334 status[scroll + i], i, i == choice); 335 } 336 } 337 wnoutrefresh (list); 338 wrefresh (dialog); 339 340 for (i = 0; i < item_no; i++) { 341 if (status[i]) { 342 if (flag == FLAG_CHECK) { 343 fprintf (stderr, "\"%s\" ", items[i * 3]); 344 } else { 345 fprintf (stderr, "%s", items[i * 3]); 346 } 347 348 } 349 } 350 } 351 delwin (dialog); 352 free (status); 353 return button; 354 case 'X': 355 case 'x': 356 key = ESC; 357 case ESC: 358 break; 359 } 360 361 /* Now, update everything... */ 362 doupdate (); 363 } 364 351 delwin (dialog); 352 free (status); 353 return button; 354 case 'X': 355 case 'x': 356 key = ESC; 357 case ESC: 358 break; 359 } 360 361 /* Now, update everything... */ 362 doupdate (); 363 } 364 365 365 366 366 delwin (dialog); 367 367 free (status); 368 return -1; /* ESC pressed */368 return -1; /* ESC pressed */ 369 369 } lxdialog/dialog.h
r6ee1e19 rf102b57 86 86 #endif 87 87 88 /* 88 /* 89 89 * Attribute names 90 90 */ … … 147 147 void print_button (WINDOW * win, const char *label, int y, int x, int selected); 148 148 void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, 149 chtype border);149 chtype border); 150 150 void draw_shadow (WINDOW * win, int y, int x, int height, int width); 151 151 … … 153 153 int dialog_yesno (const char *title, const char *prompt, int height, int width); 154 154 int dialog_msgbox (const char *title, const char *prompt, int height, 155 int width, int pause);155 int width, int pause); 156 156 int dialog_textbox (const char *title, const char *file, int height, int width); 157 157 int dialog_menu (const char *title, const char *prompt, int height, int width, 158 int menu_height, const char *choice, int item_no, 159 const char * const * items);158 int menu_height, const char *choice, int item_no, 159 const char * const * items); 160 160 int dialog_checklist (const char *title, const char *prompt, int height, 161 int width, int list_height, int item_no,162 const char * const * items, int flag);161 int width, int list_height, int item_no, 162 const char * const * items, int flag); 163 163 extern unsigned char dialog_input_result[]; 164 164 int dialog_inputbox (const char *title, const char *prompt, int height, 165 int width, const char *init);165 int width, const char *init); 166 166 167 167 /* lxdialog/inputbox.c
r6ee1e19 rf102b57 45 45 int 46 46 dialog_inputbox (const char *title, const char *prompt, int height, int width, 47 const char *init)47 const char *init) 48 48 { 49 49 int i, x, y, box_y, box_x, box_width; … … 66 66 mvwaddch (dialog, height-3, 0, ACS_LTEE); 67 67 for (i = 0; i < width - 2; i++) 68 waddch (dialog, ACS_HLINE);68 waddch (dialog, ACS_HLINE); 69 69 wattrset (dialog, dialog_attr); 70 70 waddch (dialog, ACS_RTEE); 71 71 72 72 if (title != NULL && strlen(title) >= width-2 ) { 73 /* truncate long title -- mec */74 char * title2 = malloc(width-2+1);75 memcpy( title2, title, width-2 );76 title2[width-2] = '\0';77 title = title2;73 /* truncate long title -- mec */ 74 char * title2 = malloc(width-2+1); 75 memcpy( title2, title, width-2 ); 76 title2[width-2] = '\0'; 77 title = title2; 78 78 } 79 79 80 80 if (title != NULL) { 81 wattrset (dialog, title_attr);82 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');83 waddstr (dialog, (char *)title);84 waddch (dialog, ' ');81 wattrset (dialog, title_attr); 82 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); 83 waddstr (dialog, (char *)title); 84 waddch (dialog, ' '); 85 85 } 86 86 … … 94 94 box_x = (width - box_width) / 2; 95 95 draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, 96 border_attr, dialog_attr);96 border_attr, dialog_attr); 97 97 98 98 print_buttons(dialog, height, width, 0); … … 103 103 104 104 if (!init) 105 instr[0] = '\0';105 instr[0] = '\0'; 106 106 else 107 strcpy (instr, init);107 strcpy (instr, init); 108 108 109 109 input_x = strlen (instr); 110 110 111 111 if (input_x >= box_width) { 112 scroll = input_x - box_width + 1;113 input_x = box_width - 1;114 for (i = 0; i < box_width - 1; i++)115 waddch (dialog, instr[scroll + i]);112 scroll = input_x - box_width + 1; 113 input_x = box_width - 1; 114 for (i = 0; i < box_width - 1; i++) 115 waddch (dialog, instr[scroll + i]); 116 116 } else 117 waddstr (dialog, instr);117 waddstr (dialog, instr); 118 118 119 119 wmove (dialog, box_y, box_x + input_x); … … 122 122 123 123 while (key != ESC) { 124 key = wgetch (dialog); 125 126 if (button == -1) { /* Input box selected */ 127 switch (key) { 128 case TAB: 129 case KEY_UP: 130 case KEY_DOWN: 131 break; 132 case KEY_LEFT: 133 continue; 134 case KEY_RIGHT: 135 continue; 136 case KEY_BACKSPACE: 137 case 127: 138 if (input_x || scroll) { 139 wattrset (dialog, inputbox_attr); 140 if (!input_x) { 141 scroll = scroll < box_width - 1 ? 142 0 : scroll - (box_width - 1); 143 wmove (dialog, box_y, box_x); 144 for (i = 0; i < box_width; i++) 145 waddch (dialog, instr[scroll + input_x + i] ? 146 instr[scroll + input_x + i] : ' '); 147 input_x = strlen (instr) - scroll; 148 } else 149 input_x--; 150 instr[scroll + input_x] = '\0'; 151 mvwaddch (dialog, box_y, input_x + box_x, ' '); 152 wmove (dialog, box_y, input_x + box_x); 153 wrefresh (dialog); 154 } 155 continue; 156 default: 157 if (key < 0x100 && isprint (key)) { 158 if (scroll + input_x < MAX_LEN) { 159 wattrset (dialog, inputbox_attr); 160 instr[scroll + input_x] = key; 161 instr[scroll + input_x + 1] = '\0'; 162 if (input_x == box_width - 1) { 163 scroll++; 164 wmove (dialog, box_y, box_x); 165 for (i = 0; i < box_width - 1; i++) 166 waddch (dialog, instr[scroll + i]); 167 } else { 168 wmove (dialog, box_y, input_x++ + box_x); 169 waddch (dialog, key); 170 } 171 wrefresh (dialog); 172 } else 173 flash (); /* Alarm user about overflow */ 174 continue; 175 } 176 } 124 key = wgetch (dialog); 125 126 if (button == -1) { /* Input box selected */ 127 switch (key) { 128 case TAB: 129 case KEY_UP: 130 case KEY_DOWN: 131 break; 132 case KEY_LEFT: 133 continue; 134 case KEY_RIGHT: 135 continue; 136 case KEY_BACKSPACE: 137 case 127: 138 if (input_x || scroll) { 139 wattrset (dialog, inputbox_attr); 140 if (!input_x) { 141 scroll = scroll < box_width - 1 ? 142 0 : scroll - (box_width - 1); 143 wmove (dialog, box_y, box_x); 144 for (i = 0; i < box_width; i++) 145 waddch (dialog, instr[scroll + input_x + i] ? 146 instr[scroll + input_x + i] : ' '); 147 input_x = strlen (instr) - scroll; 148 } else 149 input_x--; 150 instr[scroll + input_x] = '\0'; 151 mvwaddch (dialog, box_y, input_x + box_x, ' '); 152 wmove (dialog, box_y, input_x + box_x); 153 wrefresh (dialog); 154 } 155 continue; 156 default: 157 if (key < 0x100 && isprint (key)) { 158 if (scroll + input_x < MAX_LEN) { 159 wattrset (dialog, inputbox_attr); 160 instr[scroll + input_x] = key; 161 instr[scroll + input_x + 1] = '\0'; 162 if (input_x == box_width - 1) { 163 scroll++; 164 wmove (dialog, box_y, box_x); 165 for (i = 0; i < box_width - 1; i++) 166 waddch (dialog, instr[scroll + i]); 167 } else { 168 wmove (dialog, box_y, input_x++ + box_x); 169 waddch (dialog, key); 170 } 171 wrefresh (dialog); 172 } else 173 flash (); /* Alarm user about overflow */ 174 continue; 175 } 176 } 177 } 178 switch (key) { 179 case 'O': 180 case 'o': 181 delwin (dialog); 182 return 0; 183 case 'H': 184 case 'h': 185 delwin (dialog); 186 return 1; 187 case KEY_UP: 188 case KEY_LEFT: 189 switch (button) { 190 case -1: 191 button = 1; /* Indicates "Cancel" button is selected */ 192 print_buttons(dialog, height, width, 1); 193 break; 194 case 0: 195 button = -1; /* Indicates input box is selected */ 196 print_buttons(dialog, height, width, 0); 197 wmove (dialog, box_y, box_x + input_x); 198 wrefresh (dialog); 199 break; 200 case 1: 201 button = 0; /* Indicates "OK" button is selected */ 202 print_buttons(dialog, height, width, 0); 203 break; 204 } 205 break; 206 case TAB: 207 case KEY_DOWN: 208 case KEY_RIGHT: 209 switch (button) { 210 case -1: 211 button = 0; /* Indicates "OK" button is selected */ 212 print_buttons(dialog, height, width, 0); 213 break; 214 case 0: 215 button = 1; /* Indicates "Cancel" button is selected */ 216 print_buttons(dialog, height, width, 1); 217 break; 218 case 1: 219 button = -1; /* Indicates input box is selected */ 220 print_buttons(dialog, height, width, 0); 221 wmove (dialog, box_y, box_x + input_x); 222 wrefresh (dialog); 223 break; 224 } 225 break; 226 case ' ': 227 case '\n': 228 delwin (dialog); 229 return (button == -1 ? 0 : button); 230 case 'X': 231 case 'x': 232 key = ESC; 233 case ESC: 234 break; 235 } 177 236 } 178 switch (key) {179 case 'O':180 case 'o':181 delwin (dialog);182 return 0;183 case 'H':184 case 'h':185 delwin (dialog);186 return 1;187 case KEY_UP:188 case KEY_LEFT:189 switch (button) {190 case -1:191 button = 1; /* Indicates "Cancel" button is selected */192 print_buttons(dialog, height, width, 1);193 break;194 case 0:195 button = -1; /* Indicates input box is selected */196 print_buttons(dialog, height, width, 0);197 wmove (dialog, box_y, box_x + input_x);198 wrefresh (dialog);199 break;200 case 1:201 button = 0; /* Indicates "OK" button is selected */202 print_buttons(dialog, height, width, 0);203 break;204 }205 break;206 case TAB:207 case KEY_DOWN:208 case KEY_RIGHT:209 switch (button) {210 case -1:211 button = 0; /* Indicates "OK" button is selected */212 print_buttons(dialog, height, width, 0);213 break;214 case 0:215 button = 1; /* Indicates "Cancel" button is selected */216 print_buttons(dialog, height, width, 1);217 break;218 case 1:219 button = -1; /* Indicates input box is selected */220 print_buttons(dialog, height, width, 0);221 wmove (dialog, box_y, box_x + input_x);222 wrefresh (dialog);223 break;224 }225 break;226 case ' ':227 case '\n':228 delwin (dialog);229 return (button == -1 ? 0 : button);230 case 'X':231 case 'x':232 key = ESC;233 case ESC:234 break;235 }236 }237 237 238 238 delwin (dialog); 239 return -1; /* ESC pressed */239 return -1; /* ESC pressed */ 240 240 } lxdialog/lxdialog.c
r6ee1e19 rf102b57 68 68 #endif 69 69 if (argc < 2) { 70 Usage (argv[0]);71 exit (-1);72 } 73 74 while (offset < argc - 1 && !end_common_opts) { /* Common options */75 if (!strcmp (argv[offset + 1], "--title")) {76 if (argc - offset < 3 || title != NULL) {77 Usage (argv[0]);78 exit (-1);79 } else {80 title = argv[offset + 2];81 offset += 2;82 }70 Usage (argv[0]); 71 exit (-1); 72 } 73 74 while (offset < argc - 1 && !end_common_opts) { /* Common options */ 75 if (!strcmp (argv[offset + 1], "--title")) { 76 if (argc - offset < 3 || title != NULL) { 77 Usage (argv[0]); 78 exit (-1); 79 } else { 80 title = argv[offset + 2]; 81 offset += 2; 82 } 83 83 } else if (!strcmp (argv[offset + 1], "--backtitle")) { 84 84 if (backtitle != NULL) { … … 89 89 offset += 2; 90 90 } 91 } else if (!strcmp (argv[offset + 1], "--clear")) {92 if (clear_screen) {/* Hey, "--clear" can't appear twice! */93 Usage (argv[0]);94 exit (-1);95 } else if (argc == 2) {/* we only want to clear the screen */96 init_dialog ();97 refresh ();/* init_dialog() will clear the screen for us */98 end_dialog ();99 return 0;100 } else {101 clear_screen = 1;102 offset++;103 }104 } else/* no more common options */105 end_common_opts = 1;106 } 107 108 if (argc - 1 == offset) { /* no more options */109 Usage (argv[0]);110 exit (-1);91 } else if (!strcmp (argv[offset + 1], "--clear")) { 92 if (clear_screen) { /* Hey, "--clear" can't appear twice! */ 93 Usage (argv[0]); 94 exit (-1); 95 } else if (argc == 2) { /* we only want to clear the screen */ 96 init_dialog (); 97 refresh (); /* init_dialog() will clear the screen for us */ 98 end_dialog (); 99 return 0; 100 } else { 101 clear_screen = 1; 102 offset++; 103 } 104 } else /* no more common options */ 105 end_common_opts = 1; 106 } 107 108 if (argc - 1 == offset) { /* no more options */ 109 Usage (argv[0]); 110 exit (-1); 111 111 } 112 112 /* use a table to look for the requested mode, to avoid code duplication */ 113 113 114 for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */115 if (!strcmp (argv[offset + 1], modePtr->name))116 break;114 for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ 115 if (!strcmp (argv[offset + 1], modePtr->name)) 116 break; 117 117 118 118 if (!modePtr->name) 119 Usage (argv[0]);119 Usage (argv[0]); 120 120 if (argc - offset < modePtr->argmin) 121 Usage (argv[0]);121 Usage (argv[0]); 122 122 if (modePtr->argmax && argc - offset > modePtr->argmax) 123 Usage (argv[0]);123 Usage (argv[0]); 124 124 125 125 … … 128 128 retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); 129 129 130 if (clear_screen) { /* clear screen before exit */131 attr_clear (stdscr, LINES, COLS, screen_attr);132 refresh ();130 if (clear_screen) { /* clear screen before exit */ 131 attr_clear (stdscr, LINES, COLS, screen_attr); 132 refresh (); 133 133 } 134 134 end_dialog(); … … 174 174 { 175 175 return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]), 176 atoi (av[5]), av[6], (ac - 6) / 2, av + 7);176 atoi (av[5]), av[6], (ac - 6) / 2, av + 7); 177 177 } 178 178 … … 181 181 { 182 182 return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), 183 atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);183 atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); 184 184 } 185 185 … … 188 188 { 189 189 return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), 190 atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);190 atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); 191 191 } 192 192 lxdialog/menubox.c
r6ee1e19 rf102b57 27 27 * *) A bugfix for the Page-Down problem 28 28 * 29 * *) Formerly when I used Page Down and Page Up, the cursor would be set 29 * *) Formerly when I used Page Down and Page Up, the cursor would be set 30 30 * to the first position in the menu box. Now lxdialog is a bit 31 31 * smarter and works more like other menu systems (just have a look at … … 81 81 int i; 82 82 for (i = 0; i < menu_width; i++) 83 waddch (win, ' ');83 waddch (win, ' '); 84 84 } 85 85 #else … …  
