/*
- * $Id: list.c,v 1.21 2004/06/30 19:47:43 jheinonen Exp $
+ * $Id: list.c,v 1.27 2005/09/17 10:10:26 jheinonen Exp $
*
* by JH <jheinonen@users.sourceforge.net>
*
#include "ui.h"
#include "database.h"
#include "edit.h"
+#include "gettext.h"
#include "list.h"
#include "misc.h"
#include "options.h"
+#include "xmalloc.h"
#define MIN_EXTRA_COLUMN ADDRESS /* 2 */
#define MAX_EXTRA_COLUMN LAST_FIELD
extern list_item *database;
extern struct abook_field abook_fields[];
-WINDOW *list = NULL;
+static WINDOW *list = NULL;
static int
init_extra_field(enum str_opts option)
refresh_list()
{
int i, line;
-
+
werase(list);
ui_print_number_of_items();
-
- if(items < 1) {
+
+ if(list_is_empty()) {
refresh();
wrefresh(list);
return;
}
-
+
if(curitem < 0)
curitem = 0;
print_list_line(i, line, i == curitem);
}
+ if(opt_get_bool(BOOL_SHOW_CURSOR)) {
+ wmove(list, curitem - first_list_item, 0);
+ /* need to call refresh() to update the cursor positions */
+ refresh();
+ }
wrefresh(list);
}
if(selected[i])
mvwaddch(list, line, 0, '*' );
-
+
mvwaddnstr(list, line, NAMEPOS, database[i][NAME],
bytes2width(database[i][NAME], NAMELEN));
if(opt_get_bool(BOOL_SHOW_ALL_EMAILS))
if(highlight)
wstandend(list);
}
-
+
void
list_headerline()
#if defined(A_BOLD) && defined(A_NORMAL)
attrset(A_BOLD);
#endif
- mvaddstr(2, NAMEPOS, abook_fields[NAME].name);
- mvaddstr(2, EMAILPOS, abook_fields[EMAIL].name);
+ mvaddstr(2, NAMEPOS, gettext(abook_fields[NAME].name));
+ mvaddstr(2, EMAILPOS, gettext(abook_fields[EMAIL].name));
if(extra_column > 0)
- mvaddnstr(2, EXTRAPOS, abook_fields[extra_column].name,
+ mvaddnstr(2, EXTRAPOS, gettext(abook_fields[extra_column].name),
COLS-EXTRAPOS);
#if defined(A_BOLD) && defined(A_NORMAL)
attrset(A_NORMAL);
{
if(curitem < 1)
return;
-
+
curitem = curitem == first_list_item ?
((curitem -= LIST_LINES) < 0 ? 0 : curitem) : first_list_item;
-
+
refresh_list();
}
{
if(items > 0)
curitem = 0;
-
+
refresh_list();
}
return 1;
for(i = 0; i < ITEM_FIELDS; i++)
- item[i] = database[curitem][i] ? strdup(database[curitem][i]) :
+ item[i] = database[curitem][i] ? xstrdup(database[curitem][i]) :
NULL;
if(add_item2database(item))