]> git.deb.at Git - pkg/abook.git/commitdiff
Don't handle extra_column/extra_alternative as numbers in abookrc
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Thu, 11 Oct 2001 15:49:19 +0000 (15:49 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Thu, 11 Oct 2001 15:49:19 +0000 (15:49 +0000)
ChangeLog
configure
configure.in
edit.c
edit.h
list.c
sample.abookrc

index c78b6d4f4e52caea9ebf0d143f5ebc185d736ee5..ddf9b2007414d2ace7ab37bdd801785fb93959ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 0.4.15
  - new options --add-email and --add-email-quiet
  - proper mutt alias import filter
+ - minor editor update
+ - don't handle extra_column and extra_alternative as numbers in abookrc
  - mail.vim update in contrib directory
 
 0.4.14
index 3364110d0c04916626d711ffe2cf93bb99bab297..d4633382c1cea3eb1b1d08ecdb95e795ac9f4d07 100755 (executable)
--- a/configure
+++ b/configure
@@ -785,7 +785,7 @@ fi
 
 # Define the identity of the package.
 PACKAGE=abook
-VERSION=0.4.15pre1
+VERSION=0.4.15pre2
 cat >> confdefs.h <<EOF
 #define PACKAGE "$PACKAGE"
 EOF
index 68a06a533f70bc8f7546ea588ecae361288306a6..f1bb8d635e9f2b79ed85bb87d381d9fb96a4415f 100644 (file)
@@ -1,7 +1,7 @@
 dnl abook configure.in
 
 AC_INIT(abook.c)
-AM_INIT_AUTOMAKE(abook, 0.4.15pre1)
+AM_INIT_AUTOMAKE(abook, 0.4.15pre2)
 AM_CONFIG_HEADER(config.h)
 
 AC_CANONICAL_HOST
diff --git a/edit.c b/edit.c
index 4aea3c03719877ffaff4cc3d858a21f37052e81c..e6ba4342494912c9a455b58cf8c80d677718e5c3 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -138,15 +138,13 @@ print_editor_header(int item)
        x = (EDITW_COLS - len) / 2;
        mvwaddstr(editw, 0, x, header);
        for(i = x; i < x + len; i++)
-               mvwaddch(editw,1, i, '^');
+               mvwaddch(editw, 1, i, '^');
        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 +157,13 @@ 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, TAB_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, TAB_START_X,
+                               "%c -", '2' + k);
+                               mvwprintw(editw, y +1, TAB_COLON_POS,
+                                               ": %s", emails[k]);
                        }
                        continue;
                }
@@ -171,13 +171,14 @@ editor_print_data(int tab, int item)
                if(j > 1) {
                        getyx(editw, y, x); y++;
                } else
-                       y = start_y;
+                       y = TAB_START_Y;
 
