Commit 624aba07 authored by Cedric Roux's avatar Cedric Roux
Browse files

new function text_list_del

parent f8733535
......@@ -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);
......
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment