start on appending text to the grid (version 2) ;)
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
5b06da057e
commit
eb055ef1bf
|
@ -10,8 +10,6 @@ struct _Channel
|
|||
const char *name;
|
||||
const char *server;
|
||||
|
||||
Eina_Binbuf *buff;
|
||||
|
||||
Evas *evas;
|
||||
Evas_Object *o_base;
|
||||
Evas_Object *o_bg;
|
||||
|
@ -30,34 +28,6 @@ struct _Channel
|
|||
Eina_Bool missed : 1;
|
||||
};
|
||||
|
||||
/* local functions */
|
||||
static int
|
||||
_find_crlf(const unsigned char *data, int length, int *lf)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
*lf = 0;
|
||||
for (; i < length; i++)
|
||||
{
|
||||
/* find crlf (\r\n) */
|
||||
if ((data[i] == 0x0D) &&
|
||||
(i < (length - 1)) && (data[i + 1] == 0x0A))
|
||||
{
|
||||
*lf = 2;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* find just lf */
|
||||
if (data[i] == 0x0A)
|
||||
{
|
||||
*lf = 1;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_theme_reload(Channel *chl)
|
||||
{
|
||||
|
@ -181,8 +151,6 @@ _channel_create(Evas *evas, const char *name, const char *server)
|
|||
|
||||
chl->evas = evas;
|
||||
|
||||
chl->buff = eina_binbuf_new();
|
||||
|
||||
/* store channel name */
|
||||
if (name) chl->name = eina_stringshare_add(name);
|
||||
|
||||
|
@ -249,8 +217,6 @@ _channel_destroy(Channel *chl)
|
|||
/* delete channel server name */
|
||||
if (chl->server) eina_stringshare_del(chl->server);
|
||||
|
||||
if (chl->buff) eina_binbuf_free(chl->buff);
|
||||
|
||||
/* free allocated channel structure */
|
||||
free(chl);
|
||||
}
|
||||
|
@ -488,40 +454,15 @@ _channel_spacer_create(Channel *chl)
|
|||
void
|
||||
_channel_text_append(Channel *chl, const char *txt)
|
||||
{
|
||||
int len = 0, crlf = 0, lf = 0;
|
||||
fprintf(stderr, "Channel %s Append: %s", chl->name, txt);
|
||||
|
||||
if (!eina_binbuf_append_length(chl->buff, (void *)txt, strlen(txt))) return;
|
||||
|
||||
len = eina_binbuf_length_get(chl->buff);
|
||||
while (len > 0)
|
||||
{
|
||||
const unsigned char *str;
|
||||
|
||||
str = eina_binbuf_string_get(chl->buff);
|
||||
|
||||
crlf = _find_crlf(str, len, &lf);
|
||||
if (crlf > 0)
|
||||
{
|
||||
char buff[crlf + lf + 1];
|
||||
|
||||
memcpy(buff, str, crlf + lf);
|
||||
buff[crlf + lf] = '\0';
|
||||
|
||||
fprintf(stderr, "Channel %s Append: %s", chl->name, buff);
|
||||
|
||||
/* TODO: write buff to grid */
|
||||
|
||||
eina_binbuf_remove(chl->buff, 0, crlf + lf);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
len = eina_binbuf_length_get(chl->buff);
|
||||
}
|
||||
/* write buff to grid */
|
||||
_grid_text_append(chl->o_grid, txt, strlen(txt));
|
||||
}
|
||||
|
||||
void
|
||||
_channel_window_set(Channel *chl, Evas_Object *win)
|
||||
{
|
||||
_grid_window_set(chl->o_grid, win);
|
||||
_grid_theme_set(chl->o_grid, chl->o_bg);
|
||||
}
|
||||
|
|
902
src/bin/grid.c
902
src/bin/grid.c
File diff suppressed because it is too large
Load Diff
|
@ -109,9 +109,15 @@ struct _Grid
|
|||
Evas *evas;
|
||||
Evas_Object *win;
|
||||
Evas_Object *o_event;
|
||||
Evas_Object *o_theme;
|
||||
|
||||
int w, h;
|
||||
|
||||
int *buff;
|
||||
int bufflen;
|
||||
unsigned char oldbuff[4];
|
||||
|
||||
int scroll;
|
||||
int circular_offset, circular_offset2;
|
||||
int backmax, backpos, backscroll_num;
|
||||
|
||||
|
@ -136,13 +142,18 @@ struct _Grid
|
|||
Eina_Bool active : 1;
|
||||
} selection;
|
||||
|
||||
unsigned int altbuf : 1;
|
||||
|
||||
Ecore_Animator *anim;
|
||||
Ecore_Timer *delayed_size_tmr;
|
||||
};
|
||||
|
||||
Evas_Object *_grid_add(Evas *evas);
|
||||
void _grid_update(Evas_Object *obj);
|
||||
void _grid_window_set(Evas_Object *obj, Evas_Object *win);
|
||||
void _grid_theme_set(Evas_Object *obj, Evas_Object *theme);
|
||||
void _grid_resize(Evas_Object *obj, int nw, int nh);
|
||||
void _grid_text_append(Evas_Object *obj, const char *txt, int len);
|
||||
|
||||
#define GRID_CELLS(SD, X, Y) \
|
||||
SD->cells[X + (((Y + SD->circular_offset) % SD->h) * SD->w)]
|
||||
|
|
Loading…
Reference in New Issue