diff --git a/common/utils/T/tracer/event_selector.c b/common/utils/T/tracer/event_selector.c index 2e950ac974d998dc2eddde98f02afa2273bb55c6..833939ff5d51c663b2acfab84a4887abb86c42fc 100644 --- a/common/utils/T/tracer/event_selector.c +++ b/common/utils/T/tracer/event_selector.c @@ -27,7 +27,7 @@ static void scroll(void *private, gui *g, int new_line; int inc; - text_list_state(g, w, &visible_lines, &start_line, &number_of_lines); + textlist_state(g, w, &visible_lines, &start_line, &number_of_lines); inc = 10; if (inc > visible_lines - 2) inc = visible_lines - 2; if (inc < 1) inc = 1; @@ -38,7 +38,7 @@ static void scroll(void *private, gui *g, new_line = number_of_lines - visible_lines; if (new_line < 0) new_line = 0; - text_list_set_start_line(g, w, new_line); + textlist_set_start_line(g, w, new_line); } static void click(void *private, gui *g, @@ -59,21 +59,21 @@ static void click(void *private, gui *g, if (button == 1) set_on = 1; else set_on = 0; if (w == this->events) - text_list_get_line(this->g, this->events, line, &text, &color); + textlist_get_line(this->g, this->events, line, &text, &color); else - text_list_get_line(this->g, this->groups, line, &text, &color); + textlist_get_line(this->g, this->groups, line, &text, &color); on_off(this->database, text, this->is_on, set_on); for (i = 0; i < this->nevents; i++) - text_list_set_color(this->g, this->events, i, + textlist_set_color(this->g, this->events, i, this->is_on[database_pos_to_id(this->database, i)] ? this->green : this->red); for (i = 0; i < this->ngroups; i++) - text_list_set_color(this->g, this->groups, i, FOREGROUND_COLOR); + textlist_set_color(this->g, this->groups, i, FOREGROUND_COLOR); if (w == this->groups) - text_list_set_color(this->g, this->groups, line, + textlist_set_color(this->g, this->groups, line, set_on ? this->green : this->red); t = 1; @@ -124,8 +124,8 @@ event_selector *setup_event_selector(gui *g, void *database, int socket, widget_add_child(g, left, new_label(g, "Events"), -1); widget_add_child(g, right, new_label(g, "Groups"), -1); - events = new_text_list(g, 235, 10, new_color(g, "#b3c1e1")); - groups = new_text_list(g, 235, 10, new_color(g, "#edd6cb")); + events = new_textlist(g, 235, 10, new_color(g, "#b3c1e1")); + groups = new_textlist(g, 235, 10, new_color(g, "#edd6cb")); widget_add_child(g, left, events, -1); widget_add_child(g, right, groups, -1); @@ -134,7 +134,7 @@ event_selector *setup_event_selector(gui *g, void *database, int socket, n = database_get_ids(database, &ids); for (i = 0; i < n; i++) { - text_list_add(g, events, ids[i], -1, + textlist_add(g, events, ids[i], -1, is_on[database_pos_to_id(database, i)] ? green : red); } free(ids); @@ -143,7 +143,7 @@ event_selector *setup_event_selector(gui *g, void *database, int socket, n = database_get_groups(database, &gps); for (i = 0; i < n; i++) { - text_list_add(g, groups, gps[i], -1, FOREGROUND_COLOR); + textlist_add(g, groups, gps[i], -1, FOREGROUND_COLOR); } free(gps); diff --git a/common/utils/T/tracer/gui/Makefile b/common/utils/T/tracer/gui/Makefile index cc6a409e7512db99e1f8086bfaaff71f0b241fc3..adec8fdd79a201dcd2fcf400aea1030a6ae36182 100644 --- a/common/utils/T/tracer/gui/Makefile +++ b/common/utils/T/tracer/gui/Makefile @@ -2,7 +2,7 @@ CC=gcc CFLAGS=-Wall -g -pthread OBJS=init.o loop.o toplevel_window.o x.o container.o widget.o \ - gui.o label.o event.o xy_plot.o text_list.o notify.o + gui.o label.o event.o xy_plot.o textlist.o notify.o gui.a: $(OBJS) ar cr gui.a $(OBJS) diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h index 142e34a0a809b134c6d18b71df84a8488923eda8..aa89a53c75e89dbc8d25e9c367e4c6a722bf33a6 100644 --- a/common/utils/T/tracer/gui/gui.h +++ b/common/utils/T/tracer/gui/gui.h @@ -23,7 +23,7 @@ widget *new_container(gui *gui, int vertical); widget *new_label(gui *gui, const char *text); widget *new_xy_plot(gui *gui, int width, int height, char *label, int vruler_width); -widget *new_text_list(gui *_gui, int width, int nlines, int background_color); +widget *new_textlist(gui *_gui, int width, int nlines, int background_color); void container_set_child_growable(gui *_gui, widget *_this, widget *child, int growable); @@ -33,18 +33,18 @@ void xy_plot_set_range(gui *gui, widget *this, void xy_plot_set_points(gui *gui, widget *this, int npoints, float *x, float *y); -void text_list_add(gui *gui, widget *this, const char *text, int position, +void textlist_add(gui *gui, widget *this, const char *text, int position, int color); -void text_list_del(gui *gui, widget *this, int position); -void text_list_add_silent(gui *gui, widget *this, const char *text, +void textlist_del(gui *gui, widget *this, int position); +void textlist_add_silent(gui *gui, widget *this, const char *text, int position, int color); -void text_list_del_silent(gui *gui, widget *this, int position); -void text_list_state(gui *_gui, widget *_this, +void textlist_del_silent(gui *gui, widget *this, int position); +void textlist_state(gui *_gui, widget *_this, int *visible_lines, int *start_line, int *number_of_lines); -void text_list_set_start_line(gui *gui, widget *this, int line); -void text_list_get_line(gui *gui, widget *this, int line, +void textlist_set_start_line(gui *gui, widget *this, int line); +void textlist_get_line(gui *gui, widget *this, int line, char **text, int *color); -void text_list_set_color(gui *gui, widget *this, int line, int color); +void textlist_set_color(gui *gui, widget *this, int line, int color); void gui_loop(gui *gui); @@ -55,7 +55,7 @@ int new_color(gui *gui, char *color); /* notifications */ /* known notifications: - * - text_list: + * - textlist: * - scrollup { void *: NULL } * - scrolldown { void *: NULL } * - click { int [2]: line, button } diff --git a/common/utils/T/tracer/gui/gui_defs.h b/common/utils/T/tracer/gui/gui_defs.h index fc9cd39bb35fc35e0ac5ba884943d01adcc45bd6..afc590c7be1bb7f6310d3dec5bb678bbb62e77df 100644 --- a/common/utils/T/tracer/gui/gui_defs.h +++ b/common/utils/T/tracer/gui/gui_defs.h @@ -76,7 +76,7 @@ struct container_widget { int nchildren; }; -struct text_list_widget { +struct textlist_widget { struct widget common; char **text; int *color; diff --git a/common/utils/T/tracer/gui/test.c b/common/utils/T/tracer/gui/test.c index 06e3b6309d2b81223675268ca9b92129573daf1d..f64d02347e3383eb7b039156fc07db4585df5d6a 100644 --- a/common/utils/T/tracer/gui/test.c +++ b/common/utils/T/tracer/gui/test.c @@ -31,11 +31,11 @@ int main(void) #endif tlcol = new_color(g, "#ddf"); - tl = new_text_list(g, 300, 10, tlcol); + tl = new_textlist(g, 300, 10, tlcol); widget_add_child(g, c1, tl, -1); - text_list_add(g, tl, "hello", -1); - text_list_add(g, tl, "world", -1); + textlist_add(g, tl, "hello", -1, FOREGROUND_COLOR); + textlist_add(g, tl, "world", -1, FOREGROUND_COLOR); w = new_toplevel_window(g, 500, 400, "test window"); widget_add_child(g, w, c1, 0); diff --git a/common/utils/T/tracer/gui/text_list.c b/common/utils/T/tracer/gui/textlist.c similarity index 71% rename from common/utils/T/tracer/gui/text_list.c rename to common/utils/T/tracer/gui/textlist.c index 9efdedd2a9e309136df03590408a8dc3e88d3a6d..9244b8c9bf5df02126d2c3dccbbffe2f60bc4d07 100644 --- a/common/utils/T/tracer/gui/text_list.c +++ b/common/utils/T/tracer/gui/textlist.c @@ -8,9 +8,9 @@ static void paint(gui *_gui, widget *_this) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; int i, j; - LOGD("PAINT text_list %p xywh %d %d %d %d starting line %d allocated nlines %d text_count %d\n", _this, this->common.x, this->common.y, this->common.width, this->common.height, this->starting_line, this->allocated_nlines, this->text_count); + LOGD("PAINT textlist %p xywh %d %d %d %d starting line %d allocated nlines %d text_count %d\n", _this, this->common.x, this->common.y, this->common.width, this->common.height, this->starting_line, this->allocated_nlines, this->text_count); x_fill_rectangle(g->x, g->xwin, this->background_color, this->common.x, this->common.y, this->common.width, this->common.height); @@ -26,29 +26,29 @@ static void paint(gui *_gui, widget *_this) static void hints(gui *_gui, widget *_w, int *width, int *height) { - struct text_list_widget *w = _w; + struct textlist_widget *w = _w; *width = w->wanted_width; *height = w->wanted_nlines * w->line_height; - LOGD("HINTS text_list wh %d %d\n", *width, *height); + LOGD("HINTS textlist wh %d %d\n", *width, *height); } static void allocate( gui *gui, widget *_this, int x, int y, int width, int height) { - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; this->common.x = x; this->common.y = y; this->common.width = width; this->common.height = height; this->allocated_nlines = height / this->line_height; - LOGD("ALLOCATE text_list %p xywh %d %d %d %d nlines %d\n", this, x, y, width, height, this->allocated_nlines); + LOGD("ALLOCATE textlist %p xywh %d %d %d %d nlines %d\n", this, x, y, width, height, this->allocated_nlines); } static void button(gui *_g, widget *_this, int x, int y, int button, int up) { struct gui *g = _g; - struct text_list_widget *this = _this; - LOGD("BUTTON text_list %p xy %d %d button %d up %d\n", _this, x, y, button, up); + struct textlist_widget *this = _this; + LOGD("BUTTON textlist %p xy %d %d button %d up %d\n", _this, x, y, button, up); /* scroll up */ if (button == 4 && up == 0) { gui_notify(g, "scrollup", _this, NULL); @@ -65,15 +65,15 @@ static void button(gui *_g, widget *_this, int x, int y, int button, int up) } } -widget *new_text_list(gui *_gui, int width, int nlines, int bgcol) +widget *new_textlist(gui *_gui, int width, int nlines, int bgcol) { struct gui *g = _gui; - struct text_list_widget *w; + struct textlist_widget *w; int dummy; glock(g); - w = new_widget(g, TEXT_LIST, sizeof(struct text_list_widget)); + w = new_widget(g, TEXT_LIST, sizeof(struct textlist_widget)); w->wanted_nlines = nlines; x_text_get_dimensions(g->x, ".", &dummy, &w->line_height, &w->baseline); @@ -95,11 +95,11 @@ widget *new_text_list(gui *_gui, int width, int nlines, int bgcol) /* public functions */ /*************************************************************************/ -static void _text_list_add(gui *_gui, widget *_this, const char *text, +static void _textlist_add(gui *_gui, widget *_this, const char *text, int position, int color, int silent) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; glock(g); @@ -125,10 +125,10 @@ static void _text_list_add(gui *_gui, widget *_this, const char *text, gunlock(g); } -static void _text_list_del(gui *_gui, widget *_this, int position, int silent) +static void _textlist_del(gui *_gui, widget *_this, int position, int silent) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; glock(g); @@ -157,33 +157,33 @@ done: gunlock(g); } -void text_list_add(gui *gui, widget *this, const char *text, int position, +void textlist_add(gui *gui, widget *this, const char *text, int position, int color) { - _text_list_add(gui, this, text, position, color, 0); + _textlist_add(gui, this, text, position, color, 0); } -void text_list_del(gui *gui, widget *this, int position) +void textlist_del(gui *gui, widget *this, int position) { - _text_list_del(gui, this, position, 0); + _textlist_del(gui, this, position, 0); } -void text_list_add_silent(gui *gui, widget *this, const char *text, +void textlist_add_silent(gui *gui, widget *this, const char *text, int position, int color) { - _text_list_add(gui, this, text, position, color, 1); + _textlist_add(gui, this, text, position, color, 1); } -void text_list_del_silent(gui *gui, widget *this, int position) +void textlist_del_silent(gui *gui, widget *this, int position) { - _text_list_del(gui, this, position, 1); + _textlist_del(gui, this, position, 1); } -void text_list_state(gui *_gui, widget *_this, +void textlist_state(gui *_gui, widget *_this, int *visible_lines, int *start_line, int *number_of_lines) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; glock(g); @@ -194,10 +194,10 @@ void text_list_state(gui *_gui, widget *_this, gunlock(g); } -void text_list_set_start_line(gui *_gui, widget *_this, int line) +void textlist_set_start_line(gui *_gui, widget *_this, int line) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; glock(g); @@ -208,11 +208,11 @@ void text_list_set_start_line(gui *_gui, widget *_this, int line) gunlock(g); } -void text_list_get_line(gui *_gui, widget *_this, int line, +void textlist_get_line(gui *_gui, widget *_this, int line, char **text, int *color) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; glock(g); @@ -227,10 +227,10 @@ void text_list_get_line(gui *_gui, widget *_this, int line, gunlock(g); } -void text_list_set_color(gui *_gui, widget *_this, int line, int color) +void textlist_set_color(gui *_gui, widget *_this, int line, int color) { struct gui *g = _gui; - struct text_list_widget *this = _this; + struct textlist_widget *this = _this; glock(g); diff --git a/common/utils/T/tracer/remote.c b/common/utils/T/tracer/remote.c index 9b06673e8e988928f24fd165e2d828eaa65901ab..2ef9e5bc28c518cc63ab1c23f17a56e632fe9be7 100644 --- a/common/utils/T/tracer/remote.c +++ b/common/utils/T/tracer/remote.c @@ -169,14 +169,14 @@ int main(int n, char **v) if (gui_mode) { widget *w, *win; -// w = new_text_list(g, 600, 20, 0); - w = new_text_list(g, 800, 50, BACKGROUND_COLOR); +// w = new_textlist(g, 600, 20, 0); + w = new_textlist(g, 800, 50, BACKGROUND_COLOR); win = new_toplevel_window(g, 800, 50*12, "textlog"); widget_add_child(g, win, w, -1); - out = new_textlist(1000, 10, g, w); - //tout = new_textlist(7, 4, g, w); + out = new_view_textlist(1000, 10, g, w); + //tout = new_view_textlist(7, 4, g, w); } else { - out = new_stdout(); + out = new_view_stdout(); } for (i = 0; i < number_of_events; i++) { diff --git a/common/utils/T/tracer/view/stdout.c b/common/utils/T/tracer/view/stdout.c index 695704e4221d4a4667f9dae9e036c49c01824d01..93223e59d81d2591a9a317f75c84cd7f57b32d33 100644 --- a/common/utils/T/tracer/view/stdout.c +++ b/common/utils/T/tracer/view/stdout.c @@ -21,7 +21,7 @@ static void append(view *_this, char *s) if (pthread_mutex_unlock(&this->lock)) abort(); } -view *new_stdout(void) +view *new_view_stdout(void) { struct stdout *ret = calloc(1, sizeof(struct stdout)); if (ret == NULL) abort(); diff --git a/common/utils/T/tracer/view/textlist.c b/common/utils/T/tracer/view/textlist.c index 6aec4848d3ad2a0a9132c9351cf50dddae953de2..5227900e4ef36d241b8fd62c2233d0d7ba9a2620 100644 --- a/common/utils/T/tracer/view/textlist.c +++ b/common/utils/T/tracer/view/textlist.c @@ -20,11 +20,11 @@ struct textlist { static void _append(struct textlist *this, char *s, int *deleted) { if (this->cursize == this->maxsize) { - text_list_del_silent(this->g, this->w, 0); + textlist_del_silent(this->g, this->w, 0); this->cursize--; (*deleted)++; } - text_list_add_silent(this->g, this->w, s, -1, FOREGROUND_COLOR); + textlist_add_silent(this->g, this->w, s, -1, FOREGROUND_COLOR); this->cursize++; } @@ -46,15 +46,15 @@ static void *textlist_thread(void *_this) free(s); } if (dirty) { - text_list_state(this->g, this->w, &visible_lines, &start_line, + textlist_state(this->g, this->w, &visible_lines, &start_line, &number_of_lines); if (this->autoscroll) start_line = number_of_lines - visible_lines; else start_line -= deleted; if (start_line < 0) start_line = 0; - text_list_set_start_line(this->g, this->w, start_line); - /* this call is not necessary, but if things change in text_list... */ + textlist_set_start_line(this->g, this->w, start_line); + /* this call is not necessary, but if things change in textlist... */ widget_dirty(this->g, this->w); } if (pthread_mutex_unlock(&this->lock)) abort(); @@ -92,7 +92,7 @@ static void scroll(void *private, gui *g, if (pthread_mutex_lock(&this->lock)) abort(); - text_list_state(g, w, &visible_lines, &start_line, &number_of_lines); + textlist_state(g, w, &visible_lines, &start_line, &number_of_lines); inc = 10; if (inc > visible_lines - 2) inc = visible_lines - 2; if (inc < 1) inc = 1; @@ -103,7 +103,7 @@ static void scroll(void *private, gui *g, new_line = number_of_lines - visible_lines; if (new_line < 0) new_line = 0; - text_list_set_start_line(g, w, new_line); + textlist_set_start_line(g, w, new_line); if (new_line + visible_lines < number_of_lines) this->autoscroll = 0; @@ -127,7 +127,7 @@ static void click(void *private, gui *g, if (pthread_mutex_unlock(&this->lock)) abort(); } -view *new_textlist(int maxsize, float refresh_rate, gui *g, widget *w) +view *new_view_textlist(int maxsize, float refresh_rate, gui *g, widget *w) { struct textlist *ret = calloc(1, sizeof(struct textlist)); if (ret == NULL) abort(); diff --git a/common/utils/T/tracer/view/view.h b/common/utils/T/tracer/view/view.h index 9929e6e5d4324d562553bb791ebf209d7e94e7db..a5855b109809c4e1c0e7cac0e6750e06543af7b5 100644 --- a/common/utils/T/tracer/view/view.h +++ b/common/utils/T/tracer/view/view.h @@ -10,7 +10,7 @@ typedef struct view { void (*append)(struct view *this, ...); } view; -view *new_stdout(void); -view *new_textlist(int maxsize, float refresh_rate, gui *g, widget *w); +view *new_view_stdout(void); +view *new_view_textlist(int maxsize, float refresh_rate, gui *g, widget *w); #endif /* _VIEW_H_ */