diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h index 45acf8de3dc9cc0bd4dfe1abe22d7644c052c0e3..7646b0849e1a3da74a4f669d18c47ee5554018b7 100644 --- a/common/utils/T/tracer/gui/gui.h +++ b/common/utils/T/tracer/gui/gui.h @@ -27,6 +27,7 @@ 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 text_list_del(gui *gui, widget *this, int position); void gui_loop(gui *gui); diff --git a/common/utils/T/tracer/gui/text_list.c b/common/utils/T/tracer/gui/text_list.c index 89b7e8822d8d427bee2f13bf65ba9f3d75c46a0a..59de2809d79cd7cbe4682cfcb5fdddf8857f25ca 100644 --- a/common/utils/T/tracer/gui/text_list.c +++ b/common/utils/T/tracer/gui/text_list.c @@ -93,3 +93,31 @@ void text_list_add(gui *_gui, widget *_this, const char *text, int position) gunlock(g); } + +void text_list_del(gui *_gui, widget *_this, int position) +{ + struct gui *g = _gui; + struct text_list_widget *this = _this; + + glock(g); + + /* TODO: useful check? */ + if (this->text_count == 0) goto done; + + if (position < 0) position = this->text_count; + if (position > this->text_count-1) position = this->text_count-1; + + free(this->text[position]); + + memmove(this->text + position, this->text + position + 1, + (this->text_count-1 - position) * sizeof(char *)); + + this->text_count--; + this->text = realloc(this->text, this->text_count * sizeof(char *)); + if (this->text == NULL) OOM; + + send_event(g, DIRTY, this->common.id); + +done: + gunlock(g); +}