diff options
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/sysinstall/editor.c | 147 | ||||
-rw-r--r-- | sbin/sysinstall/editor.h | 1 | ||||
-rw-r--r-- | sbin/sysinstall/label.c | 12 | ||||
-rw-r--r-- | sbin/sysinstall/mbr.c | 18 |
4 files changed, 19 insertions, 159 deletions
diff --git a/sbin/sysinstall/editor.c b/sbin/sysinstall/editor.c index 42867d4..572c18c 100644 --- a/sbin/sysinstall/editor.c +++ b/sbin/sysinstall/editor.c @@ -51,150 +51,3 @@ change_field(struct field field, int key) } return (next); } - -int -edit_line(WINDOW *window, int y, int x, char *field, int width, int maxlen) -{ - int len; - int key = 0; - int fpos, dispos, curpos; - int i; - int done = 0; - - len = strlen(field); - if (len < width) { - fpos = len; - curpos = len; - dispos = 0; - } else { - fpos = width; - curpos = width; - dispos = len - width; - }; - - - do { - wattrset(window, item_selected_attr); - wmove(window, y, x); - for (i=0; i < width; i++) - if (i < (len - dispos)) - waddch(window, field[dispos+i]); - else - waddch(window, ' '); - wmove(window, y, x + curpos); - wrefresh(window); - - key = wgetch(window); - switch (key) { - case TAB: - case KEY_BTAB: - case KEY_UP: - case KEY_DOWN: - case ESC: - case '\n': - case '\r': - done = 1; - break; - case KEY_HOME: - if (len < width) { - fpos = len; - curpos = len; - dispos = 0; - } else { - fpos = width; - curpos = width; - dispos = len - width; - }; - break; - case KEY_END: - if (len < width) { - dispos = 0; - curpos = len - 1; - } else { - dispos = len - width - 1; - curpos = width - 1; - } - fpos = len - 1; - break; - case KEY_LEFT: - if ((!curpos) && (!dispos)) { - beep(); - break; - } - if (--curpos < 0) { - curpos = 0; - if (--dispos < 0) - dispos = 0; - } - if (--fpos < 0) - fpos = 0; - break; - case KEY_RIGHT: - if ((curpos + dispos) == len) { - beep(); - break; - } - if ((curpos == (width-1)) && (dispos == (maxlen - width -1))) { - beep(); - break; - } - if (++curpos >= width) { - curpos = width - 1; - dispos++; - } - if (dispos >= len) - dispos = len - 1; - if (++fpos >= len) { - fpos = len; - } - break; - case KEY_BACKSPACE: - case KEY_DC: - if ((!curpos) && (!dispos)) { - beep(); - break; - } - if (fpos > 0) { - memmove(field+fpos-1, field+fpos, len - fpos); - len--; - fpos--; - if (curpos > 0) - --curpos; - if (!curpos) - --dispos; - if (dispos < 0) - dispos = 0; - } else - beep(); - break; - default: - if (len < maxlen - 1) { - memmove(field+fpos+1, field+fpos, len - fpos); - field[fpos] = key; - len++; - fpos++; - if (++curpos == width) { - --curpos; - dispos++; - } - if (len == (maxlen - 1)) { - dispos = (maxlen - width - 1); - } - } else - beep(); - break; - } - } while (!done); - wattrset(window, dialog_attr); - wmove(window, y, x); - for (i=0; i < width; i++) - if (i < (len - dispos)) - waddch(window, field[dispos+i]); - else - waddch(window, ' '); - wmove(window, y, x + curpos); - wstandend(window); - field[len] = 0; - wrefresh(window); - return (key); -} diff --git a/sbin/sysinstall/editor.h b/sbin/sysinstall/editor.h index 0df8554..c3375a4 100644 --- a/sbin/sysinstall/editor.h +++ b/sbin/sysinstall/editor.h @@ -16,4 +16,3 @@ struct field { int disp_fields(WINDOW *, struct field *, int); int change_field(struct field, int); -int edit_line(WINDOW *, int, int, char *, int, int); diff --git a/sbin/sysinstall/label.c b/sbin/sysinstall/label.c index 73b786b..1592d21 100644 --- a/sbin/sysinstall/label.c +++ b/sbin/sysinstall/label.c @@ -180,11 +180,13 @@ edit_disklabel(int disk) } disp_fields(window, label_field, sizeof(label_field)/sizeof(struct field)); - key = edit_line(window, label_field[cur_field].y, - label_field[cur_field].x, - label_field[cur_field].field, - label_field[cur_field].width, - label_field[cur_field].maxlen); + key = line_edit(window, label_field[cur_field].y, + label_field[cur_field].x, + label_field[cur_field].width, + label_field[cur_field].maxlen, + item_selected_attr, + 1, + label_field[cur_field].field); next = change_field(label_field[cur_field], key); if (next == -1) beep(); diff --git a/sbin/sysinstall/mbr.c b/sbin/sysinstall/mbr.c index c09ab50..d4384fc 100644 --- a/sbin/sysinstall/mbr.c +++ b/sbin/sysinstall/mbr.c @@ -254,9 +254,12 @@ get_geom_values(int disk) sprintf(field[2].field, "%ld", lbl->d_nsectors); disp_fields(window, field, sizeof(field)/sizeof(struct field)); - key = edit_line(window, field[cur_field].y, field[cur_field].x, - field[cur_field].field, field[cur_field].width, - field[cur_field].maxlen); + key = line_edit(window, field[cur_field].y, field[cur_field].x, + field[cur_field].width, + field[cur_field].maxlen, + item_selected_attr, + 1, + field[cur_field].field); next = change_field(field[cur_field], key); if (next == -1) beep(); @@ -353,9 +356,12 @@ edit_mbr(int disk) } disp_fields(window, mbr_field, sizeof(mbr_field)/sizeof(struct field)); - key = edit_line(window, mbr_field[cur_field].y, mbr_field[cur_field].x, - mbr_field[cur_field].field, mbr_field[cur_field].width, - mbr_field[cur_field].maxlen); + key = line_edit(window, mbr_field[cur_field].y, mbr_field[cur_field].x, + mbr_field[cur_field].width, + mbr_field[cur_field].maxlen, + item_selected_attr, + 1, + mbr_field[cur_field].field); /* Propagate changes to MBR */ for (i=0; i < NDOSPART; i++) { |