gui "text_list" becomes "textlist"
view "textlist" becomes "view_textlist" (this one may change at some point)
This commit is contained in:
@@ -27,7 +27,7 @@ static void scroll(void *private, gui *g,
|
|||||||
int new_line;
|
int new_line;
|
||||||
int inc;
|
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;
|
inc = 10;
|
||||||
if (inc > visible_lines - 2) inc = visible_lines - 2;
|
if (inc > visible_lines - 2) inc = visible_lines - 2;
|
||||||
if (inc < 1) inc = 1;
|
if (inc < 1) inc = 1;
|
||||||
@@ -38,7 +38,7 @@ static void scroll(void *private, gui *g,
|
|||||||
new_line = number_of_lines - visible_lines;
|
new_line = number_of_lines - visible_lines;
|
||||||
if (new_line < 0) new_line = 0;
|
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,
|
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 (button == 1) set_on = 1; else set_on = 0;
|
||||||
|
|
||||||
if (w == this->events)
|
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
|
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);
|
on_off(this->database, text, this->is_on, set_on);
|
||||||
|
|
||||||
for (i = 0; i < this->nevents; i++)
|
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->is_on[database_pos_to_id(this->database, i)] ?
|
||||||
this->green : this->red);
|
this->green : this->red);
|
||||||
|
|
||||||
for (i = 0; i < this->ngroups; i++)
|
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)
|
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);
|
set_on ? this->green : this->red);
|
||||||
|
|
||||||
t = 1;
|
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, left, new_label(g, "Events"), -1);
|
||||||
widget_add_child(g, right, new_label(g, "Groups"), -1);
|
widget_add_child(g, right, new_label(g, "Groups"), -1);
|
||||||
|
|
||||||
events = new_text_list(g, 235, 10, new_color(g, "#b3c1e1"));
|
events = new_textlist(g, 235, 10, new_color(g, "#b3c1e1"));
|
||||||
groups = new_text_list(g, 235, 10, new_color(g, "#edd6cb"));
|
groups = new_textlist(g, 235, 10, new_color(g, "#edd6cb"));
|
||||||
|
|
||||||
widget_add_child(g, left, events, -1);
|
widget_add_child(g, left, events, -1);
|
||||||
widget_add_child(g, right, groups, -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);
|
n = database_get_ids(database, &ids);
|
||||||
for (i = 0; i < n; i++) {
|
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);
|
is_on[database_pos_to_id(database, i)] ? green : red);
|
||||||
}
|
}
|
||||||
free(ids);
|
free(ids);
|
||||||
@@ -143,7 +143,7 @@ event_selector *setup_event_selector(gui *g, void *database, int socket,
|
|||||||
|
|
||||||
n = database_get_groups(database, &gps);
|
n = database_get_groups(database, &gps);
|
||||||
for (i = 0; i < n; i++) {
|
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);
|
free(gps);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ CC=gcc
|
|||||||
CFLAGS=-Wall -g -pthread
|
CFLAGS=-Wall -g -pthread
|
||||||
|
|
||||||
OBJS=init.o loop.o toplevel_window.o x.o container.o widget.o \
|
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)
|
gui.a: $(OBJS)
|
||||||
ar cr gui.a $(OBJS)
|
ar cr gui.a $(OBJS)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ widget *new_container(gui *gui, int vertical);
|
|||||||
widget *new_label(gui *gui, const char *text);
|
widget *new_label(gui *gui, const char *text);
|
||||||
widget *new_xy_plot(gui *gui, int width, int height, char *label,
|
widget *new_xy_plot(gui *gui, int width, int height, char *label,
|
||||||
int vruler_width);
|
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,
|
void container_set_child_growable(gui *_gui, widget *_this,
|
||||||
widget *child, int growable);
|
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,
|
void xy_plot_set_points(gui *gui, widget *this,
|
||||||
int npoints, float *x, float *y);
|
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);
|
int color);
|
||||||
void text_list_del(gui *gui, widget *this, int position);
|
void textlist_del(gui *gui, widget *this, int position);
|
||||||
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);
|
int position, int color);
|
||||||
void text_list_del_silent(gui *gui, widget *this, int position);
|
void textlist_del_silent(gui *gui, widget *this, int position);
|
||||||
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);
|
int *visible_lines, int *start_line, int *number_of_lines);
|
||||||
void text_list_set_start_line(gui *gui, widget *this, int line);
|
void textlist_set_start_line(gui *gui, widget *this, int line);
|
||||||
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);
|
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);
|
void gui_loop(gui *gui);
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ int new_color(gui *gui, char *color);
|
|||||||
|
|
||||||
/* notifications */
|
/* notifications */
|
||||||
/* known notifications:
|
/* known notifications:
|
||||||
* - text_list:
|
* - textlist:
|
||||||
* - scrollup { void *: NULL }
|
* - scrollup { void *: NULL }
|
||||||
* - scrolldown { void *: NULL }
|
* - scrolldown { void *: NULL }
|
||||||
* - click { int [2]: line, button }
|
* - click { int [2]: line, button }
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ struct container_widget {
|
|||||||
int nchildren;
|
int nchildren;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct text_list_widget {
|
struct textlist_widget {
|
||||||
struct widget common;
|
struct widget common;
|
||||||
char **text;
|
char **text;
|
||||||
int *color;
|
int *color;
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
tlcol = new_color(g, "#ddf");
|
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);
|
widget_add_child(g, c1, tl, -1);
|
||||||
|
|
||||||
text_list_add(g, tl, "hello", -1);
|
textlist_add(g, tl, "hello", -1, FOREGROUND_COLOR);
|
||||||
text_list_add(g, tl, "world", -1);
|
textlist_add(g, tl, "world", -1, FOREGROUND_COLOR);
|
||||||
|
|
||||||
w = new_toplevel_window(g, 500, 400, "test window");
|
w = new_toplevel_window(g, 500, 400, "test window");
|
||||||
widget_add_child(g, w, c1, 0);
|
widget_add_child(g, w, c1, 0);
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
static void paint(gui *_gui, widget *_this)
|
static void paint(gui *_gui, widget *_this)
|
||||||
{
|
{
|
||||||
struct gui *g = _gui;
|
struct gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
int i, j;
|
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,
|
x_fill_rectangle(g->x, g->xwin, this->background_color,
|
||||||
this->common.x, this->common.y,
|
this->common.x, this->common.y,
|
||||||
this->common.width, this->common.height);
|
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)
|
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;
|
*width = w->wanted_width;
|
||||||
*height = w->wanted_nlines * w->line_height;
|
*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(
|
static void allocate(
|
||||||
gui *gui, widget *_this, int x, int y, int width, int height)
|
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.x = x;
|
||||||
this->common.y = y;
|
this->common.y = y;
|
||||||
this->common.width = width;
|
this->common.width = width;
|
||||||
this->common.height = height;
|
this->common.height = height;
|
||||||
this->allocated_nlines = height / this->line_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)
|
static void button(gui *_g, widget *_this, int x, int y, int button, int up)
|
||||||
{
|
{
|
||||||
struct gui *g = _g;
|
struct gui *g = _g;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
LOGD("BUTTON text_list %p xy %d %d button %d up %d\n", _this, x, y, button, up);
|
LOGD("BUTTON textlist %p xy %d %d button %d up %d\n", _this, x, y, button, up);
|
||||||
/* scroll up */
|
/* scroll up */
|
||||||
if (button == 4 && up == 0) {
|
if (button == 4 && up == 0) {
|
||||||
gui_notify(g, "scrollup", _this, NULL);
|
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 gui *g = _gui;
|
||||||
struct text_list_widget *w;
|
struct textlist_widget *w;
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
glock(g);
|
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;
|
w->wanted_nlines = nlines;
|
||||||
x_text_get_dimensions(g->x, ".", &dummy, &w->line_height, &w->baseline);
|
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 */
|
/* 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)
|
int position, int color, int silent)
|
||||||
{
|
{
|
||||||
struct gui *g = _gui;
|
struct gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
|
|
||||||
glock(g);
|
glock(g);
|
||||||
|
|
||||||
@@ -125,10 +125,10 @@ static void _text_list_add(gui *_gui, widget *_this, const char *text,
|
|||||||
gunlock(g);
|
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 gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
|
|
||||||
glock(g);
|
glock(g);
|
||||||
|
|
||||||
@@ -157,33 +157,33 @@ done:
|
|||||||
gunlock(g);
|
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)
|
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)
|
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)
|
int *visible_lines, int *start_line, int *number_of_lines)
|
||||||
{
|
{
|
||||||
struct gui *g = _gui;
|
struct gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
|
|
||||||
glock(g);
|
glock(g);
|
||||||
|
|
||||||
@@ -194,10 +194,10 @@ void text_list_state(gui *_gui, widget *_this,
|
|||||||
gunlock(g);
|
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 gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
|
|
||||||
glock(g);
|
glock(g);
|
||||||
|
|
||||||
@@ -208,11 +208,11 @@ void text_list_set_start_line(gui *_gui, widget *_this, int line)
|
|||||||
gunlock(g);
|
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)
|
char **text, int *color)
|
||||||
{
|
{
|
||||||
struct gui *g = _gui;
|
struct gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
|
|
||||||
glock(g);
|
glock(g);
|
||||||
|
|
||||||
@@ -227,10 +227,10 @@ void text_list_get_line(gui *_gui, widget *_this, int line,
|
|||||||
gunlock(g);
|
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 gui *g = _gui;
|
||||||
struct text_list_widget *this = _this;
|
struct textlist_widget *this = _this;
|
||||||
|
|
||||||
glock(g);
|
glock(g);
|
||||||
|
|
||||||
@@ -169,14 +169,14 @@ int main(int n, char **v)
|
|||||||
|
|
||||||
if (gui_mode) {
|
if (gui_mode) {
|
||||||
widget *w, *win;
|
widget *w, *win;
|
||||||
// w = new_text_list(g, 600, 20, 0);
|
// w = new_textlist(g, 600, 20, 0);
|
||||||
w = new_text_list(g, 800, 50, BACKGROUND_COLOR);
|
w = new_textlist(g, 800, 50, BACKGROUND_COLOR);
|
||||||
win = new_toplevel_window(g, 800, 50*12, "textlog");
|
win = new_toplevel_window(g, 800, 50*12, "textlog");
|
||||||
widget_add_child(g, win, w, -1);
|
widget_add_child(g, win, w, -1);
|
||||||
out = new_textlist(1000, 10, g, w);
|
out = new_view_textlist(1000, 10, g, w);
|
||||||
//tout = new_textlist(7, 4, g, w);
|
//tout = new_view_textlist(7, 4, g, w);
|
||||||
} else {
|
} else {
|
||||||
out = new_stdout();
|
out = new_view_stdout();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < number_of_events; i++) {
|
for (i = 0; i < number_of_events; i++) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ static void append(view *_this, char *s)
|
|||||||
if (pthread_mutex_unlock(&this->lock)) abort();
|
if (pthread_mutex_unlock(&this->lock)) abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
view *new_stdout(void)
|
view *new_view_stdout(void)
|
||||||
{
|
{
|
||||||
struct stdout *ret = calloc(1, sizeof(struct stdout));
|
struct stdout *ret = calloc(1, sizeof(struct stdout));
|
||||||
if (ret == NULL) abort();
|
if (ret == NULL) abort();
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ struct textlist {
|
|||||||
static void _append(struct textlist *this, char *s, int *deleted)
|
static void _append(struct textlist *this, char *s, int *deleted)
|
||||||
{
|
{
|
||||||
if (this->cursize == this->maxsize) {
|
if (this->cursize == this->maxsize) {
|
||||||
text_list_del_silent(this->g, this->w, 0);
|
textlist_del_silent(this->g, this->w, 0);
|
||||||
this->cursize--;
|
this->cursize--;
|
||||||
(*deleted)++;
|
(*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++;
|
this->cursize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,15 +46,15 @@ static void *textlist_thread(void *_this)
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
if (dirty) {
|
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);
|
&number_of_lines);
|
||||||
if (this->autoscroll)
|
if (this->autoscroll)
|
||||||
start_line = number_of_lines - visible_lines;
|
start_line = number_of_lines - visible_lines;
|
||||||
else
|
else
|
||||||
start_line -= deleted;
|
start_line -= deleted;
|
||||||
if (start_line < 0) start_line = 0;
|
if (start_line < 0) start_line = 0;
|
||||||
text_list_set_start_line(this->g, this->w, start_line);
|
textlist_set_start_line(this->g, this->w, start_line);
|
||||||
/* this call is not necessary, but if things change in text_list... */
|
/* this call is not necessary, but if things change in textlist... */
|
||||||
widget_dirty(this->g, this->w);
|
widget_dirty(this->g, this->w);
|
||||||
}
|
}
|
||||||
if (pthread_mutex_unlock(&this->lock)) abort();
|
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();
|
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;
|
inc = 10;
|
||||||
if (inc > visible_lines - 2) inc = visible_lines - 2;
|
if (inc > visible_lines - 2) inc = visible_lines - 2;
|
||||||
if (inc < 1) inc = 1;
|
if (inc < 1) inc = 1;
|
||||||
@@ -103,7 +103,7 @@ static void scroll(void *private, gui *g,
|
|||||||
new_line = number_of_lines - visible_lines;
|
new_line = number_of_lines - visible_lines;
|
||||||
if (new_line < 0) new_line = 0;
|
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)
|
if (new_line + visible_lines < number_of_lines)
|
||||||
this->autoscroll = 0;
|
this->autoscroll = 0;
|
||||||
@@ -127,7 +127,7 @@ static void click(void *private, gui *g,
|
|||||||
if (pthread_mutex_unlock(&this->lock)) abort();
|
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));
|
struct textlist *ret = calloc(1, sizeof(struct textlist));
|
||||||
if (ret == NULL) abort();
|
if (ret == NULL) abort();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ typedef struct view {
|
|||||||
void (*append)(struct view *this, ...);
|
void (*append)(struct view *this, ...);
|
||||||
} view;
|
} view;
|
||||||
|
|
||||||
view *new_stdout(void);
|
view *new_view_stdout(void);
|
||||||
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);
|
||||||
|
|
||||||
#endif /* _VIEW_H_ */
|
#endif /* _VIEW_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user