X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=edit.c;h=9cfbf26bab89737706b785ccd0a4d090d40fd18b;hb=ba218a8c82df9b5e5bdedf4c4bcb3e1094361b0b;hp=4aea3c03719877ffaff4cc3d858a21f37052e81c;hpb=4f7637954591ecfb575642709bd12a069ee90aab;p=pkg%2Fabook.git diff --git a/edit.c b/edit.c index 4aea3c0..9cfbf26 100644 --- a/edit.c +++ b/edit.c @@ -120,7 +120,6 @@ print_editor_header(int item) { char *header; char email[MAX_EMAIL_LEN]; - int i, x, len; if( (header = (char *)malloc(EDITW_COLS)) == NULL ) return; @@ -134,19 +133,15 @@ print_editor_header(int item) else snprintf(header, EDITW_COLS, "%s", database[item][NAME]); - len = strlen(header); - x = (EDITW_COLS - len) / 2; - mvwaddstr(editw, 0, x, header); - for(i = x; i < x + len; i++) - mvwaddch(editw,1, i, '^'); + mvwaddstr(editw, 0, (EDITW_COLS - strlen(header)) / 2, + header); + free(header); } static void editor_print_data(int tab, int item) { - const int pos_x = EDITW_COLS > 70 ? 8:4; - const int start_y = 5; int i, j; int y, x; @@ -159,11 +154,14 @@ editor_print_data(int tab, int item) char emails[MAX_EMAILS][MAX_EMAIL_LEN]; split_emailstr(item, emails); getyx(editw, y, x); - mvwaddstr(editw, y+1, pos_x, "E-mail addresses:"); + mvwaddstr(editw, y+1, FIELDS_START_X, + "E-mail addresses:"); for(k = 0; k < MAX_EMAILS; k++) { getyx(editw, y, x); - mvwprintw(editw, y+1, pos_x, - "%c -\t\t%s", '2' + k, emails[k] ); + mvwprintw(editw, y+1, FIELDS_START_X, + "%c -", '2' + k); + mvwprintw(editw, y +1, TAB_COLON_POS, + ": %s", emails[k]); } continue; } @@ -171,13 +169,14 @@ editor_print_data(int tab, int item) if(j > 1) { getyx(editw, y, x); y++; } else - y = start_y; + y = FIELDS_START_Y; - mvwprintw(editw, y, pos_x, "%d - %s", + mvwprintw(editw, y, FIELDS_START_X, "%d - %s", j, abook_fields[i].name); - mvwaddch(editw, y, 28, ':'); - mvwaddstr(editw, y, 30, safe_str(database[item][i])); + mvwaddch(editw, y, TAB_COLON_POS, ':'); + mvwaddstr(editw, y, TAB_COLON_POS + 2, + safe_str(database[item][i])); j++; } @@ -268,7 +267,7 @@ edit_emails(char c, int item) my_free(database[item][EMAIL]); - for(i=0; i 6) + if(n < 1 || n > MAX_TAB_FIELDS) return 0; edit_undo(item, BACKUP_ITEM);