-               mvwprintw(editw, y, pos_x, "%d - %s",
+               mvwprintw(editw, y, TAB_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 +269,7 @@ edit_emails(char c, int item)
        
        my_free(database[item][EMAIL]);
 
-       for(i=0; i<MAX_EMAILS; i++) {
+       for(i = 0; i < MAX_EMAILS; i++) {
                if( *emails[i] ) {
                        strcat(tmp, emails[i]);
                        strcat(tmp, ",");
@@ -289,7 +290,7 @@ edit_field(int tab, char c, int item)
        int n = c - '1' + 1;
        char *str;
 
-       if(n < 1 || n > 6)
+       if(n < 1 || n > MAX_TAB_LINES)
                return 0;
 
        edit_undo(item, BACKUP_ITEM);
diff --git a/edit.h b/edit.h
index 1b8c8f609b50725d5e4b1946b9dc9b8fcbf6546c..d686f9d4291e545b9f852ac90f2e2a9f7f052746 100644 (file)
--- a/edit.h
+++ b/edit.h
@@ -14,6 +14,12 @@ void         add_item();
 
 #define TABLINE                2
 
+#define MAX_TAB_LINES  7
+
+#define TAB_COLON_POS  28
+#define TAB_START_Y    5
+#define TAB_START_X    (EDITW_COLS > 70 ? 8:4)
+
 enum {
        TAB_CONTACT,
        TAB_ADDRESS,
diff --git a/list.c b/list.c
index b3e12de92a914460b3a391913e0909cf07737b75..32c12ed8b8466c0c6aa3ee72573c619bf8f7a2e5 100644 (file)
--- a/list.c
+++ b/list.c
 #include "misc.h"
 #include "options.h"
 
+#define MIN_EXTRA_COLUMN       ADDRESS /* 2 */
+#define MAX_EXTRA_COLUMN       LAST_FIELD
+
 int curitem = -1;
 int first_list_item = -1;
 char *selected = NULL;
 
+int extra_column = -1;
+int extra_alternative = -1;
+
 extern int items;
 extern list_item *database;
 extern struct abook_field abook_fields[];
@@ -30,8 +36,44 @@ WINDOW *list = NULL;
 void
 init_list()
 {
+       int i;
+       char *e_column_str = options_get_str("extra_column");
+       char *e_alternative_str = options_get_str("extra_alternative");
+
        list = newwin(LIST_LINES, LIST_COLS, LIST_TOP, 0);
        scrollok(list, TRUE);
+
+       /*
+        * init extra_column and extra alternative
+        */
+
+       if(e_column_str && *e_column_str) {
+               for(i = 0; i < ITEM_FIELDS; i++) {
+                       if(!strcasecmp(e_column_str, abook_fields[i].key)) {
+                               extra_column = i;
+                               break;
+                       }
+               }
+               if(extra_column < MIN_EXTRA_COLUMN ||
+                               extra_column > MAX_EXTRA_COLUMN) {
+                       extra_column = -1;
+               }
+       }
+
+       if(e_alternative_str && *e_alternative_str) {
+               for(i = 0; i < ITEM_FIELDS; i++) {
+                       if(!strcasecmp(e_alternative_str,
+                                               abook_fields[i].key)) {
+                               extra_alternative = i;
+                               break;
+                       }
+               }
+               if(extra_alternative < MIN_EXTRA_COLUMN ||
+                               extra_alternative > MAX_EXTRA_COLUMN) {
+                       extra_alternative = -1;
+               }
+       }
+
 }
 
 void
@@ -84,9 +126,9 @@ refresh_list()
 void
 print_list_line(int i, int line)
 {
+       int extra = extra_column;
        char tmp[MAX_EMAILSTR_LEN];
-       int extra_column = options_get_int("extra_column");
-       int real_emaillen = (extra_column > 2 && extra_column < ITEM_FIELDS) ?
+       int real_emaillen = (extra_column > 0 || extra_alternative > 0) ?
                EMAILLEN : COLS - EMAILPOS;
 
        scrollok(list, FALSE);
@@ -103,19 +145,12 @@ print_list_line(int i, int line)
                mvwaddnstr(list, line, EMAILPOS, tmp, real_emaillen);
        }
 
-       if(extra_column > 2 && extra_column < ITEM_FIELDS) {
-               if( !database[i][extra_column] ) {
-                       int extra_alternative =
-                               options_get_int("extra_alternative");
-                       
-                       if(extra_alternative > 2 &&
-                                       extra_alternative < ITEM_FIELDS)
-                               extra_column = extra_alternative;
-               }
+       if(extra < 0 || !database[i][extra])
+               extra = extra_alternative;
+       if(extra >= 0)
                mvwaddnstr(list, line, EXTRAPOS,
-                               safe_str(database[i][extra_column]),
+                               safe_str(database[i][extra]),
                                EXTRALEN);
-       }
 
        scrollok(list, TRUE);
 }
@@ -124,12 +159,10 @@ print_list_line(int i, int line)
 void
 list_headerline()
 {
-       int extra_column = options_get_int("extra_column");
-
        attrset(A_BOLD);
        mvaddstr(2, NAMEPOS, abook_fields[NAME].name);
        mvaddstr(2, EMAILPOS, abook_fields[EMAIL].name);
-       if( extra_column > 2 && extra_column < ITEM_FIELDS )
+       if(extra_column > 0)
                mvaddnstr(2, EXTRAPOS, abook_fields[extra_column].name,
                                COLS-EXTRAPOS);
        attrset(A_NORMAL);
index 3096cf17d14076edf2005e2a9d7f1ce925390ea3..847e4ff767664700f5e9bf098707fca2f463ab24 100644 (file)
@@ -11,15 +11,15 @@ show_all_emails=true
 emailpos=25
 
 # Field to be used in the extra column
-extra_column=7
+extra_column=phone
 # frequently used values:
-#      -1 = disabled
-#      7 = Home Phone
-#      8 = Work Phone
-#      9 = Fax
-#      10 = Mobile Phone
-#      11 = Nick / Alias
-#      12 = URL
+#      -1              disabled
+#      phone           Home Phone
+#      workphone       Work Phone
+#      fax             Fax
+#      mobile          Mobile Phone
+#      nick            Nick / Alias
+#      url             URL
 
 # Specify an alternative field to be displayed in the extra
 # column if there is no data for the field specified in