mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 13:00:45 +00:00
New graph switch (-d) turning histograms into lines
Signed-off-by: Alessandro Di Marco <dmr@ethzero.com> Signed-off-by: Brenden Matthews <brenden@diddyinc.com>
This commit is contained in:
parent
ccc3dd1147
commit
f5850b713a
19
src/conky.c
19
src/conky.c
@ -3023,6 +3023,9 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
specials[special_index].first_colour);
|
specials[special_index].first_colour);
|
||||||
}
|
}
|
||||||
colour_idx = 0;
|
colour_idx = 0;
|
||||||
|
|
||||||
|
int og, g = -1; // dmr's here..
|
||||||
|
|
||||||
for (i = w - 2; i > -1; i--) {
|
for (i = w - 2; i > -1; i--) {
|
||||||
if (specials[special_index].last_colour != 0
|
if (specials[special_index].last_colour != 0
|
||||||
|| specials[special_index].first_colour != 0) {
|
|| specials[special_index].first_colour != 0) {
|
||||||
@ -3056,11 +3059,21 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
set_foreground_color(tmpcolour[colour_idx++]);
|
set_foreground_color(tmpcolour[colour_idx++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
og = g;
|
||||||
|
g = round_to_int((double)by + h - specials[special_index].graph[j] *
|
||||||
|
(h - 1) / specials[special_index].graph_scale);
|
||||||
|
|
||||||
|
if (!~og) {
|
||||||
|
og = g;
|
||||||
|
}
|
||||||
|
|
||||||
/* this is mugfugly, but it works */
|
/* this is mugfugly, but it works */
|
||||||
XDrawLine(display, window.drawable, window.gc,
|
XDrawLine(display, window.drawable, window.gc,
|
||||||
cur_x + i + 1, by + h, cur_x + i + 1,
|
cur_x + i + 1,
|
||||||
round_to_int((double)by + h - specials[special_index].graph[j] *
|
specials[special_index].dotgraph ? og : by + h,
|
||||||
(h - 1) / specials[special_index].graph_scale));
|
cur_x + i + 1,
|
||||||
|
g);
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
if (tmpcolour) free(tmpcolour);
|
if (tmpcolour) free(tmpcolour);
|
||||||
|
@ -68,7 +68,7 @@ struct graph {
|
|||||||
int width, height;
|
int width, height;
|
||||||
unsigned int first_colour, last_colour;
|
unsigned int first_colour, last_colour;
|
||||||
unsigned int scale, showaslog;
|
unsigned int scale, showaslog;
|
||||||
char tempgrad;
|
char tempgrad, dotgraph;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stippled_hr {
|
struct stippled_hr {
|
||||||
@ -161,11 +161,15 @@ char *scan_graph(struct text_object *obj, const char *args, int defscale)
|
|||||||
g->last_colour = 0;
|
g->last_colour = 0;
|
||||||
g->scale = defscale;
|
g->scale = defscale;
|
||||||
g->tempgrad = FALSE;
|
g->tempgrad = FALSE;
|
||||||
|
g->dotgraph = FALSE;
|
||||||
g->showaslog = FALSE;
|
g->showaslog = FALSE;
|
||||||
if (args) {
|
if (args) {
|
||||||
if (strstr(args, " "TEMPGRAD) || strncmp(args, TEMPGRAD, strlen(TEMPGRAD)) == 0) {
|
if (strstr(args, " "TEMPGRAD) || strncmp(args, TEMPGRAD, strlen(TEMPGRAD)) == 0) {
|
||||||
g->tempgrad = TRUE;
|
g->tempgrad = TRUE;
|
||||||
}
|
}
|
||||||
|
if (strstr(args, " "DOTGRAPH) || strncmp(args, DOTGRAPH, strlen(DOTGRAPH)) == 0) {
|
||||||
|
g->dotgraph = TRUE;
|
||||||
|
}
|
||||||
if (strstr(args, " "LOGGRAPH) || strncmp(args, LOGGRAPH, strlen(LOGGRAPH)) == 0) {
|
if (strstr(args, " "LOGGRAPH) || strncmp(args, LOGGRAPH, strlen(LOGGRAPH)) == 0) {
|
||||||
g->showaslog = TRUE;
|
g->showaslog = TRUE;
|
||||||
}
|
}
|
||||||
@ -428,6 +432,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
s->show_scale = 1;
|
s->show_scale = 1;
|
||||||
}
|
}
|
||||||
s->tempgrad = g->tempgrad;
|
s->tempgrad = g->tempgrad;
|
||||||
|
s->dotgraph = g->dotgraph;
|
||||||
#ifdef MATH
|
#ifdef MATH
|
||||||
if (g->showaslog) {
|
if (g->showaslog) {
|
||||||
s->graph_scale = log10(s->graph_scale + 1);
|
s->graph_scale = log10(s->graph_scale + 1);
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
|
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
|
||||||
#define LOGGRAPH "-l"
|
#define LOGGRAPH "-l"
|
||||||
#define TEMPGRAD "-t"
|
#define TEMPGRAD "-t"
|
||||||
|
#define DOTGRAPH "-d"
|
||||||
|
|
||||||
enum special_types {
|
enum special_types {
|
||||||
NONSPECIAL = 0,
|
NONSPECIAL = 0,
|
||||||
@ -70,7 +71,7 @@ struct special_t {
|
|||||||
unsigned long first_colour; // for graph gradient
|
unsigned long first_colour; // for graph gradient
|
||||||
unsigned long last_colour;
|
unsigned long last_colour;
|
||||||
short font_added;
|
short font_added;
|
||||||
char tempgrad;
|
char tempgrad, dotgraph;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* direct access to the registered specials (FIXME: bad encapsulation) */
|
/* direct access to the registered specials (FIXME: bad encapsulation) */
|
||||||
|
Loading…
Reference in New Issue
Block a user