2013-05-03 19:44:20 -07:00
|
|
|
#include "private.h"
|
|
|
|
#include <Elementary.h>
|
|
|
|
#include "termpty.h"
|
2019-11-23 09:31:23 -08:00
|
|
|
#include "backlog.h"
|
2013-05-05 07:10:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
static int ts_comp = 0;
|
2013-05-03 19:44:20 -07:00
|
|
|
static int ts_uncomp = 0;
|
2013-05-05 07:10:44 -07:00
|
|
|
static int ts_freeops = 0;
|
2013-05-03 19:44:20 -07:00
|
|
|
static Eina_List *ptys = NULL;
|
|
|
|
|
|
|
|
void
|
|
|
|
termpty_save_register(Termpty *ty)
|
|
|
|
{
|
2015-08-01 09:37:35 -07:00
|
|
|
termpty_backlog_lock();
|
2013-05-03 19:44:20 -07:00
|
|
|
ptys = eina_list_append(ptys, ty);
|
2015-08-01 09:37:35 -07:00
|
|
|
termpty_backlog_unlock();
|
2013-05-03 19:44:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termpty_save_unregister(Termpty *ty)
|
|
|
|
{
|
2015-08-01 09:37:35 -07:00
|
|
|
termpty_backlog_lock();
|
2013-05-03 19:44:20 -07:00
|
|
|
ptys = eina_list_remove(ptys, ty);
|
2015-08-01 09:37:35 -07:00
|
|
|
termpty_backlog_unlock();
|
2013-05-03 19:44:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Termsave *
|
|
|
|
termpty_save_extract(Termsave *ts)
|
|
|
|
{
|
|
|
|
if (!ts) return NULL;
|
|
|
|
return ts;
|
|
|
|
}
|
|
|
|
|
|
|
|
Termsave *
|
2018-10-13 10:15:57 -07:00
|
|
|
termpty_save_new(Termpty *ty, Termsave *ts, int w)
|
2013-05-03 19:44:20 -07:00
|
|
|
{
|
2018-10-13 10:15:57 -07:00
|
|
|
termpty_save_free(ty, ts);
|
2015-04-06 09:08:23 -07:00
|
|
|
|
|
|
|
Termcell *cells = calloc(1, w * sizeof(Termcell));
|
|
|
|
if (!cells ) return NULL;
|
|
|
|
ts->cells = cells;
|
2013-05-03 19:44:20 -07:00
|
|
|
ts->w = w;
|
|
|
|
return ts;
|
|
|
|
}
|
|
|
|
|
2015-04-06 09:08:23 -07:00
|
|
|
Termsave *
|
2018-10-13 10:15:57 -07:00
|
|
|
termpty_save_expand(Termpty *ty, Termsave *ts, Termcell *cells, size_t delta)
|
2015-04-06 09:08:23 -07:00
|
|
|
{
|
|
|
|
Termcell *newcells;
|
|
|
|
|
|
|
|
newcells = realloc(ts->cells, (ts->w + delta) * sizeof(Termcell));
|
|
|
|
if (!newcells)
|
|
|
|
return NULL;
|
2017-08-26 09:51:22 -07:00
|
|
|
|
2018-10-13 10:15:57 -07:00
|
|
|
memset(newcells + ts->w,
|
|
|
|
0, delta * sizeof(Termcell));
|
|
|
|
TERMPTY_CELL_COPY(ty, cells, &newcells[ts->w], (int)delta);
|
|
|
|
|
2015-04-06 09:08:23 -07:00
|
|
|
ts->w += delta;
|
|
|
|
ts->cells = newcells;
|
|
|
|
return ts;
|
|
|
|
}
|
|
|
|
|
2013-05-03 19:44:20 -07:00
|
|
|
void
|
2018-10-13 10:15:57 -07:00
|
|
|
termpty_save_free(Termpty *ty, Termsave *ts)
|
2013-05-03 19:44:20 -07:00
|
|
|
{
|
2018-10-13 10:15:57 -07:00
|
|
|
unsigned int i;
|
2013-05-03 19:44:20 -07:00
|
|
|
if (!ts) return;
|
2018-09-12 22:40:39 -07:00
|
|
|
if (ts->comp) ts_comp--;
|
|
|
|
else ts_uncomp--;
|
|
|
|
ts_freeops++;
|
2018-10-13 10:15:57 -07:00
|
|
|
for (i = 0; i < ts->w; i++)
|
|
|
|
{
|
|
|
|
if (EINA_UNLIKELY(ts->cells[i].att.link_id))
|
|
|
|
term_link_refcount_dec(ty, ts->cells[i].att.link_id, 1);
|
|
|
|
}
|
|
|
|
free(ts->cells);
|
2015-04-06 09:08:23 -07:00
|
|
|
ts->cells = NULL;
|
|
|
|
ts->w = 0;
|
2013-05-03 19:44:20 -07:00
|
|
|
}
|
2015-08-01 09:37:35 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
termpty_backlog_lock(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termpty_backlog_unlock(void)
|
|
|
|
{
|
|
|
|
}
|