- if(i==EMAIL) { /* special field */
- int k;
- char emails[MAX_EMAILS][MAX_EMAIL_LEN];
- split_emailstr(item, emails);
- mvwaddstr(editw, (LINES > 21 ? 7:6), pos_x, "E-mail addresses:");
- for(k=0; k < MAX_EMAILS; k++)
- mvwprintw(editw, (LINES > 21 ? 9:7)+k*2, pos_x,
- "%c -\t\t%s", '2' + k, emails[k] );
- continue;
+ view_info(tab, NULL, &cur);
+
+ for(; cur; cur = cur->next) {
+
+ if(j > 1) {
+ getyx(editw, y, x);
+ y++;
+ } else
+ y = FIELDS_START_Y;
+
+ mvwprintw(editw, y, FIELDS_START_X, "%c - ",
+ (j < 10) ? '0' + j : 'A' + j - 10);
+ mvwaddnstr(editw, y, FIELDS_START_X + 4, cur->field->name,
+ bytes2width(cur->field->name,
+ FIELDNAME_MAX_WIDTH));
+ mvwaddch(editw, y, TAB_COLON_POS, ':');
+
+ if((cur->field->type == FIELD_EMAILS) ||
+ (cur->field->type == FIELD_LIST)) {
+ abook_list *emails, *e;
+
+ find_field_number(cur->field->key, &nb);
+ emails = csv_to_abook_list(db_fget_byid(item, nb));
+
+ for(e = emails; e; e = e->next) {
+ getyx(editw, y, x);
+ mvwaddnstr(editw, y + 1, TAB_COLON_POS + 2,
+ e->data,
+ bytes2width(e->data,
+ FIELD_MAX_WIDTH));
+ mvwaddch(editw, y + 1, TAB_COLON_POS,
+ UI_VLINE_CHAR);
+ }
+ if(emails) {
+ mvwaddch(editw, y + 2, TAB_COLON_POS,
+ UI_LLCORNER_CHAR);
+ mvwhline(editw, y + 2, TAB_COLON_POS + 1,
+ UI_HLINE_CHAR,
+ EDITW_COLS - TAB_COLON_POS - 2);
+ }
+ abook_list_free(&emails);
+ } else if(cur->field->type == FIELD_DATE) {
+ int day, month, year;
+ char buf[12];
+
+ find_field_number(cur->field->key, &nb);
+ if((str = db_fget_byid(item, nb)) != NULL)
+ strncpy(buf, str, sizeof(buf));
+
+ if(str && parse_date_string(buf, &day, &month, &year)) {
+ if(year)
+ str = strdup_printf("%04d-%02d-%02d",
+ year, month, day);
+ else
+ str = strdup_printf("--%02d-%02d",
+ month, day);
+ mvwaddnstr(editw, y, TAB_COLON_POS + 2, str,
+ bytes2width(str, FIELD_MAX_WIDTH));
+ free(str);
+ }
+ } else {
+ find_field_number(cur->field->key, &nb);
+ str = safe_str(db_fget_byid(item, nb));
+ mvwaddnstr(editw, y, TAB_COLON_POS + 2, str,
+ bytes2width(str, FIELD_MAX_WIDTH));