X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=edit.c;h=5edebec4d2fb2f01e1a6afcd47063d4fb55d5507;hb=ceba9214d8bebe32d0c34c7a82916bcb9d798d69;hp=66dae8b65d2e19aaf764bd744d912e22c4b01e0a;hpb=90ffc7f76f5ddebc4d670a55bf60a4d74e3f4f84;p=pkg%2Fabook.git diff --git a/edit.c b/edit.c index 66dae8b..5edebec 100644 --- a/edit.c +++ b/edit.c @@ -2,7 +2,7 @@ /* * $Id$ * - * by JH + * by JH * * Copyright (C) Jaakko Heinonen */ @@ -120,13 +120,12 @@ print_editor_header(int item) { char *header; char email[MAX_EMAIL_LEN]; - int i, x, len; - + if( (header = (char *)malloc(EDITW_COLS)) == NULL ) return; get_first_email(email, item); - + if( *database[item][EMAIL] ) snprintf(header, EDITW_COLS, "%s <%s>", database[item][NAME], @@ -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,25 +154,29 @@ 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; } - + 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++; } @@ -204,10 +203,10 @@ change_field(char *msg, char **field) char tmp[MAX_FIELD_LEN]; int max_len = MAX_FIELD_LEN; int ret; - + if( !strncmp("E-mail", msg, 6) ) max_len = MAX_EMAIL_LEN; - + statusline_addstr(msg); if( (ret = statusline_getnstr( tmp, max_len - 1, 0 ) ? 1:0 ) ) { my_free(*field); @@ -265,10 +264,10 @@ edit_emails(char c, int item) fix_email_str(emails[c - '2']); } else *emails[c - '2'] = 0; - + my_free(database[item][EMAIL]); - for(i=0; i 6) + if(n < 1 || n > MAX_TAB_FIELDS) return 0; edit_undo(item, BACKUP_ITEM); @@ -343,7 +342,7 @@ edit_undo(int item, int mode) free_list_item(backup[0]); my_free(backup); } - backup = abook_malloc(sizeof(list_item)); + backup = (list_item *)abook_malloc(sizeof(list_item)); for(i = 0; i < ITEM_FIELDS; i++) backup[0][i] = safe_strdup(database[item][i]); break; @@ -362,7 +361,7 @@ edit_loop(int item) { static int tab = 0; /* first tab */ int c; - + werase(editw); headerline(EDITOR_HELPLINE); refresh_statusline();