Subversion Repositories SvarDOS

Rev

Rev 1946 | Rev 1949 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1946 Rev 1948
Line 199... Line 199...
199
}
199
}
200
 
200
 
201
 
201
 
202
/* display a menu with items and return user's choice.
202
/* display a menu with items and return user's choice.
203
 * ypos: starting line where the menu is drawn
203
 * ypos: starting line where the menu is drawn
204
 * height: number of items to display inside the menu
204
 * height: max number of items to display inside the menu
205
 * list: NULL-terminated list of items
205
 * list: NULL-terminated list of items
206
 * maxlistlen: limit list to this many items tops */
206
 * maxlistlen: limit list to this many items tops */
207
static int menuselect(unsigned char ypos, unsigned char height, const char **list, int maxlistlen) {
207
static int menuselect(unsigned char ypos, unsigned char height, const char **list, int maxlistlen) {
208
  int i, offset = 0, res = 0, count;
208
  int i, offset = 0, res = 0, count;
209
  unsigned char y, xpos, width = 0;
209
  unsigned char y, xpos, width = 0;
Line 213... Line 213...
213
    int len = strlen(list[count]);
213
    int len = strlen(list[count]);
214
    if (len > width) width = len;
214
    if (len > width) width = len;
215
  }
215
  }
216
  width++; /* it's nice to have a small margin to the right of the widest item */
216
  width++; /* it's nice to have a small margin to the right of the widest item */
217
 
217
 
-
 
218
  /* adjust height if there is less items than max height */
-
 
219
  if (count < height) height = count;
-
 
220
 
218
  /* if xpos negative, means 'center out' */
221
  /* if xpos negative, means 'center out' */
219
  xpos = 39 - (width >> 1);
222
  xpos = 39 - (width >> 1);
220
 
223
 
221
  mdr_cout_char_rep(ypos, xpos, 0xC4, COLOR_SELECT, width + 2);  /* top line */
224
  mdr_cout_char_rep(ypos, xpos, 0xC4, COLOR_SELECT, width + 2);  /* top line */
222
  mdr_cout_char(ypos, xpos+width+2, 0xBF, COLOR_SELECT);         /*       \ */
225
  mdr_cout_char(ypos, xpos+width+2, 0xBF, COLOR_SELECT);         /*       \ */
Line 262... Line 265...
262
    }
265
    }
263
    key = mdr_dos_getkey();
266
    key = mdr_dos_getkey();
264
    if (key == 0x0D) { /* ENTER */
267
    if (key == 0x0D) { /* ENTER */
265
      return(res);
268
      return(res);
266
    } else if (key == 0x148) { /* up */
269
    } else if (key == 0x148) { /* up */
-
 
270
      UP_AGAIN:
267
      if (res > 0) {
271
      if (res > 0) {
268
        res--;
272
        res--;
269
        if (res < offset) offset = res;
273
        if (res < offset) offset = res;
-
 
274
        if (list[res][0] == 0) goto UP_AGAIN;
270
      }
275
      }
271
    } else if (key == 0x150) { /* down */
276
    } else if (key == 0x150) { /* down */
-
 
277
      DOWN_AGAIN:
272
      if (res+1 < count) {
278
      if (res+1 < count) {
273
        res++;
279
        res++;
274
        if (res > offset + height - 1) offset = res - (height - 1);
280
        if (res > offset + height - 1) offset = res - (height - 1);
-
 
281
        if (list[res][0] == 0) goto DOWN_AGAIN;
275
      }
282
      }
276
    } else if (key == 0x147) { /* home */
283
    } else if (key == 0x147) { /* home */
277
      res = 0;
284
      res = 0;
278
      offset = 0;
285
      offset = 0;
279
    } else if (key == 0x14F) { /* end */
286
    } else if (key == 0x14F) { /* end */
Line 779... Line 786...
779
  /* build a menu with all drives */
786
  /* build a menu with all drives */
780
  for (i = 0; i < drvlistlen; i++) {
787
  for (i = 0; i < drvlistlen; i++) {
781
    snprintf(drvlist[i], sizeof(drvlist[0]), "%c: [%u MiB, hd%c%u]", 'A' + drives[i].dosid, drives[i].tot_size, 'a' + drives[i].hd, drives[i].partid);
788
    snprintf(drvlist[i], sizeof(drvlist[0]), "%c: [%u MiB, hd%c%u]", 'A' + drives[i].dosid, drives[i].tot_size, 'a' + drives[i].hd, drives[i].partid);
782
    menulist[i] = drvlist[i];
789
    menulist[i] = drvlist[i];
783
  }
790
  }
-
 
791
  menulist[i++] = "";
784
  menulist[i++] = svarlang_str(0, 2); /* Quit to DOS */
792
  menulist[i++] = svarlang_str(0, 2); /* Quit to DOS */
785
  menulist[i] = NULL;
793
  menulist[i] = NULL;
786
 
794
 
787
  newscreen(0);
795
  newscreen(0);
-
 
796
 
-
 
797
  snprintf(buff, sizeof(buff), "Select the drive where SvarDOS will be installed. You may also return to DOS and use FDISK to partition your disk. Please note that SvarDOS may be installed only on a primary partition (ie. not a logical drive).");
788
  i = menuselect(6 /*ypos*/, i /*height*/, menulist, -1);
798
  i = menuselect(7 + putstringwrap(4, 1, COLOR_BODY, buff) /*ypos*/, 10 /*max-height*/, menulist, -1);
789
  if (i < 0) {
799
  if (i < 0) {
790
    return(MENUPREV);
800
    return(MENUPREV);
791
  } else if (i < drvlistlen) {
801
  } else if (i < drvlistlen) {
792
    /* return a bitfield HHPPLLLLLLLL
802
    /* return a bitfield HHPPLLLLLLLL
793
     * HH = hard drive id (0..3)
803
     * HH = hard drive id (0..3)