1034
1023
menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength,
1035
1024
char *available, int menuType, int current ) {
1036
int i, lmargin = x, ymargin = y;
1039
1028
/* Print available buttons */
1085
1074
if( current == i ) /*attroff( A_REVERSE )*/ standend ();
1087
1076
/* Calculate position for the next item */
1088
if( menuType & MENU_VERT )
1091
if( y >= WARNING_START )
1094
x += itemLength + MENU_SPACING;
1095
if( menuType & MENU_BUTTON ) x += 2;
1100
1077
x += itemLength + MENU_SPACING;
1101
1078
if( menuType & MENU_BUTTON ) x += 2;
1102
1079
if( x > COLUMNS - lmargin - 12 )
1121
1097
char *available, int menuType, int menuDefault ) {
1122
1098
int i, ylast = y, key = 0, current = menuDefault;
1124
if( !( menuType & ( MENU_HORIZ | MENU_VERT ) ) ) {
1125
print_warning(_("Menu without direction. Defaulting to horizontal."));
1126
menuType |= MENU_HORIZ;
1129
1100
/* Make sure that the current is one of the available items */
1130
1101
while( !strchr(available, menuItems[current].key) ) {
1132
1103
if( !menuItems[current].key ) current = 0;
1106
keypad(stdscr, TRUE);
1135
1108
/* Repeat until allowable choice has been made */
1136
1109
while( !key ) {
1137
1110
/* Display the menu and read a command */
1153
1126
move( WARNING_START + 1, 0 );
1156
/* Cursor keys - possibly split by slow connection */
1158
/* Check whether this is a real ESC or one of extended keys */
1159
/*nodelay(stdscr, TRUE);*/
1161
/*nodelay(stdscr, FALSE);*/
1163
if( key == /*ERR*/ ESC ) {
1164
/* This is a real ESC */
1167
if(key == '[' || key == 'O') {
1168
/* This is one extended keys */
1172
case 'A': /* Up arrow */
1175
case 'B': /* Down arrow */
1178
case 'C': /* Right arrow */
1181
case 'D': /* Left arrow */
1182
case 'Z': /* Shift Tab */
1191
/* Enter equals the keyboard shortcut of current menu item */
1193
key = menuItems[current].key;
1195
/* Give alternatives for arrow keys in case the window manager
1199
if (key == UPKEY || key == UPKEYVI) /* ^P or k */
1201
if (key == DOWNKEY || key == DOWNKEYVI) /* ^N or j */
1204
if (key == MENU_UP) {
1205
if( menuType & MENU_VERT ) {
1209
while( menuItems[current+1].key )
1211
} while( !strchr( available, menuItems[current].key ));
1216
if (key == MENU_DOWN) {
1217
if( menuType & MENU_VERT ) {
1220
if( !menuItems[current].key ) current = 0 ;
1221
} while( !strchr( available, menuItems[current].key ));
1226
if (key == MENU_RIGHT) {
1227
if( menuType & MENU_HORIZ ) {
1230
if( !menuItems[current].key )
1232
} while( !strchr( available, menuItems[current].key ));
1237
if (key == MENU_LEFT) {
1238
if( menuType & MENU_HORIZ ) {
1242
while( menuItems[current + 1].key )
1245
} while( !strchr( available, menuItems[current].key ));
1132
/* Select next menu item */
1135
if (!menuItems[current].key)
1137
} while (!strchr(available, menuItems[current].key));
1142
case KEY_BTAB: /* Back tab */
1144
/* Select previous menu item */
1148
while (menuItems[current + 1].key)
1151
} while (!strchr(available, menuItems[current].key));
1157
/* Enter equals the keyboard shortcut of current menu item */
1158
key = menuItems[current].key;
1250
1162
/* Should all keys to be accepted? */
1288
1202
menuSelect(COMMAND_LINE_Y, COMMAND_LINE_X,
1289
menuContinueBtn, 0, "c", MENU_HORIZ | MENU_ACCEPT_OTHERS, 0 );
1203
menuContinueBtn, 0, "c", MENU_ACCEPT_OTHERS, 0 );
1292
1206
/* Function menuSelect takes way too many parameters *
1306
1220
available[i] = 0;
1307
1221
return menuSelect(COMMAND_LINE_Y, COMMAND_LINE_X, menuItems, itemLength,
1308
available, MENU_HORIZ | MENU_BUTTON, menuDefault);
1222
available, MENU_BUTTON, menuDefault);
1311
1225
/* End of command menu support code */
1845
1759
fp_printf(FILE *fp, char *format, ...) {
1847
1761
char buf[1024];
1762
int y, x __attribute__((unused));
1850
1764
va_start(args, format);
1851
1765
vsnprintf(buf, sizeof(buf), format, args);
2683
2597
while (!done) {
2686
(void)draw_cursor(0);
2688
2602
if (p_info[cur_part].id == FREE_SPACE) {
2689
2603
s = ((opentype == O_RDWR) ? "hnpquW" : "hnpqu");
2690
2604
command = menuSelect(COMMAND_LINE_Y, COMMAND_LINE_X, menuMain, 10,
2691
s, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, 5);
2605
s, MENU_BUTTON | MENU_ACCEPT_OTHERS, 5);
2692
2606
} else if (p_info[cur_part].id > 0) {
2693
2607
s = ((opentype == O_RDWR) ? "bdhmpqtuW" : "bdhmpqtu");
2694
2608
command = menuSelect(COMMAND_LINE_Y, COMMAND_LINE_X, menuMain, 10,
2695
s, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, is_first_run ? 7 : 0);
2609
s, MENU_BUTTON | MENU_ACCEPT_OTHERS, is_first_run ? 7 : 0);
2697
2611
s = ((opentype == O_RDWR) ? "hpquW" : "hpqu");
2698
2612
command = menuSelect(COMMAND_LINE_Y, COMMAND_LINE_X, menuMain, 10,
2699
s, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, 0);
2613
s, MENU_BUTTON | MENU_ACCEPT_OTHERS, 0);
2701
2615
is_first_run = FALSE;
2702
2616
switch ( command ) {
2787
2701
display_help();
2790
case MENU_UP : /* Up arrow */
2791
if (!draw_cursor(-1))
2794
print_warning(_("No more partitions"));
2704
case KEY_UP: /* Up arrow key */
2705
case '\020': /* ^P */
2706
case 'k': /* Vi-like alternative */
2796
case MENU_DOWN : /* Down arrow */
2797
if (!draw_cursor(1))
2800
print_warning(_("No more partitions"));
2709
case KEY_DOWN: /* Down arrow key */
2710
case '\016': /* ^N */
2711
case 'j': /* Vi-like alternative */
2802
2714
case REDRAWKEY:
2719
draw_cursor(-cur_part);
2722
draw_cursor(num_parts - cur_part - 1);
2807
2725
print_warning(_("Illegal command"));
2808
2726
putchar(BELL); /* CTRL-G */