From 4f8e700d64ea934b7aded07a8241f02f6c5f28cb Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 23 Nov 2009 23:34:21 +0100 Subject: [PATCH] convert fs bars to callbacks.barval --- src/core.c | 4 ++-- src/fs.c | 14 +++++++------- src/fs.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core.c b/src/core.c index 2e382759..1b1f6fb1 100644 --- a/src/core.c +++ b/src/core.c @@ -588,10 +588,10 @@ struct text_object *construct_text_object(const char *s, const char *arg, long scan_pre_exec_arg(obj, arg); END OBJ(fs_bar, &update_fs_stats) init_fs_bar(obj, arg); - obj->callbacks.print = &print_fs_bar; + obj->callbacks.barval = &fs_barval; END OBJ(fs_bar_free, &update_fs_stats) init_fs_bar(obj, arg); - obj->callbacks.print = &print_fs_bar_free; + obj->callbacks.barval = &fs_free_barval; END OBJ(fs_free, &update_fs_stats) init_fs(obj, arg); obj->callbacks.print = &print_fs_free; diff --git a/src/fs.c b/src/fs.c index c7b42d0d..32c7b76b 100644 --- a/src/fs.c +++ b/src/fs.c @@ -211,13 +211,13 @@ void init_fs_bar(struct text_object *obj, const char *arg) obj->data.opaque = prepare_fs_stat(arg); } -static void do_print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_size) +static uint8_t do_fs_barval(struct text_object *obj, int be_free_bar) { double val = 1.0; struct fs_stat *fs = obj->data.opaque; if (!fs) - return; + return 0; if (fs->size) val = (double)fs->avail / (double)fs->size; @@ -225,17 +225,17 @@ static void do_print_fs_bar(struct text_object *obj, int be_free_bar, char *p, i if (!be_free_bar) val = 1.0 - val; - new_bar(obj, p, p_max_size, (int)(255 * val)); + return round_to_int(val * 255.0); } -void print_fs_bar(struct text_object *obj, char *p, int p_max_size) +uint8_t fs_barval(struct text_object *obj) { - do_print_fs_bar(obj, 0, p, p_max_size); + return do_fs_barval(obj, 0); } -void print_fs_bar_free(struct text_object *obj, char *p, int p_max_size) +uint8_t fs_free_barval(struct text_object *obj) { - do_print_fs_bar(obj, 1, p, p_max_size); + return do_fs_barval(obj, 1); } void init_fs(struct text_object *obj, const char *arg) diff --git a/src/fs.h b/src/fs.h index 8c1b0f8d..d6e37b4e 100644 --- a/src/fs.h +++ b/src/fs.h @@ -19,8 +19,8 @@ struct fs_stat { struct text_object; void init_fs_bar(struct text_object *, const char *); -void print_fs_bar(struct text_object *, char *, int); -void print_fs_bar_free(struct text_object *, char *, int); +uint8_t fs_barval(struct text_object *); +uint8_t fs_free_barval(struct text_object *); void init_fs(struct text_object *, const char *); void print_fs_free_perc(struct text_object *, char *, int);