aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cfg.c26
-rw-r--r--drv_generic_graphic.c10
-rw-r--r--layout.c26
-rw-r--r--layout.h8
-rw-r--r--lcd4linux.conf.sample40
5 files changed, 89 insertions, 21 deletions
diff --git a/cfg.c b/cfg.c
index f0e483a..5b87bae 100644
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.48 2006/01/30 12:53:07 reinelt Exp $^
+/* $Id: cfg.c,v 1.49 2006/02/07 05:36:13 reinelt Exp $^
*
* config file stuff
*
@@ -23,6 +23,9 @@
*
*
* $Log: cfg.c,v $
+ * Revision 1.49 2006/02/07 05:36:13 reinelt
+ * Layers added to Layout
+ *
* Revision 1.48 2006/01/30 12:53:07 reinelt
* replaced strncpy with strcpy where possible
*
@@ -397,7 +400,7 @@ static char *dequote(char *string)
/* which if a string contains only valid chars */
/* i.e. start with a char and contains chars and nums */
-static int validchars(const char *string)
+static int validchars(const char *string, const int numstart)
{
const char *c;
@@ -405,8 +408,11 @@ static int validchars(const char *string)
/* first and following chars */
if ((*c >= 'A' && *c <= 'Z') || (*c >= 'a' && *c <= 'z') || (*c == '_'))
continue;
+ /* number as first or following char */
+ if ((numstart || c > string) && *c >= '0' && *c <= '9')
+ continue;
/* only following chars */
- if ((c > string) && ((*c >= '0' && *c <= '9') || (*c == '.') || (*c == '-')))
+ if ((c > string) && ((*c == '.') || (*c == '-')))
continue;
return 0;
}
@@ -460,7 +466,7 @@ int cfg_cmd(const char *arg)
char *key, *val;
char *buffer;
- buffer = strdup (arg);
+ buffer = strdup(arg);
key = strip(buffer, 0);
for (val = key; *val; val++) {
if (*val == '=') {
@@ -469,18 +475,18 @@ int cfg_cmd(const char *arg)
}
}
if (*key == '\0' || *val == '\0') {
- free (buffer);
+ free(buffer);
return -1;
}
- if (!validchars(key)) {
- free (buffer);
+ if (!validchars(key, 0)) {
+ free(buffer);
return -1;
}
cfg_add("", key, val, 1);
- free (buffer);
+ free(buffer);
return 0;
}
@@ -755,14 +761,14 @@ static int cfg_read(const char *file)
}
/* check key for valid chars */
- if (!validchars(key)) {
+ if (!validchars(key, 0)) {
error("error in config file '%s' line %d: key '%s' is invalid", file, lineno, key);
error = 1;
break;
}
/* on section-open, check value for valid chars */
- if (section_open && !validchars(val)) {
+ if (section_open && !validchars(val, 1)) {
error("error in config file '%s' line %d: section '%s' is invalid", file, lineno, val);
error = 1;
break;
diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c
index af209fd..6a4bdeb 100644
--- a/drv_generic_graphic.c
+++ b/drv_generic_graphic.c
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_graphic.c,v $
+ * Revision 1.19 2006/02/07 05:36:13 reinelt
+ * Layers added to Layout
+ *
* Revision 1.18 2006/01/30 05:47:38 reinelt
* graphic subsystem changed to full-color RGBA
*
@@ -136,6 +139,7 @@
#include "debug.h"
#include "cfg.h"
#include "plugin.h"
+#include "layout.h"
#include "widget.h"
#include "widget_text.h"
#include "widget_icon.h"
@@ -149,9 +153,6 @@
#include <dmalloc.h>
#endif
-/* number of layers */
-#define LAYERS 4
-
int DROWS, DCOLS; /* display size (pixels!) */
int XRES, YRES; /* pixels of one char cell */
@@ -257,6 +258,7 @@ static void drv_generic_graphic_render(const int layer, const int row, const int
/* sanity checks */
if (layer < 0 || layer >= LAYERS) {
error("%s: layer %d out of bounds (0..%d)", Driver, layer, LAYERS - 1);
+ return;
}
len = strlen(txt);
@@ -386,6 +388,7 @@ int drv_generic_graphic_icon_draw(WIDGET * W)
/* sanity check */
if (layer < 0 || layer >= LAYERS) {
error("%s: layer %d out of bounds (0..%d)", Driver, layer, LAYERS - 1);
+ return -1;
}
/* maybe grow layout framebuffer */
@@ -440,6 +443,7 @@ int drv_generic_graphic_bar_draw(WIDGET * W)
/* sanity check */
if (layer < 0 || layer >= LAYERS) {
error("%s: layer %d out of bounds (0..%d)", Driver, layer, LAYERS - 1);
+ return -1;
}
/* maybe grow layout framebuffer */
diff --git a/layout.c b/layout.c
index db48344..11fa1fe 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.19 2006/01/30 05:47:38 reinelt Exp $
+/* $Id: layout.c,v 1.20 2006/02/07 05:36:13 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,9 @@
*
*
* $Log: layout.c,v $
+ * Revision 1.20 2006/02/07 05:36:13 reinelt
+ * Layers added to Layout
+ *
* Revision 1.19 2006/01/30 05:47:38 reinelt
* graphic subsystem changed to full-color RGBA
*
@@ -130,7 +133,7 @@ int layout_init(const char *layout)
char *section;
char *list, *l;
char *widget;
- int row, col, num;
+ int lay, row, col, num;
info("initializing layout '%s'", layout);
@@ -159,12 +162,27 @@ int layout_init(const char *layout)
if ((p = strchr(l, '|')) != NULL)
*p = '\0';
- /* row/col widgets */
+ /* layer/row/col widgets */
+ i = sscanf(l, "layer:%d.row%d.col%d%n", &lay, &row, &col, &n);
+ if (i == 3 && l[n] == '\0') {
+ if (lay < 0 || lay >= LAYERS) {
+ error ("%s: layer %d out of bounds (0..%d)", section, lay, LAYERS-1);
+ } else {
+ widget = cfg_get(section, l, NULL);
+ if (widget != NULL && *widget != '\0') {
+ widget_add(widget, WIDGET_TYPE_RC, lay, row - 1, col - 1);
+ }
+ free(widget);
+ }
+ }
+
+ /* row/col widgets w/o layer*/
i = sscanf(l, "row%d.col%d%n", &row, &col, &n);
if (i == 2 && l[n] == '\0') {
widget = cfg_get(section, l, NULL);
if (widget != NULL && *widget != '\0') {
- widget_add(widget, WIDGET_TYPE_RC, 0, row - 1, col - 1);
+ /* default is layer 1 if outside layer section */
+ widget_add(widget, WIDGET_TYPE_RC, 1, row - 1, col - 1);
}
free(widget);
}
diff --git a/layout.h b/layout.h
index c44b5b5..0e4214a 100644
--- a/layout.h
+++ b/layout.h
@@ -1,4 +1,4 @@
-/* $Id: layout.h,v 1.3 2005/01/18 06:30:23 reinelt Exp $
+/* $Id: layout.h,v 1.4 2006/02/07 05:36:13 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,9 @@
*
*
* $Log: layout.h,v $
+ * Revision 1.4 2006/02/07 05:36:13 reinelt
+ * Layers added to Layout
+ *
* Revision 1.3 2005/01/18 06:30:23 reinelt
* added (C) to all copyright statements
*
@@ -41,6 +44,9 @@
#ifndef _LAYOUT_H_
#define _LAYOUT_H_
+/* number of layers */
+#define LAYERS 4
+
int layout_init(const char *section);
#endif
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index a921648..7e4d8c5 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -745,6 +745,7 @@ Widget Test {
class 'Text'
expression '1234567890123456789012345678901234567890'
width 40
+ foreground 'ff0000ff'
}
Widget Test1 {
@@ -832,6 +833,38 @@ Layout Default {
}
}
+Layout TestLayer {
+ Row1 {
+ Col1 'OS'
+ }
+ Row2 {
+ Col1 'CPU'
+ Col10 'RAM'
+ }
+ Row3 {
+ Col1 'Busy'
+ Col10 'Rain'
+ Col11 'BusyBar'
+ }
+ Row4 {
+ Col1 'Load'
+ Col11 'LoadBar'
+ }
+ Row5 {
+ Col1 'Disk'
+ Col11 'DiskBar'
+ }
+ Row6 {
+ Col1 'Eth0'
+ Col11 'Eth0Bar'
+ }
+ Layer 0 {
+ Row3 {
+ Col1 'Test'
+ }
+ }
+}
+
Layout L24x8 {
Row1 {
Col1 'Load'
@@ -944,15 +977,16 @@ Layout testMySQL {
#Display 'BA63'
#Display 'CT20x4'
#Display 'T6963-240x64'
-#Display 'XWindow'
+Display 'XWindow'
#Display 'USBLCD'
#Display 'BWCT'
-Display 'Image'
+#Display 'Image'
#Display 'Trefon'
#Display 'LPH7508-serdisplib'
#Display 'LPH7508'
-Layout 'Default'
+#Layout 'Default'
+Layout 'TestLayer'
#Layout 'L8x2'
#Layout 'L16x2'
#Layout 'L20x2'