X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=edit.c;h=4aea3c03719877ffaff4cc3d858a21f37052e81c;hb=4f7637954591ecfb575642709bd12a069ee90aab;hp=e41d707d1d5d22e6f87a75cbdd4a80031d541635;hpb=3a500c48898f7a279a98bfc259955a2e47bbfc48;p=pkg%2Fabook.git diff --git a/edit.c b/edit.c index e41d707..4aea3c0 100644 --- a/edit.c +++ b/edit.c @@ -2,7 +2,7 @@ /* * $Id$ * - * by JH + * by JH * * Copyright (C) Jaakko Heinonen */ @@ -127,12 +127,12 @@ print_editor_header(int item) get_first_email(email, item); - if( snprintf(header, EDITW_COLS, "%s <%s>", database[item][NAME], - email ) == -1 || !*database[item][EMAIL] ) - if( snprintf(header, EDITW_COLS, "%s", database[item][NAME]) == -1) { - free(header); - return; - } + if( *database[item][EMAIL] ) + snprintf(header, EDITW_COLS, "%s <%s>", + database[item][NAME], + email); + else + snprintf(header, EDITW_COLS, "%s", database[item][NAME]); len = strlen(header); x = (EDITW_COLS - len) / 2; @@ -146,8 +146,9 @@ static void editor_print_data(int tab, int item) { const int pos_x = EDITW_COLS > 70 ? 8:4; - const int start_y = 4; + const int start_y = 5; int i, j; + int y, x; for(i = 0, j = 1; i < ITEM_FIELDS; i++) { if(abook_fields[i].tab != tab) @@ -157,18 +158,26 @@ editor_print_data(int tab, int item) int k; char emails[MAX_EMAILS][MAX_EMAIL_LEN]; split_emailstr(item, emails); - mvwaddstr(editw, 6, pos_x, "E-mail addresses:"); - for(k=0; k < MAX_EMAILS; k++) - mvwprintw(editw, 7 + k, pos_x, + getyx(editw, y, x); + mvwaddstr(editw, y+1, pos_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] ); + } continue; } - mvwprintw(editw, start_y + j, pos_x, "%d - %s", + if(j > 1) { + getyx(editw, y, x); y++; + } else + y = start_y; + + mvwprintw(editw, y, pos_x, "%d - %s", j, abook_fields[i].name); - mvwaddch(editw, start_y + j, 28, ':'); - mvwaddstr(editw, start_y + j, 30, safe_str(database[item][i])); + mvwaddch(editw, y, 28, ':'); + mvwaddstr(editw, y, 30, safe_str(database[item][i])); j++; } @@ -239,7 +248,7 @@ static void edit_emails(char c, int item) { char *field = NULL; - char emails[4][MAX_EMAIL_LEN]; + char emails[MAX_EMAILS][MAX_EMAIL_LEN]; char tmp[MAX_EMAILSTR_LEN] = ""; int i, len; @@ -259,7 +268,7 @@ edit_emails(char c, int item) my_free(database[item][EMAIL]); - for(i=0; i<4; i++) { + for(i=0; i