use an eina_binbuf to store channel text (the theory is that we will
write the text to the actual grid in an idler maybe)... Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
5ccfbc70e8
commit
f1ab6b82e2
|
@ -10,6 +10,8 @@ struct _Channel
|
|||
const char *name;
|
||||
const char *server;
|
||||
|
||||
Eina_Binbuf *buff;
|
||||
|
||||
Evas *evas;
|
||||
Evas_Object *o_base;
|
||||
Evas_Object *o_bg;
|
||||
|
@ -29,6 +31,33 @@ struct _Channel
|
|||
};
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
@ -152,6 +181,8 @@ _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);
|
||||
|
||||
|
@ -218,6 +249,8 @@ _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);
|
||||
}
|
||||
|
@ -455,7 +488,36 @@ _channel_spacer_create(Channel *chl)
|
|||
void
|
||||
_channel_text_append(Channel *chl, const char *txt)
|
||||
{
|
||||
fprintf(stderr, "Channel %s Append: %s", chl->name, txt);
|
||||
int len = 0, crlf = 0, lf = 0;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue