# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id$ # $URL$ # Process this file with automake to produce Makefile.in VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = lcd4linux$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ TODO config.guess config.rpath config.sub depcomp install-sh \ ltmain.sh missing mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/curses.m4 \ $(top_srcdir)/ax_python_devel.m4 $(top_srcdir)/drivers.m4 \ $(top_srcdir)/plugins.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) cfg.$(OBJEXT) \ debug.$(OBJEXT) drv.$(OBJEXT) drv_generic.$(OBJEXT) \ evaluator.$(OBJEXT) property.$(OBJEXT) hash.$(OBJEXT) \ layout.$(OBJEXT) pid.$(OBJEXT) timer.$(OBJEXT) \ thread.$(OBJEXT) udelay.$(OBJEXT) qprintf.$(OBJEXT) \ rgb.$(OBJEXT) event.$(OBJEXT) widget.$(OBJEXT) \ widget_text.$(OBJEXT) widget_bar.$(OBJEXT) \ widget_icon.$(OBJEXT) widget_keypad.$(OBJEXT) \ widget_timer.$(OBJEXT) widget_gpo.$(OBJEXT) plugin.$(OBJEXT) \ plugin_cfg.$(OBJEXT) plugin_math.$(OBJEXT) \ plugin_string.$(OBJEXT) plugin_test.$(OBJEXT) \ plugin_time.$(OBJEXT) lcd4linux_OBJECTS = $(am_lcd4linux_OBJECTS) lcd4linux_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(lcd4linux_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES) DIST_SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURSES_INCLUDEDIR = @CURSES_INCLUDEDIR@ CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ DBUS_LIBS = @DBUS_LIBS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DRIVERS = @DRIVERS@ DRVLIBS = @DRVLIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = libtool LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PLUGINLIBS = @PLUGINLIBS@ PLUGINS = @PLUGINS@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ XMKMF = @XMKMF@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = gnu CLEANFILES = *~ # Fixme: -W should be renamed to -Wextra someday... AM_CFLAGS = -D_GNU_SOURCE -Wall -Wextra -fno-strict-aliasing ACLOCAL_AMFLAGS = -I m4 # use this for lots of warnings #AM_CFLAGS = -D_GNU_SOURCE -std=c99 -m64 -Wall -W -pedantic -Wno-variadic-macros -fno-strict-aliasing lcd4linux_LDFLAGS = lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@ lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@ lcd4linux_SOURCES = \ lcd4linux.c svn_version.h \ cfg.c cfg.h \ debug.c debug.h \ drv.c drv.h \ drv_generic.c drv_generic.h \ evaluator.c evaluator.h \ property.c property.h \ hash.c hash.h \ layout.c layout.h \ pid.c pid.h \ timer.c timer.h \ thread.c thread.h \ udelay.c udelay.h \ qprintf.c qprintf.h \ rgb.c rgb.h \ event.c \ \ widget.c widget.h \ widget_text.c widget_text.h \ widget_bar.c widget_bar.h \ widget_icon.c widget_icon.h \ widget_keypad.c widget_keypad.h \ widget_timer.c widget_timer.h \ widget_gpo.c widget_gpo.h \ \ plugin.c plugin.h \ plugin_cfg.c \ plugin_math.c \ plugin_string.c \ plugin_test.c \ plugin_time.c EXTRA_lcd4linux_SOURCES = \ drv_generic_text.c \ drv_generic_text.h \ drv_generic_graphic.c \ drv_generic_graphic.h \ drv_generic_gpio.c \ drv_generic_gpio.h \ drv_generic_serial.c \ drv_generic_serial.h \ drv_generic_parport.c \ drv_generic_parport.h \ drv_generic_i2c.c \ drv_generic_i2c.h \ drv_generic_keypad.c \ drv_generic_keypad.h \ drv_BeckmannEgle.c \ drv_BWCT.c \ drv_Crystalfontz.c \ drv_Curses.c \ drv_Cwlinux.c \ drv_D4D.c \ drv_EA232graphic.c \ drv_G15.c \ drv_GLCD2USB.c glcd2usb.h \ drv_HD44780.c \ drv_Image.c \ drv_IRLCD.c \ drv_LCD2USB.c \ drv_LCDLinux.c \ drv_LCDTerm.c \ drv_LEDMatrix.c \ drv_LPH7508.c \ drv_LUIse.c \ drv_LW_ABP.c \ drv_M50530.c \ drv_MatrixOrbital.c \ drv_MatrixOrbitalGX.c \ drv_MilfordInstruments.c \ drv_Noritake.c \ drv_NULL.c \ drv_Pertelian.c \ drv_PHAnderson.c \ drv_PICGraphic.c \ drv_picoLCD.c \ drv_picoLCDGraphic.c \ drv_RouterBoard.c \ drv_Sample.c \ drv_st2205.c \ drv_serdisplib.c \ drv_ShuttleVFD.c \ drv_SimpleLCD.c \ drv_T6963.c \ drv_Trefon.c \ drv_ula200.c \ drv_USBHUB.c \ drv_USBLCD.c \ drv_vnc.c \ drv_WincorNixdorf.c \ drv_X11.c \ \ font_6x8.h \ font_6x8_bold.h \ widget_image.c widget_image.h \ \ lcd4linux_i2c.h \ \ plugin_apm.c \ plugin_asterisk.c \ plugin_button_exec.c \ plugin_cpuinfo.c \ plugin_dbus.c \ plugin_diskstats.c \ plugin_dvb.c \ plugin_exec.c \ plugin_fifo.c \ plugin_file.c \ plugin_gps.c \ plugin_hddtemp.c \ plugin_i2c_sensors.c \ plugin_iconv.c \ plugin_imon.c \ plugin_isdn.c \ plugin_kvv.c \ plugin_loadavg.c \ plugin_meminfo.c \ plugin_mpd.c \ plugin_mpris_dbus.c \ plugin_mysql.c \ plugin_netdev.c \ plugin_netinfo.c \ plugin_pop3.c \ plugin_ppp.c \ plugin_proc_stat.c \ plugin_python.c \ plugin_qnaplog.c \ plugin_sample.c \ plugin_seti.c \ plugin_statfs.c \ plugin_uname.c \ plugin_uptime.c \ plugin_w1retap.c \ plugin_wireless.c \ plugin_xmms.c EXTRA_DIST = \ svn_version.sh \ lcd4linux.conf.sample \ lcd4kde.conf \ lcd4linux.kdelnk \ lcd4linux.xpm \ lcd4linux.lsm \ ax_python_devel.m4 \ curses.m4 \ drivers.m4 \ plugins.m4 \ AUTHORS \ CREDITS \ NEWS \ TODO \ README \ plugin_sample.c all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBT
/* $Id$
 * $URL$
 *
 * pure ncurses based text driver
 *
 * Copyright (C) 2004 Michael Reinelt <michael@reinelt.co.at>
 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * based on the old Curses/Text driver which is
 * Copyright (C) 2001 Leopold Toetsch <lt@toetsch.at>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * LCD4Linux is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/* 
 *
 * exported fuctions:
 *
 * struct DRIVER drv_Curses
 *
 */

