-2002-xx-xx
+2002-03-10
+ - readline support
- abook can be compiled with g++
- attempt to improve --datafile behavior
- html filter update (Morten Brix Pedersen)
bin_PROGRAMS = abook
abook_SOURCES = abook.c database.c filter.c list.c misc.c conff.c \
- options.c edit.c ldif.c estr.c ui.c getname.c \
- getopt.c getopt1.c \
+ options.c edit.c ldif.c ui.c getname.c \
+ getopt.c getopt1.c abook_rl.c \
abook.h database.h filter.h list.h misc.h help.h conff.h \
- options.h edit.h ldif.h estr.h abook_curses.h ui.h getname.h \
- getopt.h
+ options.h edit.h ldif.h abook_curses.h ui.h getname.h \
+ getopt.h abook_rl.h
EXTRA_DIST = ANNOUNCE BUGS FAQ abook.1 abookrc.5 sample.abookrc
-# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
bin_PROGRAMS = abook
-abook_SOURCES = abook.c database.c filter.c list.c misc.c conff.c options.c edit.c ldif.c estr.c ui.c getname.c getopt.c getopt1.c abook.h database.h filter.h list.h misc.h help.h conff.h options.h edit.h ldif.h estr.h abook_curses.h ui.h getname.h getopt.h
+abook_SOURCES = abook.c database.c filter.c list.c misc.c conff.c \
+ options.c edit.c ldif.c ui.c getname.c \
+ getopt.c getopt1.c abook_rl.c \
+ abook.h database.h filter.h list.h misc.h help.h conff.h \
+ options.h edit.h ldif.h abook_curses.h ui.h getname.h \
+ getopt.h abook_rl.h
EXTRA_DIST = ANNOUNCE BUGS FAQ abook.1 abookrc.5 sample.abookrc
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
abook_OBJECTS = abook.o database.o filter.o list.o misc.o conff.o \
-options.o edit.o ldif.o estr.o ui.o getname.o getopt.o getopt1.o
+options.o edit.o ldif.o ui.o getname.o getopt.o getopt1.o abook_rl.o
abook_LDADD = $(LDADD)
abook_DEPENDENCIES =
abook_LDFLAGS =
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = tar
+TAR = gtar
GZIP_ENV = --best
-DEP_FILES = .deps/abook.P .deps/conff.P .deps/database.P .deps/edit.P \
-.deps/estr.P .deps/filter.P .deps/getname.P .deps/getopt.P \
-.deps/getopt1.P .deps/ldif.P .deps/list.P .deps/misc.P .deps/options.P \
-.deps/ui.P
+DEP_FILES = .deps/abook.P .deps/abook_rl.P .deps/conff.P \
+.deps/database.P .deps/edit.P .deps/filter.P .deps/getname.P \
+.deps/getopt.P .deps/getopt1.P .deps/ldif.P .deps/list.P .deps/misc.P \
+.deps/options.P .deps/ui.P
SOURCES = $(abook_SOURCES)
OBJECTS = $(abook_OBJECTS)
$(ACLOCAL_M4): configure.in acinclude.m4
cd $(srcdir) && $(ACLOCAL)
-config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES)
+config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
--- /dev/null
+/*
+ * $Id$
+ *
+ * by JH <jheinonen@users.sourceforge.net>
+ *
+ * Copyright (C) Jaakko Heinonen
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include "abook.h"
+#include "abook_rl.h"
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined(HAVE_READLINE_READLINE_H)
+# include <readline/readline.h>
+#elif defined(HAVE_READLINE_H)
+# include <readline.h>
+#endif
+
+#if defined(HAVE_READLINE_HISTORY_H)
+# include <readline/history.h>
+#elif defined(HAVE_HISTORY_H)
+# include <history.h>
+#endif
+
+#define RL_READLINE_NAME "Abook"
+
+static int rl_x, rl_y;
+static WINDOW *rl_win;
+
+static void
+rl_refresh()
+{
+ /*refresh();*/
+ wrefresh(rl_win);
+}
+
+static void
+rline_update()
+{
+ int real_point = rl_point + rl_x;
+
+ if(real_point > (COLS - 1))
+ mvwaddnstr(rl_win, rl_y, rl_x,
+ rl_line_buffer + (1 + real_point - COLS),
+ COLS - rl_x - 1);
+ else
+ mvwaddnstr(rl_win, rl_y, rl_x, rl_line_buffer, rl_end);
+
+ wclrtoeol(rl_win);
+ wmove(rl_win, rl_y, min(real_point, COLS - 1));
+
+ rl_refresh();
+}
+
+void
+rline_compdisp(char **matches, int n, int max_len)
+{
+ /*
+ * dummy
+ */
+}
+
+static void
+abook_rl_init(int use_completion)
+{
+ rl_readline_name = RL_READLINE_NAME;
+
+ rl_already_prompted = 1;
+
+ rl_redisplay_function = rline_update;
+ rl_completion_display_matches_hook = rline_compdisp;
+
+ rl_unbind_function_in_map(rl_clear_screen, rl_get_keymap());
+
+ if(use_completion)
+ rl_bind_key('\t', rl_menu_complete);
+ else
+ rl_unbind_function_in_map(rl_complete, rl_get_keymap());
+
+ clear_history();
+}
+
+char *
+abook_readline(WINDOW *w, int y, int x, char *s, int limit, int use_completion)
+{
+ char *ret = NULL;
+
+ rl_win = w;
+ abook_rl_init(use_completion);
+
+ wmove(rl_win, rl_y = y, rl_x = x);
+ rl_refresh();
+
+ if(s && *s)
+ add_history(s);
+
+ ret = readline(NULL);
+
+ return ret;
+}
--- /dev/null
+#ifndef _ABOOK_RL_H
+#define _ABOOK_RL_H
+
+#include "abook_curses.h"
+
+char *abook_readline(WINDOW *w, int y, int x, char *s, int limit,
+ int use_completion);
+
+#endif
fi
])])
+
+
+
+dnl @synopsis AC_LIB_READLINE
+dnl
+dnl Searches for a readline compatible library. If found, defines
+dnl `HAVE_LIBREADLINE'. If the found library has the `add_history'
+dnl function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
+dnl locations of the necessary include files and sets `HAVE_READLINE_H'
+dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
+dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
+dnl
+dnl The libraries that may be readline compatible are `libedit',
+dnl `libeditline' and `libreadline'. Sometimes we need to link a termcap
+dnl library for readline to work, this macro tests these cases too by
+dnl trying to link with `libtermcap', `libcurses' or `libncurses' before
+dnl giving up.
+dnl
+dnl Here is an example of how to use the information provided by this
+dnl macro to perform the necessary includes or declarations in a C file:
+dnl
+dnl #include <config.h>
+dnl
+dnl #ifdef HAVE_LIBREADLINE
+dnl #if defined(HAVE_READLINE_READLINE_H)
+dnl #include <readline/readline.h>
+dnl #elif defined(HAVE_READLINE_H)
+dnl #include <readline.h>
+dnl #else /* !defined(HAVE_READLINE_H) */
+dnl extern char *readline ();
+dnl #endif /* !defined(HAVE_READLINE_H) */
+dnl char *cmdline = NULL;
+dnl #else /* !defined(HAVE_READLINE_READLINE_H) */
+dnl /* no readline */
+dnl #endif /* HAVE_LIBREADLINE */
+dnl
+dnl #ifdef HAVE_READLINE_HISTORY
+dnl #if defined(HAVE_READLINE_HISTORY_H)
+dnl #include <readline/history.h>
+dnl #elif defined(HAVE_HISTORY_H)
+dnl #include <history.h>
+dnl #else /* !defined(HAVE_HISTORY_H) */
+dnl extern void add_history ();
+dnl extern int write_history ();
+dnl extern int read_history ();
+dnl #endif /* defined(HAVE_READLINE_HISTORY_H) */
+dnl /* no history */
+dnl #endif /* HAVE_READLINE_HISTORY */
+dnl
+dnl
+dnl @version $Id$
+dnl @author Ville Laurikari <vl@iki.fi>
+dnl
+AC_DEFUN([AC_LIB_READLINE], [
+ AC_CACHE_CHECK([for a readline compatible library],
+ ac_cv_lib_readline, [
+ ORIG_LIBS=$LIBS
+ for readline_lib in readline edit editline; do
+ for termcap_lib in "" termcap curses ncurses; do
+ if test -z "$termcap_lib"; then
+ TRY_LIB="-l$readline_lib"
+ else
+ TRY_LIB="-l$readline_lib -l$termcap_lib"
+ fi
+ LIBS="$ORIG_LIBS $TRY_LIB"
+ AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
+ if test -n "$ac_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -n "$ac_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -z "$ac_cv_lib_readline"; then
+ ac_cv_lib_readline="no"
+ LIBS=$ORIG_LIBS
+ fi
+ ])
+
+ if test "$ac_cv_lib_readline" != "no"; then
+ AC_DEFINE(HAVE_LIBREADLINE, 1,
+ [Define if you have a readline compatible library])
+ AC_CHECK_HEADERS(readline.h readline/readline.h)
+ AC_CACHE_CHECK([whether readline supports history],
+ ac_cv_lib_readline_history, [
+ ac_cv_lib_readline_history="no"
+ AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
+ ])
+ if test "$ac_cv_lib_readline_history" = "yes"; then
+ AC_DEFINE(HAVE_READLINE_HISTORY, 1,
+ [Define if your readline library has \`add_history'])
+ AC_CHECK_HEADERS(history.h readline/history.h)
+ fi
+ fi
+])
-dnl aclocal.m4 generated automatically by aclocal 1.4-p4
+dnl aclocal.m4 generated automatically by aclocal 1.4-p5
-dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
])])
+
+
+dnl @synopsis AC_LIB_READLINE
+dnl
+dnl Searches for a readline compatible library. If found, defines
+dnl `HAVE_LIBREADLINE'. If the found library has the `add_history'
+dnl function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
+dnl locations of the necessary include files and sets `HAVE_READLINE_H'
+dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
+dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
+dnl
+dnl The libraries that may be readline compatible are `libedit',
+dnl `libeditline' and `libreadline'. Sometimes we need to link a termcap
+dnl library for readline to work, this macro tests these cases too by
+dnl trying to link with `libtermcap', `libcurses' or `libncurses' before
+dnl giving up.
+dnl
+dnl Here is an example of how to use the information provided by this
+dnl macro to perform the necessary includes or declarations in a C file:
+dnl
+dnl #include <config.h>
+dnl
+dnl #ifdef HAVE_LIBREADLINE
+dnl #if defined(HAVE_READLINE_READLINE_H)
+dnl #include <readline/readline.h>
+dnl #elif defined(HAVE_READLINE_H)
+dnl #include <readline.h>
+dnl #else /* !defined(HAVE_READLINE_H) */
+dnl extern char *readline ();
+dnl #endif /* !defined(HAVE_READLINE_H) */
+dnl char *cmdline = NULL;
+dnl #else /* !defined(HAVE_READLINE_READLINE_H) */
+dnl /* no readline */
+dnl #endif /* HAVE_LIBREADLINE */
+dnl
+dnl #ifdef HAVE_READLINE_HISTORY
+dnl #if defined(HAVE_READLINE_HISTORY_H)
+dnl #include <readline/history.h>
+dnl #elif defined(HAVE_HISTORY_H)
+dnl #include <history.h>
+dnl #else /* !defined(HAVE_HISTORY_H) */
+dnl extern void add_history ();
+dnl extern int write_history ();
+dnl extern int read_history ();
+dnl #endif /* defined(HAVE_READLINE_HISTORY_H) */
+dnl /* no history */
+dnl #endif /* HAVE_READLINE_HISTORY */
+dnl
+dnl
+dnl @version $Id$
+dnl @author Ville Laurikari <vl@iki.fi>
+dnl
+AC_DEFUN([AC_LIB_READLINE], [
+ AC_CACHE_CHECK([for a readline compatible library],
+ ac_cv_lib_readline, [
+ ORIG_LIBS=$LIBS
+ for readline_lib in readline edit editline; do
+ for termcap_lib in "" termcap curses ncurses; do
+ if test -z "$termcap_lib"; then
+ TRY_LIB="-l$readline_lib"
+ else
+ TRY_LIB="-l$readline_lib -l$termcap_lib"
+ fi
+ LIBS="$ORIG_LIBS $TRY_LIB"
+ AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
+ if test -n "$ac_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -n "$ac_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -z "$ac_cv_lib_readline"; then
+ ac_cv_lib_readline="no"
+ LIBS=$ORIG_LIBS
+ fi
+ ])
+
+ if test "$ac_cv_lib_readline" != "no"; then
+ AC_DEFINE(HAVE_LIBREADLINE, 1,
+ [Define if you have a readline compatible library])
+ AC_CHECK_HEADERS(readline.h readline/readline.h)
+ AC_CACHE_CHECK([whether readline supports history],
+ ac_cv_lib_readline_history, [
+ ac_cv_lib_readline_history="no"
+ AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
+ ])
+ if test "$ac_cv_lib_readline_history" = "yes"; then
+ AC_DEFINE(HAVE_READLINE_HISTORY, 1,
+ [Define if your readline library has \`add_history'])
+ AC_CHECK_HEADERS(history.h readline/history.h)
+ fi
+ fi
+])
+
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
-AC_DEFUN(AM_INIT_AUTOMAKE,
+AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
# Check to make sure that the build environment is sane.
#
-AC_DEFUN(AM_SANITY_CHECK,
+AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
-AC_DEFUN(AM_MISSING_PROG,
+AC_DEFUN([AM_MISSING_PROG],
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Like AC_CONFIG_HEADER, but automatically create stamp file.
-AC_DEFUN(AM_CONFIG_HEADER,
+AC_DEFUN([AM_CONFIG_HEADER],
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
# serial 1
-AC_DEFUN(AM_C_PROTOTYPES,
+AC_DEFUN([AM_C_PROTOTYPES],
[AC_REQUIRE([AM_PROG_CC_STDC])
AC_REQUIRE([AC_PROG_CPP])
AC_MSG_CHECKING([for function prototypes])
# program @code{ansi2knr}, which comes with Ghostscript.
# @end defmac
-AC_DEFUN(AM_PROG_CC_STDC,
+AC_DEFUN([AM_PROG_CC_STDC],
[AC_REQUIRE([AC_PROG_CC])
AC_BEFORE([$0], [AC_C_INLINE])
AC_BEFORE([$0], [AC_C_CONST])
-/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
+/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if you have the strcoll function and it is properly defined. */
#undef HAVE_STRCOLL
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
+/* Define if you have the <history.h> header file. */
+#undef HAVE_HISTORY_H
+
/* Define if you have the <linux/termios.h> header file. */
#undef HAVE_LINUX_TERMIOS_H
/* Define if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H
+/* Define if you have the <readline.h> header file. */
+#undef HAVE_READLINE_H
+
+/* Define if you have the <readline/history.h> header file. */
+#undef HAVE_READLINE_HISTORY_H
+
+/* Define if you have the <readline/readline.h> header file. */
+#undef HAVE_READLINE_READLINE_H
+
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if compiler has function prototypes */
#undef PROTOTYPES
+/* Define if you have a readline compatible library */
+#undef HAVE_LIBREADLINE
+
+/* Define if your readline library has `add_history' */
+#undef HAVE_READLINE_HISTORY
+
+
+ echo $ac_n "checking for a readline compatible library""... $ac_c" 1>&6
+echo "configure:2302: checking for a readline compatible library" >&5
+if eval "test \"`echo '$''{'ac_cv_lib_readline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ ORIG_LIBS=$LIBS
+ for readline_lib in readline edit editline; do
+ for termcap_lib in "" termcap curses ncurses; do
+ if test -z "$termcap_lib"; then
+ TRY_LIB="-l$readline_lib"
+ else
+ TRY_LIB="-l$readline_lib -l$termcap_lib"
+ fi
+ LIBS="$ORIG_LIBS $TRY_LIB"
+ cat > conftest.$ac_ext <<EOF
+#line 2317 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char readline();
+
+int main() {
+readline()
+; return 0; }
+EOF
+if { (eval echo configure:2328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_lib_readline="$TRY_LIB"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ if test -n "$ac_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -n "$ac_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -z "$ac_cv_lib_readline"; then
+ ac_cv_lib_readline="no"
+ LIBS=$ORIG_LIBS
+ fi
+
+fi
+
+echo "$ac_t""$ac_cv_lib_readline" 1>&6
+
+ if test "$ac_cv_lib_readline" != "no"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LIBREADLINE 1
+EOF
+
+ for ac_hdr in readline.h readline/readline.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2362: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2367 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2372: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ echo $ac_n "checking whether readline supports history""... $ac_c" 1>&6
+echo "configure:2399: checking whether readline supports history" >&5
+if eval "test \"`echo '$''{'ac_cv_lib_readline_history'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ ac_cv_lib_readline_history="no"
+ cat > conftest.$ac_ext <<EOF
+#line 2406 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char add_history();
+
+int main() {
+add_history()
+; return 0; }
+EOF
+if { (eval echo configure:2417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_lib_readline_history="yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_lib_readline_history" 1>&6
+ if test "$ac_cv_lib_readline_history" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_READLINE_HISTORY 1
+EOF
+
+ for ac_hdr in history.h readline/history.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2438: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2443 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2448: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ fi
+ fi
+
+
+if test x$ac_lib_readline = xno -o x$ac_cv_lib_readline_history = xno; then
+ { echo "configure: error: *** readline library not found or it doesn't support history ***" 1>&2; exit 1; }
+fi
+
+LDFLAGS="$ac_cv_lib_readline $LDFLAGS"
+
for ac_func in resizeterm
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2303: checking for $ac_func" >&5
+echo "configure:2487: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2308 "configure"
+#line 2492 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo $ac_n "checking for snprintf""... $ac_c" 1>&6
-echo "configure:2357: checking for snprintf" >&5
+echo "configure:2541: checking for snprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_snprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2362 "configure"
+#line 2546 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char snprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:2385: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_snprintf=yes"
else
fi
echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
-echo "configure:2408: checking for vsnprintf" >&5
+echo "configure:2592: checking for vsnprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vsnprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2413 "configure"
+#line 2597 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vsnprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:2436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vsnprintf=yes"
else
dnl end of (n)curses detection
dnl --------------------------
+AC_LIB_READLINE
+
+if test x$ac_lib_readline = xno -o x$ac_cv_lib_readline_history = xno; then
+ AC_MSG_ERROR([*** readline library not found or it doesn't support history ***])
+fi
+
+LDFLAGS="$ac_cv_lib_readline $LDFLAGS"
+
AC_CHECK_FUNCS(resizeterm)
AC_CHECK_FUNC(snprintf, [AC_DEFINE(HAVE_SNPRINTF)],)
}
}
-/*
- * function: change_field
- *
- * parameters:
- * (char *msg)
- * message to display as a prompt
- * (char **field)
- * a pointer to pointer which will point a new string. if the latter
- * pointer != NULL it will be freed (if user doesn't cancel)
- *
- * returns (int)
- * a nonzero value if user has cancelled and zero if user has typed a
- * valid string
- */
-
static int
change_field(char *msg, char **field)
{
- char tmp[MAX_FIELD_LEN];
int max_len = MAX_FIELD_LEN;
- int ret;
+ char *old;
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);
- if( *tmp )
- *field = strdup(tmp);
- }
+ old = *field;
+
+ *field = ui_readline(msg, old, max_len - 1, 0);
+
+ free(old);
clear_statusline();
refresh_statusline();
- return !ret;
+ return 0;
}
static void
static void
edit_emails(char c, int item)
{
- char *field = NULL;
+ char *field;
char emails[MAX_EMAILS][MAX_EMAIL_LEN];
char tmp[MAX_EMAILSTR_LEN] = "";
int i, len;
+ int email_num = c - '2';
split_emailstr(item, emails);
+ field = strdup(emails[email_num]);
if(change_field("E-mail: ", &field)) {
#ifdef DEBUG
fprintf(stderr, "change_field = TRUE\n");
#endif
- return; /* user cancelled ( C-g ) */
+ return;
}
if(field) {
- strncpy(emails[c - '2'], field, MAX_EMAIL_LEN);
- fix_email_str(emails[c - '2']);
+ strncpy(emails[email_num], field, MAX_EMAIL_LEN);
+ fix_email_str(emails[email_num]);
} else
- *emails[c - '2'] = 0;
+ *emails[email_num] = 0;
my_free(database[item][EMAIL]);
mvaddstr(5+filter, 2, "->");
- filename = ask_filename("Filename: ", 1);
+ filename = ask_filename("Filename: ");
if( !filename ) {
refresh_screen();
return 2;
clear_statusline();
}
- filename = ask_filename("Filename: ", 0);
+ filename = ask_filename("Filename: ");
if( !filename ) {
refresh_screen();
return 2;
};
#define LIST_TOP 3
-#define LIST_BOTTOM (LINES-3)
+#define LIST_BOTTOM (LINES-2)
#define LIST_LINES (LIST_BOTTOM-LIST_TOP)
#define LIST_COLS COLS
#include "misc.h"
#include "options.h"
#include "filter.h"
-#include "estr.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
# include <sys/ioctl.h>
#endif
+#include "abook_rl.h"
+
/*
* external variables
*/
wrefresh(bottom);
}
-/*
- * function statusline_getnstr
- *
- * parameters:
- * (char *str)
- * if n >= 0 str is a pointer which points a place where to store
- * the string, else str is ignored
- * (int n)
- * the maximum length of the string
- * If n < 0 function will allocate needed space for the string.
- * Value 0 is not allowed for n.
- * (int use_filesel)
- * if this value is nonzero the fileselector is enabled
- *
- * returns (char *)
- * If n < 0 a pointer to a newly allocated string is returned.
- * If n > 0 a nonzero value is returned if user has typed a valid
- * string. If not NULL value is returned. Never really use the
- * _pointer_ if n > 0.
- *
- */
-
char *
-statusline_getnstr(char *str, int n, int use_filesel)
+ui_readline(char *prompt, char *s, int limit, int use_completion)
{
- char *buf;
int y, x;
- getyx(bottom, y, x);
- wmove(bottom, 1, x);
-
- buf = wenter_string(bottom, n,
- (use_filesel ? ESTR_USE_FILESEL:0) | ESTR_DONT_WRAP);
-
- if(n < 0)
- return buf;
+ mvwaddstr(bottom, 1, 0, prompt);
+ //mvwaddstr(stdscr, LINES - 1, 0, prompt);
- if(buf == NULL)
- str[0] = 0;
- else
- strncpy(str, buf, n);
-
- str[n-1] = 0;
-
- free(buf);
+ /*
+ * FIXME: stdscr shoulnd't be used ???
+ */
+// getyx(stdscr, y, x);
+ getyx(bottom, y, x);
- return buf;
+ return abook_readline(bottom, y, x, s, limit, use_completion);
}
int
werase(bottom);
mvwhline(bottom, 0, 0, UI_HLINE_CHAR, COLS);
- mvwhline(bottom, 2, 0, UI_HLINE_CHAR, COLS);
refresh();
wrefresh(bottom);
char *
-ask_filename(char *prompt, int flags)
+ask_filename(char *prompt)
{
char *buf = NULL;
clear_statusline();
- statusline_addstr(prompt);
- buf = statusline_getnstr(NULL, -1, flags);
-
- clear_statusline();
+ buf = ui_readline(prompt, NULL, -1, 1);
return buf;
}
if( !*findstr )
return;
} else {
+ char *s;
clear_statusline();
- statusline_addstr("/");
- statusline_getnstr(findstr, MAX_FIELD_LEN - 1, 0);
- clear_statusline();
+ s = ui_readline("/", findstr, MAX_FIELD_LEN - 1, 0);
+ strncpy(findstr, s, MAX_FIELD_LEN);
+ refresh_screen();
}
if( (item = find_item(findstr, curitem + !!next,
{
char *filename;
- filename = ask_filename("File to open: ", 1);
+ filename = ask_filename("File to open: ");
- if( !filename ) {
+ if( !filename || ! *filename) {
+ free(filename);
refresh_screen();
return;
}
void headerline(char *str);
void refresh_screen();
int statusline_msg(char *msg);
-char *ask_filename(char *prompt, int flags);
+char *ask_filename(char *prompt);
int statusline_ask_boolean(char *msg, int def);
void clear_statusline();
void display_help(int help);
void statusline_addstr(char *str);
-char *statusline_getnstr(char *str, int n, int use_filesel);
+char * ui_readline(char *prompt, char *s, int limit, int use_completion);
void refresh_statusline();
void get_commands();
void ui_remove_items();