* Please see COPYING for details
*
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
int default_bar_width = 0, default_bar_height = 6;
#ifdef X11
int default_graph_width = 0, default_graph_height = 25;
-int default_gauge_width = 40, default_gauge_height = 25;
#endif /* X11 */
+int default_gauge_width = 40, default_gauge_height = 25;
/*
* Special data typedefs
* Scanning arguments to various special text objects
*/
-#ifdef X11
const char *scan_gauge(struct text_object *obj, const char *args)
{
struct gauge *g;
obj->special_data = g;
return args;
}
-#endif /* X11 */
const char *scan_bar(struct text_object *obj, const char *args)
{
//TODO: check the return value and throw an error?
sscanf(args, "%1023s %d,%d", buf, &g->height, &g->width);
}
+
+ /* escape quotes at end in case of execgraph */
+ if (*buf == '"') {
+ char *_ptr;
+ size_t _size;
+ if (_ptr = strrchr(args, '"')) {
+ _size = _ptr - args - 1;
+ }
+ _size = _size < 1024 ? _size : 1023;
+ strncpy(buf, args + 1, _size);
+ buf[_size] = 0;
+ }
+
#undef g
return strndup(buf, text_buffer_size);
f = graph->graph_scale;
}
- graph->graph[0] = f; /* add new data */
/* shift all the data by 1 */
for (i = graph->graph_width - 1; i > 0; i--) {
graph->graph[i] = graph->graph[i - 1];
graph->graph_scale = graph->graph[i - 1];
}
}
- if (graph->scaled && graph->graph[graph->graph_width] > graph->graph_scale) {
+ graph->graph[0] = f; /* add new data */
+ if (graph->scaled && graph->graph[0] > graph->graph_scale) {
/* check if we need to update the scale */
- graph->graph_scale = graph->graph[graph->graph_width];
+ graph->graph_scale = graph->graph[0];
}
}
-void new_graph(struct text_object *obj, char *buf, double val)
+void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
{
struct special_t *s = 0;
struct graph *g = obj->special_data;
if ((output_methods & TO_X) == 0)
return;
- if (!g)
+ if (!g || !buf_max_size)
return;
s = new_special(buf, GRAPH);
struct special_t *s = 0;
struct bar *b = obj->special_data;
- if ((output_methods & TO_X) == 0)
- return;
-
- if (!b)
- return;
-
s = new_special(buf, BAR);
s->arg = usage;
- s->width = b->width;
- s->height = b->height;
+ s->width = b ? b->width : default_bar_width;
+ s->height = b ? b->height : default_bar_height;
}
#endif /* X11 */