#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <curses.h>

#include "debug.h"
#include "cfg.h"
#include "qprintf.h"
#include "timer.h"
#include "plugin.h"
#include "widget.h"
#include "widget_text.h"
#include "widget_bar.h"
#include "widget_keypad.h"
#include "drv.h"
#include "drv_generic_text.h"
#include "drv_generic_keypad.h"


static char Name[] = "Curses";

static WINDOW *w = NULL;
static WINDOW *e = NULL;

static int EROWS;


/****************************************/
/***  hardware dependant functions    ***/
/****************************************/

static void drv_Curs_clear(void)
{
    werase(w);
    box(w, 0, 0);
    wrefresh(w);
}


static void drv_Curs_write(const int row, const int col, const char *data, const int len)
{
    int l = len;
    char *p;

    while ((p = strpbrk(data, "\r\n")) != NULL) {
	*p = '\0';
    }

    if (col < DCOLS) {
	if (DCOLS - col < l)
	    l = DCOLS - col;
	mvwprintw(w, row + 1, col + 1, "%.*s", l, data);
	wmove(w, DROWS + 1, 0);
	wrefresh(w);
    }
}


static void drv_Curs_defchar(const __attribute__ ((unused))
			     int ascii, const __attribute__ ((unused))
			     unsigned char *buffer)
{
    /* empty */
}


/* ncures scroll SIGSEGVs on my system, so this is a workaroud */

int curses_error(char *buffer)
{
    static int lines = 0;
    static char *lb[100];
    int start, i;
    char *p;

    if (e == NULL)
	return 0;

    /* replace \r, \n with underscores */
    while ((p = strpbrk(buffer, "\r\n")) != NULL) {
	*p = '_';
    }

    if (lines >= EROWS) {
	free(lb[0]);
	for (i = 1; i <= EROWS; i++) {
	    lb[i - 1] = lb[i];
	}
	start = 0;
    } else {
	start = lines;
    }

    lb[lines] = strdup(buffer);
    for (i = start; i <= lines; i++) {
	mvwprintw(e, i + 1, 1, "%s", lb[i]);
	wclrtoeol(e);
    }

    box(e, 0, 0);
    mvwprintw(e, 0, 3, "Stderr:");
    wrefresh(e);

    if (lines < EROWS)
	lines++;

    return 1;
}


