]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-05-26 11:37:35 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 26 May 2004 11:37:36 +0000 (11:37 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 26 May 2004 11:37:36 +0000 (11:37 +0000)
Curses driver ported.

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@436 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

21 files changed:
Makefile.am
Makefile.in
Status
Text.c [deleted file]
config.h.in
configure
debug.c
drivers.m4
drv.c
drv_Crystalfontz.c
drv_Curses.c [new file with mode: 0644]
drv_Cwlinux.c
drv_HD44780.c
drv_M50530.c
drv_MatrixOrbital.c
drv_MilfordInstruments.c
drv_USBLCD.c
drv_generic_text.c
drv_generic_text.h
lcd4linux.conf.sample
widget.c

index fc01a64128e202c6a4d70780448d7f90475c73fc..ba83d2c667158d2ea496029f9f4c1ce56459037d 100644 (file)
@@ -59,6 +59,7 @@ drv_generic_parport.c       \
 drv_generic_parport.h       \
 BeckmannEgle.c              \
 drv_Crystalfontz.c          \
+drv_Curses.c                \
 drv_Cwlinux.c               \
 drv_HD44780.c               \
 drv_Image.c                 \
@@ -68,7 +69,7 @@ drv_MilfordInstruments.c    \
 drv_T6963.c                 \
 drv_USBLCD.c                \
 drv_X11.c                   \
-Text.c                      \
+                            \
 font_6x8.h                  \
                             \
 plugin_apm.c                \
index 897aa59b594a59571b8ac90bb884de1b6327f0a7..ebceaf828893597b556b8af9218cd042f2dc1a87 100644 (file)
@@ -101,7 +101,7 @@ lcd4linux_SOURCES =  lcd4linux.c                 cfg.c         cfg.h         deb
 
 #liblcd4linux_la_SOURCES =
 
-EXTRA_lcd4linux_SOURCES =  drv_generic_text.c          drv_generic_text.h          drv_generic_graphic.c       drv_generic_graphic.h       drv_generic_serial.c        drv_generic_serial.h        drv_generic_parport.c       drv_generic_parport.h       BeckmannEgle.c              drv_Crystalfontz.c          drv_Cwlinux.c               drv_HD44780.c               drv_Image.c                 drv_M50530.c                drv_MatrixOrbital.c         drv_MilfordInstruments.c    drv_T6963.c                 drv_USBLCD.c                drv_X11.c                   Text.c                      font_6x8.h                                              plugin_apm.c                plugin_cpuinfo.c            plugin_dvb.c                plugin_exec.c               plugin_i2c_sensors.c        plugin_imon.c               plugin_isdn.c               plugin_loadavg.c            plugin_meminfo.c            plugin_mysql.c              plugin_netdev.c             plugin_pop3.c               plugin_ppp.c                plugin_proc_stat.c          plugin_seti.c               plugin_uname.c              plugin_uptime.c             plugin_wireless.c           plugin_xmms.c
+EXTRA_lcd4linux_SOURCES =  drv_generic_text.c          drv_generic_text.h          drv_generic_graphic.c       drv_generic_graphic.h       drv_generic_serial.c        drv_generic_serial.h        drv_generic_parport.c       drv_generic_parport.h       BeckmannEgle.c              drv_Crystalfontz.c          drv_Curses.c                drv_Cwlinux.c               drv_HD44780.c               drv_Image.c                 drv_M50530.c                drv_MatrixOrbital.c         drv_MilfordInstruments.c    drv_T6963.c                 drv_USBLCD.c                drv_X11.c                                               font_6x8.h                                              plugin_apm.c                plugin_cpuinfo.c            plugin_dvb.c                plugin_exec.c               plugin_i2c_sensors.c        plugin_imon.c               plugin_isdn.c               plugin_loadavg.c            plugin_meminfo.c            plugin_mysql.c              plugin_netdev.c             plugin_pop3.c               plugin_ppp.c                plugin_proc_stat.c          plugin_seti.c               plugin_uname.c              plugin_uptime.c             plugin_wireless.c           plugin_xmms.c
 
 
 EXTRA_DIST =  lcd4linux.conf.sample       lcd4kde.conf                lcd4linux.kdelnk            lcd4linux.xpm               lcd4linux.lsm               curses.m4                   AUTHORS                     CREDITS                     FAQ                         NEWS                        TODO                        README                      README.Drivers              README.Plugins              README.KDE                  plugin_sample.c
@@ -139,8 +139,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
 TAR = tar
 GZIP_ENV = --best
-DEP_FILES =  .deps/BeckmannEgle.P .deps/Text.P .deps/cfg.P .deps/debug.P \
-.deps/drv.P .deps/drv_Crystalfontz.P .deps/drv_Cwlinux.P \
+DEP_FILES =  .deps/BeckmannEgle.P .deps/cfg.P .deps/debug.P .deps/drv.P \
+.deps/drv_Crystalfontz.P .deps/drv_Curses.P .deps/drv_Cwlinux.P \
 .deps/drv_HD44780.P .deps/drv_Image.P .deps/drv_M50530.P \
 .deps/drv_MatrixOrbital.P .deps/drv_MilfordInstruments.P \
 .deps/drv_T6963.P .deps/drv_USBLCD.P .deps/drv_X11.P \
diff --git a/Status b/Status
index 502ead34e5b8997bc4344790c997b77ade3bc382..de07359e66fc040b895fd62e285ca0fc88c82b91 100644 (file)
--- a/Status
+++ b/Status
@@ -3,6 +3,7 @@ Lcd4Linux NextGeneration porting status
  DRIVERS :  format : status (widgets) + extras [todo]
 -------------------------------------------------------
         Crystalfontz -> Ported (Text,Bar,Icon) + blacklight,contrast,pwm [gpo,rpm]
+              Curses -> Ported (Text,Bar)   
              Cwlinux -> Ported (Text,Bar,Icon) + blacklight [gpo,gpi,inverted text,relay]
              HD44780 -> Ported (Text,Bar,Icon) + soft brightness,'busy flag',gpo [soft contrast]
               M50530 -> Ported (Text,Bar,Icon) + gpo
@@ -14,7 +15,6 @@ Lcd4Linux NextGeneration porting status
              Raster* -> Ported (Text,Bar,Icon)
 
         BeckmannEgle ->     
-              Curses ->    
 
            PalmPilot -> Obsolete
                  SIN -> Obsolete
diff --git a/Text.c b/Text.c
deleted file mode 100644 (file)
index 9499b0d..0000000
--- a/Text.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/* $Id: Text.c,v 1.15 2004/03/03 03:47:04 reinelt Exp $
- *
- * pure ncurses based text driver
- *
- * Copyright 2001 Leopold Tötsch <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.
- *
- *
- * $Log: Text.c,v $
- * Revision 1.15  2004/03/03 03:47:04  reinelt
- * big patch from Martin Hejl:
- * - use qprintf() where appropriate
- * - save CPU cycles on gettimeofday()
- * - add quit() functions to free allocated memory
- * - fixed lots of memory leaks
- *
- * Revision 1.14  2004/01/29 04:40:02  reinelt
- * every .c file includes "config.h" now
- *
- * Revision 1.13  2004/01/09 04:16:06  reinelt
- * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
- *
- * Revision 1.12  2003/10/05 17:58:50  reinelt
- * libtool junk; copyright messages cleaned up
- *
- * Revision 1.11  2003/09/13 06:45:43  reinelt
- * icons for all remaining drivers
- *
- * Revision 1.10  2003/08/24 05:17:58  reinelt
- * liblcd4linux patch from Patrick Schemitz
- *
- * Revision 1.9  2003/07/24 04:48:09  reinelt
- * 'soft clear' needed for virtual rows
- *
- * Revision 1.8  2003/02/22 07:53:10  reinelt
- * cfg_get(key,defval)
- *
- * Revision 1.7  2003/02/17 04:27:58  reinelt
- * Text (curses) driver: cosmetic changes
- *
- * Revision 1.6  2002/08/30 03:54:01  reinelt
- * bug in curses driver fixed
- *
- * Revision 1.5  2002/08/19 04:41:20  reinelt
- * introduced bar.c, moved bar stuff from display.h to bar.h
- *
- * Revision 1.4  2001/03/16 16:40:17  ltoetsch
- * implemented time bar
- *
- * Revision 1.3  2001/03/16 09:28:08  ltoetsch
- * bugfixes
- *
- * Revision 1.2  2001/03/09 15:04:53  reinelt
- *
- * rename 'raster' to 'Text in Text.c
- * added TOTO item
- *
- * Revision 1.1  2001/03/09 13:08:11  ltoetsch
- * Added Text driver
- *
- *
- */
-
-/* 
- *
- * exported fuctions:
- *
- * struct LCD Text[]
- *
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <curses.h>
-
-#define min(x,y) (x)<(y)?x:y
-
-
-#ifdef STANDALONE
-
-int main(int argc, char *argv[]) 
-{
-  WINDOW *w;
-  int x,y;
-  
-  w = initscr();
-  
-  for (x=0; x < 255; x++)
-    addch(acs_map[x]);    
-  refresh();
-  sleep(5);
-  endwin();
-  return 0;
-  
-}
-
-#else
-
-#include <string.h>
-#include "debug.h"
-#include "cfg.h"
-#include "display.h"
-#include "bar.h"
-
-extern int running_foreground;
-
-static LCD Lcd;
-static WINDOW *w, *err_win;
-static int err_rows;
-
-
-int Text_clear (int full)
-{
-  if (full) {
-    werase(w);
-    box(w, 0, 0);
-  }
-  return 0;
-}
-
-
-int Text_quit(void) {
-  endwin();
-  return 0;
-}
-
-
-int Text_init (LCD *Self)
-{
-  int cols=-1, rows=-1;
-  int scr_cols, scr_rows;
-  char *s;
-  if (!running_foreground) {
-    error("Text: you want me to display on /dev/null: sorry, I can't");
-    error("Text: Maybe you want me to run in foreground? Try '-F'");
-    return -1;
-  }
-  
-  if (sscanf(s=cfg_get(NULL, "size", "20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) {
-    error ("Text: bad size '%s'", s);
-    return -1;
-  }
-  free(s);
-  Self->rows=rows;
-  Self->cols=cols;
-  Self->xres=1;
-  Self->yres=1;
-  Lcd=*Self;
-  
-  initscr();
-  scr_cols=COLS;
-  scr_rows=LINES;
-  debug ("curses thinks that COLS=%d LINES=%d", COLS, LINES);
-  w = newwin(rows+2,cols+2,0,0);
-  err_rows = scr_rows-rows-3;
-  err_rows = min(99, err_rows);
-  debug ("err_rows=%d", err_rows);
-  if (err_rows >= 4) {
-    err_win = newwin(err_rows, scr_cols, rows+3, 0);
-    err_rows -= 3;
-    box(err_win, 0, 0);
-    mvwprintw(err_win,0,3, "Stderr:");
-    wmove(err_win, 1 , 0);
-    wrefresh(err_win);
-  }
-  Text_clear(1);
-  return w ? 0 : -1;
-}
-
-
-/* ncures scroll SIGSEGVs on my system, so this is a workaroud */
-
-int curs_err(char *buffer) 
-{
-  static int lines;
-  static char *lb[100];
-  int start, i;
-  char *p;
-  
-  if (err_win) {
-    /* replace \r, \n with underscores */
-    while ((p = strpbrk(buffer, "\r\n")) != NULL)
-      *p='_';
-    if (lines >= err_rows) {
-      free(lb[0]);
-      for (i=1; i<=err_rows; i++) 
-       lb[i-1] = lb[i];
-      start = 0;
-    }
-    else
-      start = lines;
-    lb[lines] = strdup(buffer);
-    for (i=start; i<=lines; i++) {
-      mvwprintw(err_win,i+1,1, "%s", lb[i]);
-      wclrtoeol(err_win);
-    }
-    box(err_win, 0, 0);
-    mvwprintw(err_win,0,3, "Stderr:");
-    wrefresh(err_win);
-    if (lines < err_rows)
-      lines++;
-    return 1;
-  }
-  return 0;
-}
-
-
-int Text_put (int row, int col, char *text)
-{
-  char *p;
-  
-  while ((p = strpbrk(text, "\r\n")) != NULL) {
-    *p='\0';
-  }
-  if (col < Lcd.cols) {
-    mvwprintw(w, row+1 , col+1, "%.*s", Lcd.cols-col, text);
-  }
-  return 0;
-}
-
-
-int Text_bar (int type, int row, int col, int max, int len1, int len2)
-{
-  int len, i;
-  char* s;
-  if (s=cfg_get(NULL, "TextBar", NULL)) {
-    mvwprintw(w, row+1 , col+1, "%d %d %d", max, len1, len2);
-  } else {
-    len = min(len1, len2);
-    len = min(len, Lcd.cols-col-1);
-    if (len) {
-      wmove(w, row+1 , col+1);
-      for (i=0; i<len;i++)
-        waddch(w,ACS_BLOCK);
-    }
-    col += len;
-    len1 -= len;
-    len2 -= len;
-    len1 = min(len1, Lcd.cols-col-1);
-    for (i=0; i<len1;i++)
-      waddch(w,ACS_S1);
-    len2 = min(len2, Lcd.cols-col-1);
-    for (i=0; i<len2;i++)
-      waddch(w,ACS_S9);
-  }
-  free(s);  
-  return 0;
-}
-
-
-int Text_flush (void)
-{
-  box(w, 0, 0);
-  wrefresh(w);  
-  return 0;
-}
-
-
-LCD Text[] = {
-  { name: "Text",
-    rows:  4,
-    cols:  20,
-    xres:  1,
-    yres:  1,
-    bars:  BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2,
-    icons: 0,
-    gpos:  0,
-    init:  Text_init,
-    clear: Text_clear,
-    put:   Text_put,
-    bar:   Text_bar,
-    icon:  NULL,
-    gpo:   NULL,
-    flush: Text_flush,
-    quit:  Text_quit 
-  },
-  { NULL }
-};
-
-#endif
index 2831dddab4ad2e83cb41a0b2ab5fabff837da770..4f81f0de130d9aeff953efc987aeb466b8bc2003 100644 (file)
 /* Crystalfontz driver */
 #undef WITH_CRYSTALFONTZ
 
+/* Curses driver */
+#undef WITH_CURSES
+
 /* CwLinux driver */
 #undef WITH_CWLINUX
 
 /* T6963 driver */
 #undef WITH_T6963
 
-/* Curses driver */
-#undef WITH_TEXT
-
 /* USBLCD driver */
 #undef WITH_USBLCD
 
index a48f43c1d8781d6f8bd99ec7dc6c40e6f78582a5..a5194e7f80953027a8352e97cd544d6c2651355f 100755 (executable)
--- a/configure
+++ b/configure
@@ -5505,13 +5505,13 @@ fi
 
 if test "$CURSES" = "yes"; then
    if test "$has_curses" = true; then
-#     DRIVERS="$DRIVERS Text.lo"
-#     DRIVERS="$DRIVERS Text.o"
+#     DRIVERS="$DRIVERS drv_Curses.lo"
+      DRIVERS="$DRIVERS drv_Curses.o"
       DRVLIBS="$DRVLIBS $CURSES_LIBS"
       CPPFLAGS="$CPPFLAGS $CURSES_INCLUDES"
 
 cat >>confdefs.h <<\_ACEOF
-#define WITH_TEXT 1
+#define WITH_CURSES 1
 _ACEOF
 
    else
diff --git a/debug.c b/debug.c
index 937bc049b8a2d14682c63a2f2f6f5526c2a7425f..55bb16dc71c63eb802ac7fce0b6c4730e027e6c2 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -1,4 +1,4 @@
-/* $Id: debug.c,v 1.7 2004/02/10 07:42:35 reinelt Exp $
+/* $Id: debug.c,v 1.8 2004/05/26 11:37:36 reinelt Exp $
  *
  * debug() and error() functions
  *
  *
  *
  * $Log: debug.c,v $
+ * Revision 1.8  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.7  2004/02/10 07:42:35  reinelt
  * cut off all old-style files which are no longer used with NextGeneration
  *
@@ -87,12 +91,10 @@ void message (int level, const char *format, ...)
   va_end(ap);
   
   if (!running_background) {
-    // Fixme
-#if 0
-#ifdef WITH_TEXT
-    extern int curs_err(char *);
-    if (!curs_err(buffer))
-#endif
+    
+#ifdef WITH_CURSES
+    extern int curses_error(char *);
+    if (!curses_error(buffer))
 #endif      
       fprintf (level?stdout:stderr, "%s\n", buffer);
   }
@@ -102,7 +104,7 @@ void message (int level, const char *format, ...)
   
   if (!log_open) {
     openlog ("LCD4Linux", LOG_PID, LOG_USER);
-    log_open=1;
+    log_open = 1;
   }
   
   switch (level) {
index ce09a672f962895e4ce97e37f899a0dcecd2ea58..a50b70f84143ee85e93de11eab883e7e7215f491 100644 (file)
@@ -116,11 +116,11 @@ fi
 
 if test "$CURSES" = "yes"; then
    if test "$has_curses" = true; then
-#     DRIVERS="$DRIVERS Text.lo"
-#     DRIVERS="$DRIVERS Text.o"
+#     DRIVERS="$DRIVERS drv_Curses.lo"
+      DRIVERS="$DRIVERS drv_Curses.o"
       DRVLIBS="$DRVLIBS $CURSES_LIBS"
       CPPFLAGS="$CPPFLAGS $CURSES_INCLUDES"
-      AC_DEFINE(WITH_TEXT,1,[Curses driver])
+      AC_DEFINE(WITH_CURSES,1,[Curses driver])
    else
       AC_MSG_WARN(curses not found: Curses driver disabled)
    fi   
diff --git a/drv.c b/drv.c
index f5d10adb6c52a0f4b23a74fbbf7ccd987d4ffb0d..3c05520d8ca396ab91307d29cc8934e9e9c379ba 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -1,4 +1,4 @@
-/* $Id: drv.c,v 1.12 2004/05/26 05:03:27 reinelt Exp $
+/* $Id: drv.c,v 1.13 2004/05/26 11:37:36 reinelt Exp $
  *
  * new framework for display drivers
  *
  *
  *
  * $Log: drv.c,v $
+ * Revision 1.13  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.12  2004/05/26 05:03:27  reinelt
  *
  * MilfordInstruments driver ported
 
 extern DRIVER drv_BeckmannEgle;
 extern DRIVER drv_Crystalfontz;
+extern DRIVER drv_Curses;
 extern DRIVER drv_Cwlinux;
 extern DRIVER drv_HD44780;
 extern DRIVER drv_Image;
@@ -133,7 +138,6 @@ extern DRIVER drv_USBLCD;
 extern DRIVER drv_MatrixOrbital;
 extern DRIVER drv_MilfordInstruments;
 extern DRIVER drv_X11;
-extern DRIVER drv_Text;
 
 // output file for Image driver
 // has to be defined here because it's referenced
@@ -152,6 +156,9 @@ DRIVER *Driver[] = {
 #ifdef WITH_CWLINUX
   &drv_Cwlinux,
 #endif
+#ifdef WITH_CURSES
+  &drv_Curses,
+#endif
 #ifdef WITH_HD44780
   &drv_HD44780,
 #endif
@@ -176,11 +183,6 @@ DRIVER *Driver[] = {
 #ifdef WITH_X11
   &drv_X11,
 #endif
-  /* Fixme
-     #ifdef WITH_TEXT
-     &Text,
-     #endif
-  */
   NULL,
 };
 