static int drv_Curs_start(const char *section, const int quiet)
{
    char *s;

    if (!running_foreground) {
	error("%s: You want me to display on /dev/null? Sorry, I can't ...", Name);
	error("%s: Maybe you want me to run in foreground? Try '-F'", Name);
	return -1;
    }

    s = cfg_get(section, "Size", "20x4");
    if (s == NULL || *s == '\0') {
	error("%s: no '%s.Size' entry from %s", Name, section, cfg_source());
	free(s);
	return -1;
    }
    if (sscanf(s, "%dx%d", &DCOLS, &DROWS) != 2 || DROWS < 1 || DCOLS < 1) {
	error("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source());
	free(s);
	return -1;
    }
    free(s);

    initscr();
    noecho();
    debug("%s: curses thinks that COLS=%d LINES=%d", Name, COLS, LINES);
    w = newwin(DROWS + 2, DCOLS + 2, 0, 0);
    keypad(w, TRUE);
    nodelay(w, TRUE);

    EROWS = LINES - DROWS - 3;
    if (EROWS > 99)
	EROWS = 99;
    debug("EROWS=%d", EROWS);

    if (EROWS >= 4) {
	e = newwin(EROWS, COLS, DROWS + 3, 0);
	EROWS -= 3;
	box(e, 0, 0);
	mvwprintw(e, 0, 3, "Stderr:");
	wmove(e, 1, 0);
	wrefresh(e);
    }

    drv_Curs_clear();

    if (!quiet) {
	char buffer[40];
	qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
	if (drv_generic_text_greet(buffer, NULL)) {
	    sleep(3);
	    drv_Curs_clear();
	}
    }

    return 0;
}

static void drv_Curs_timer(void __attribute__ ((unused)) * notused)
{
    int c;
    while (1) {
	c = wgetch(w);
	if (c <= 0)
	    break;
	drv_generic_keypad_press(c);
    }
}

static int drv_Curs_keypad(const int num)
{
    int val = 0;

    switch (num) {
    case KEY_UP:
	debug("Key Up");
	val += WIDGET_KEY_PRESSED;
	val += WIDGET_KEY_UP;
	break;
    case KEY_DOWN:
	debug("Key Down");
	val += WIDGET_KEY_PRESSED;
	val += WIDGET_KEY_DOWN;
	break;
    case KEY_LEFT:
	debug("Key Left");
	val += WIDGET_KEY_PRESSED;
	val += WIDGET_KEY_LEFT;
	break;
    case KEY_RIGHT:
	debug("Key Right");
	val += WIDGET_KEY_PRESSED;
	val += WIDGET_KEY_RIGHT;
	break;
    default:
	debug("Unbound Key '%d'", num);
	break;
    }

    return val;
}


/****************************************/
/***            plugins               ***/
/****************************************/

/* none at the moment... */


/****************************************/
/***        widget callbacks          ***/
/****************************************/

/* using drv_generic_text_draw(W) */
/* using drv_generic_text_bar_draw(W) */
/* using drv_generic_keypad_draw(W) */


/****************************************/
/***        exported functions        ***/
/****************************************/


/* list models */
int drv_Curs_list(void)
{
    printf("pure ncurses based text driver");
    return 0;
}


/* initialize driver & display */
int drv_Curs_init(const char *section, const int quiet)
{
    WIDGET_CLASS wc;
    int ret;

    info("%s: %s", Name, "$Rev$");

    /* display preferences */
    XRES = 1;			/* pixel width of one char  */
    YRES = 1;			/* pixel height of one char  */
    CHARS = 0;			/* number of user-defineable characters */
    CHAR0 = 0;			/* ASCII of first user-defineable char */
    GOTO_COST = 0;		/* number of bytes a goto command requires */

    /* real worker functions */
    drv_generic_text_real_write = drv_Curs_write;
    drv_generic_text_real_defchar = drv_Curs_defchar;
    drv_generic_keypad_real_press = drv_Curs_keypad;

    /* regularly process display answers */
    timer_add(drv_Curs_timer, NULL, 100, 0);

    /* start display */
    if ((ret = drv_Curs_start(section, quiet)) != 0) {
	return ret;
    }

    /* initialize generic text driver */
    if ((ret = drv_generic_text_init(section, Name)) != 0)
	return ret;

    /* initialize generic bar driver */
    if ((ret = drv_generic_text_bar_init(1)) != 0)
	return ret;

    /* initialize generic key pad driver */
    if ((ret = drv_generic_keypad_init(section, Name)) != 0)
	return ret;

    /* add fixed chars to the bar driver */
    drv_generic_text_bar_add_segment(0, 0, 255, 32);	/* ASCII  32 = blank */
    drv_generic_text_bar_add_segment(255, 255, 255, '*');	/* asterisk */

    /* register text widget */
    wc = Widget_Text;
    wc.draw = drv_generic_text_draw;
    widget_register(&wc);

    /* register bar widget */
    wc = Widget_Bar;
    wc.draw = drv_generic_text_bar_draw;
    widget_register(&wc);

    /* register plugins */
    /* none at the moment... */

    return 0;
}


/* close driver & display */
int drv_Curs_quit(const int quiet)
{

    info("%s: shutting down.", Name);

    drv_generic_text_quit();
    drv_generic_keypad_quit();

    /* clear display */
    drv_Curs_clear();

    /* say goodbye... */
    if (!quiet) {
	drv_generic_text_greet("goodbye!", NULL);
    }

    endwin();

    return (0);
}


DRIVER drv_Curses = {
    .name = Name,
    .list = drv_Curs_list,
    .init = drv_Curs_init,
    .quit = drv_Curs_quit,
};