index 26b897cae2229d5b18e5fc01c652bae584c01656..242bc1a75d78984ec459364f19cf09f7fafd7815 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_Crystalfontz.c,v 1.15 2004/05/25 14:26:29 reinelt Exp $
+/* $Id: drv_Crystalfontz.c,v 1.16 2004/05/26 11:37:36 reinelt Exp $
  *
  * new style driver for Crystalfontz display modules
  *
  *
  *
  * $Log: drv_Crystalfontz.c,v $
+ * Revision 1.16  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.15  2004/05/25 14:26:29  reinelt
  *
  * added "Image" driver (was: Raster.c) for PPM and PNG creation
@@ -873,7 +877,7 @@ int drv_CF_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
diff --git a/drv_Curses.c b/drv_Curses.c
new file mode 100644 (file)
index 0000000..8c94668
--- /dev/null
@@ -0,0 +1,283 @@
+/* $Id: drv_Curses.c,v 1.1 2004/05/26 11:37:36 reinelt Exp $
+ *
+ * pure ncurses based text driver
+ *
+ * Copyright 2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * based on the old Curses/Text driver which is
+ * Copyright 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.
+ *
+ *
+ * $Log: drv_Curses.c,v $
+ * Revision 1.1  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
+ */
+
+/* 
+ *
+ * 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 "plugin.h"
+#include "widget.h"
+#include "widget_text.h"
+#include "widget_bar.h"
+#include "drv.h"
+#include "drv_generic_text.h"
+
+
+static char Name[]="Curses";
+
+static WINDOW *w = NULL;
+static WINDOW *e = NULL;
+
+static int EROWS;
+
+
+// ****************************************
+// ***  hardware dependant functions    ***
+// ****************************************
+
+static void drv_Curs_write (int row, int col, unsigned char *data, int len)
+{
+  char *p;
+  
+  while ((p = strpbrk(data, "\r\n")) != NULL) {
+    *p = '\0';
+  }
+  
+  if (col < DCOLS) {
+    if (DCOLS-col < len ) len = DCOLS-col;
+    mvwprintw(w, row+1 , col+1, "%.*s", DCOLS-col, data);
+    box(w, 0, 0);
+    wmove(w, DROWS+1, 0);
+    wrefresh(w);  
+  }
+}
+
+
+static void drv_Curs_defchar (int ascii, 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 (char *section)
+{
+  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();
+  debug ("%s: curses thinks that COLS=%d LINES=%d", Name, COLS, LINES);
+  w = newwin(DROWS+2, DCOLS+2, 0, 0);
+  
+  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);
+  }
+
+  werase (w);
+  box (w, 0, 0);
+  wrefresh (w);
+
+  return 0;
+}
+
+
+// ****************************************
+// ***            plugins               ***
+// ****************************************
+
+// none at the moment...
+
+
+// ****************************************
+// ***        widget callbacks          ***
+// ****************************************
+
+// using drv_generic_text_draw(W)
+// using drv_generic_text_bar_draw(W)
+
+
+// ****************************************
+// ***        exported functions        ***
+// ****************************************
+
+
+// list models
+int drv_Curs_list (void)
+{
+  printf ("any");
+  return 0;
+}
+
+
+// initialize driver & display
+int drv_Curs_init (char *section)
+{
+  WIDGET_CLASS wc;
+  int ret;  
+  
+  // 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;
+
+  // start display
+  if ((ret = drv_Curs_start (section)) != 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;
+  
+  // 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 (void) {
+
+  info("%s: shutting down.", Name);
+  drv_generic_text_quit();
+  endwin();
+  
+  return (0);
+}
+
+
+DRIVER drv_Curses = {
+  name: Name,
+  list: drv_Curs_list,
+  init: drv_Curs_init,
+  quit: drv_Curs_quit, 
+};
+
index 349aa541914f768f8ed50f5e5d63fd7b658300ee..0a07238f8434710ead7db0543f7d69072b932428 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_Cwlinux.c,v 1.4 2004/03/19 09:17:46 reinelt Exp $
+/* $Id: drv_Cwlinux.c,v 1.5 2004/05/26 11:37:36 reinelt Exp $
  *
  * new style driver for Cwlinux display modules
  *
  *
  *
  * $Log: drv_Cwlinux.c,v $
+ * Revision 1.5  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.4  2004/03/19 09:17:46  reinelt
  *
  * removed the extra 'goto' function, row and col are additional parameters
@@ -311,7 +315,7 @@ int drv_CW_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
index e3b302ededb60519916f15e0dd0e5dd9c100cddc..36e41c703f06ac09df98b6d26ed32beca5adc92f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.20 2004/05/22 04:23:49 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.21 2004/05/26 11:37:36 reinelt Exp $
  *
  * new style driver for HD44780-based displays
  *
  *
  *
  * $Log: drv_HD44780.c,v $
+ * Revision 1.21  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.20  2004/05/22 04:23:49  reinelt
  *
  * removed 16*x fix again (next time think before commit :-)
@@ -583,12 +587,12 @@ static int drv_HD_start (char *section)
   strsize=cfg_get(section, "Size", NULL);
   if (strsize==NULL || *strsize=='\0') {
     error ("%s: no '%s.Size' entry from %s", Name, section, cfg_source());
-       free(strsize);
+    free(strsize);
     return -1;
   }
   if (sscanf(strsize,"%dx%d",&cols,&rows)!=2 || rows<1 || cols<1) {
-    error ("%s: bad size '%s'", Name, strsize);
-       free(strsize);
+    error ("%s: bad %s.Size '%s' from %s", Name, section, strsize, cfg_source());
+    free(strsize);
     return -1;
   }
     
@@ -776,7 +780,7 @@ int drv_HD_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
index 929e52716883ab018993aea09d3b7b7a887eca31..e982b7dbe68ea662ee731c4e7c50b8ae1afa5600 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_M50530.c,v 1.3 2004/03/19 09:17:46 reinelt Exp $
+/* $Id: drv_M50530.c,v 1.4 2004/05/26 11:37:36 reinelt Exp $
  *
  * new style driver for M50530-based displays
  *
  *
  *
  * $Log: drv_M50530.c,v $
+ * Revision 1.4  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.3  2004/03/19 09:17:46  reinelt
  *
  * removed the extra 'goto' function, row and col are additional parameters
@@ -306,7 +310,7 @@ int drv_M5_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
index 899b124c519f118dba831ddb396d893e65f4371a..bab06380f49c71866e63fbec1d7c675a1f3c26d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.21 2004/03/19 09:17:46 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.22 2004/05/26 11:37:36 reinelt Exp $
  *
  * new style driver for Matrix Orbital serial display modules
  *
  *
  *
  * $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.22  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.21  2004/03/19 09:17:46  reinelt
  *
  * removed the extra 'goto' function, row and col are additional parameters
@@ -493,7 +497,7 @@ int drv_MO_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
index 534fbdeb193093284b4d0bdfc14727223abee2ac..44ba12ab414d01488b212583d176faac2803035b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_MilfordInstruments.c,v 1.1 2004/05/26 05:03:27 reinelt Exp $
+/* $Id: drv_MilfordInstruments.c,v 1.2 2004/05/26 11:37:36 reinelt Exp $
  *
  * driver for Milford Instruments 'BPK' piggy-back serial interface board
  * for standard Hitachi 44780 compatible lcd modules.
  *
  *
  * $Log: drv_MilfordInstruments.c,v $
+ * Revision 1.2  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.1  2004/05/26 05:03:27  reinelt
  *
  * MilfordInstruments driver ported
@@ -210,7 +214,7 @@ int drv_MI_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
index 55b25b6b33c922e9e01224cc77d0f60d9f593916..1fbad54b98957b1a9ed732d7b8c9935ac93a32f8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_USBLCD.c,v 1.3 2004/05/23 08:58:30 reinelt Exp $
+/* $Id: drv_USBLCD.c,v 1.4 2004/05/26 11:37:36 reinelt Exp $
  *
  * new style driver for USBLCD displays
  *
  *
  *
  * $Log: drv_USBLCD.c,v $
+ * Revision 1.4  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.3  2004/05/23 08:58:30  reinelt
  *
  * icon bug with USBLCD fixed
@@ -311,7 +315,7 @@ int drv_UL_init (char *section)
     return ret;
   
   // initialize generic bar driver
-  if ((ret=drv_generic_text_bar_init())!=0)
+  if ((ret=drv_generic_text_bar_init(0))!=0)
     return ret;
   
   // add fixed chars to the bar driver
index bb28a89844824f5d49532315f18a891f117dacac..68d776a678d32039850f5e9026266650dffd8488 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.13 2004/03/19 09:17:46 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.14 2004/05/26 11:37:36 reinelt Exp $
  *
  * generic driver helper for text-based displays
  *
  *
  *
  * $Log: drv_generic_text.c,v $
+ * Revision 1.14  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.13  2004/03/19 09:17:46  reinelt
  *
  * removed the extra 'goto' function, row and col are additional parameters
@@ -142,8 +146,10 @@ int ICONS;        // number of user-defineable characters reserved for icons
 static unsigned char *LayoutFB    = NULL;
 static unsigned char *DisplayFB   = NULL;
 
-static int nSegment=0;
-static int fSegment=0;
+static int Single_Segments = 0;
+
+static int nSegment = 0;
+static int fSegment = 0;
 static SEGMENT Segment[128];
 static BAR *BarFB = NULL;
 
@@ -486,7 +492,7 @@ static void drv_generic_text_bar_pack_segments (void)
     pack_j=-1;
     for (i=fSegment; i<nSegment; i++) {
       if (pass1 && Segment[i].used) continue;
-      for (j=0; j<nSegment; j++) {
+       for (j=0; j<nSegment; j++) {
        if (error[i][j]<min) {
          min=error[i][j];
          pack_i=i;
@@ -500,6 +506,10 @@ static void drv_generic_text_bar_pack_segments (void)
        continue;
       } else {
        error ("unable to compact bar characters");
+       error ("nSegment=%d fSegment=%d CHARS=%d ICONS=%d", nSegment, fSegment, CHARS, ICONS);
+       error ("Segment[0].val1=%d val2=%d", Segment[0].val1, Segment[0].val2);
+       error ("Segment[1].val1=%d val2=%d", Segment[1].val1, Segment[1].val2);
+       error ("Segment[2].val1=%d val2=%d", Segment[2].val1, Segment[2].val2);
        nSegment=CHARS-ICONS;
        break;
       }
@@ -598,16 +608,18 @@ int drv_generic_text_bar_draw (WIDGET *W)
     drv_generic_text_resizeFB (row+1, col+1);
   }
 
-  res  = dir & (DIR_EAST|DIR_WEST)?XRES:YRES;
+  res  = dir & (DIR_EAST|DIR_WEST) ? XRES : YRES;
   max  = len * res;
   val1 = Bar->val1 * (double)(max);
   val2 = Bar->val2 * (double)(max);
   
-  if      (val1<1)   val1=1;
-  else if (val1>max) val1=max;
+  if      (val1 < 1)   val1 = 1;
+  else if (val1 > max) val1 = max;
   
-  if      (val2<1)   val2=1;
-  else if (val2>max) val2=max;
+  if      (val2 < 1)   val2 = 1;
+  else if (val2 > max) val2 = max;
+  
+  if (Single_Segments) val2 = val1;
   
   // create this bar
   drv_generic_text_bar_create_bar (row, col, dir, len, val1, val2);
@@ -704,7 +716,7 @@ int drv_generic_text_icon_init (void)
 }
 
 
-int drv_generic_text_bar_init (void)
+int drv_generic_text_bar_init (int single_segments)
 {
   if (BarFB) free (BarFB);
   
@@ -713,6 +725,8 @@ int drv_generic_text_bar_init (void)
     return -1;
   }
   
+  Single_Segments = single_segments;
+  
   nSegment=0;
   fSegment=0;
   
index 16d143633d780cd7ec6148d5d3c3e18bc763b241..8e7f3ba6bc26e98a5a09a862a2023d8551b137e2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h,v 1.8 2004/03/19 09:17:46 reinelt Exp $
+/* $Id: drv_generic_text.h,v 1.9 2004/05/26 11:37:36 reinelt Exp $
  *
  * generic driver helper for text-based displays
  *
  *
  *
  * $Log: drv_generic_text.h,v $
+ * Revision 1.9  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.8  2004/03/19 09:17:46  reinelt
  *
  * removed the extra 'goto' function, row and col are additional parameters
@@ -89,7 +93,7 @@ int  drv_generic_text_init            (char *section, char *driver);
 int  drv_generic_text_draw            (WIDGET *W);
 int  drv_generic_text_icon_init       (void);
 int  drv_generic_text_icon_draw       (WIDGET *W);
-int  drv_generic_text_bar_init        (void);
+int  drv_generic_text_bar_init        (int single_segments);
 void drv_generic_text_bar_add_segment (int val1, int val2, DIRECTION dir, int ascii);
 int  drv_generic_text_bar_draw        (WIDGET *W);
 int  drv_generic_text_quit            (void);
index a54a1c197f4e2cf27265476ccf4d8365486ed6e5..1ac3326f39940a3fe30c823a815e574c729ed7a4 100644 (file)
@@ -44,6 +44,12 @@ Display CF633 {
     Backlight 50
 }
 
+Display Curses {
+    Driver 'Curses'
+    Size '20x4'
+}
+
+
 Display HD44780-20x4 {
     Driver 'HD44780'
     Port '/dev/parports/0'     
@@ -405,8 +411,7 @@ Widget Test {
 
 Layout Default {
     Row1 {
-       Col1  'Heartbeat'
-       #Col1  'OS'
+       Col1  'OS'
     }
     Row2 {
        Col1  'CPU'
@@ -490,12 +495,13 @@ Layout testMySQL {
 
 
 #Display 'LK204'
-Display 'MI240'
+#Display 'MI240'
 #Display 'HD44780-20x4'
 #Display 'M50530-24x8'
 #Display 'CF631'
 #Display 'CF632'
 #Display 'CF633'
+Display 'Curses'
 #Display 'USBLCD'
 #Display 'T6963-240x64'
 #Display 'XWindow'
index 2eaf240d9ec88aeb287ba7afe0ee66bc070ae40e..e7be927155c76ff1dca99261411d663dea202c4c 100644 (file)
--- a/widget.c
+++ b/widget.c
@@ -1,4 +1,4 @@
-/* $Id: widget.c,v 1.13 2004/03/03 03:47:04 reinelt Exp $
+/* $Id: widget.c,v 1.14 2004/05/26 11:37:36 reinelt Exp $
  *
  * generic widget handling
  *
  *
  *
  * $Log: widget.c,v $
+ * Revision 1.14  2004/05/26 11:37:36  reinelt
+ *
+ * Curses driver ported.
+ *
  * Revision 1.13  2004/03/03 03:47:04  reinelt
  * big patch from Martin Hejl:
  * - use qprintf() where appropriate
@@ -180,11 +184,12 @@ int widget_add (char *name, int row, int col)
       break;
     }
   }
-  if (class) free (class);
   if (i==nClasses) {
-    error ("widget '%s': class '%s' not supported");
+    error ("widget '%s': class '%s' not supported", name, class);
+    if (class) free (class);
     return -1;
   }
+  if (class) free (class);
   
   // do NOT use realloc here because there may be pointers to the old
   // memory area, which would point to nowhere if realloc moves the area