Move grid structure to header file, add function calls to register a

grid for saving.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2014-12-03 15:42:52 -05:00
parent 287d80370e
commit f8d4573fa1
2 changed files with 106 additions and 71 deletions

View File

@ -1,77 +1,8 @@
#include "private.h"
#include "grid.h"
#include "grid_save.h"
#include "config.h"
typedef struct _Grid_Att Grid_Att;
struct _Grid_Att
{
unsigned char fg, bg;
unsigned short bold : 1;
unsigned short faint : 1;
#if defined(SUPPORT_ITALIC)
unsigned short italic : 1;
#endif
#if defined(SUPPORT_DBLWIDTH)
unsigned short dblwidth : 1;
#endif
unsigned short underline : 1;
unsigned short blink : 1;
unsigned short blink2 : 1;
unsigned short inverse : 1;
unsigned short invisible : 1;
unsigned short strike : 1;
unsigned short fg256 : 1;
unsigned short bg256 : 1;
unsigned short fgintense : 1;
unsigned short bgintense : 1;
unsigned short autowrapped : 1;
unsigned short newline : 1;
unsigned short tab : 1;
#if defined(SUPPORT_80_132_COLUMNS)
unsigned short is_80_132_mode_allowed : 1;
#endif
};
typedef struct _Grid_Cell Grid_Cell;
struct _Grid_Cell
{
int codepoint;
Grid_Att att;
};
typedef struct _Grid Grid;
struct _Grid
{
Evas_Object_Smart_Clipped_Data __clipped_data;
Evas *evas;
Evas_Object *win;
Evas_Object *o_event;
int w, h;
Grid_Cell *cells;
struct
{
int size, chw, chh;
const char *name;
} font;
struct
{
int w, h;
Evas_Object *obj;
} grid;
struct
{
Eina_Bool active : 1;
} selection;
Ecore_Timer *delayed_size_tmr;
};
/* local function prototypes */
static void _smart_size(Evas_Object *obj, int w, int h, Eina_Bool force);
@ -181,6 +112,8 @@ _smart_del(Evas_Object *obj)
{
Grid *sd;
_grid_save_unregister(obj);
/* try to get the objects smart data */
if (!(sd = evas_object_smart_data_get(obj))) return;
@ -197,6 +130,7 @@ _smart_del(Evas_Object *obj)
if (sd->font.name) eina_stringshare_del(sd->font.name);
/* free grid cells */
if (sd->cells2) free(sd->cells2);
if (sd->cells) free(sd->cells);
_parent_sc.del(obj);
@ -221,7 +155,7 @@ _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
sd->delayed_size_tmr = ecore_timer_add(0.0, _cb_delayed_size, obj);
else
ecore_timer_reset(sd->delayed_size_tmr);
// ecore_timer_delay(sd->delayed_size_tmr, 0.0);
evas_object_resize(sd->o_event, ow, oh);
}
@ -323,13 +257,20 @@ _grid_add(Evas *evas)
sd->cells = calloc(1, sizeof(Grid_Cell) * sd->w * sd->h);
if (!sd->cells) goto err;
sd->cells2 = calloc(1, sizeof(Grid_Cell) * sd->w * sd->h);
if (!sd->cells2) goto err;
_grid_update(obj);
_smart_size(obj, sd->w, sd->h, EINA_FALSE);
_grid_save_register(obj);
return obj;
err:
if (sd->cells) free(sd->cells);
if (sd->cells2) free(sd->cells2);
free(sd);
return obj;
}

View File

@ -1,6 +1,100 @@
#ifndef _GRID_H_
# define _GRID_H_ 1
typedef struct _Grid_Att Grid_Att;
struct _Grid_Att
{
unsigned char fg, bg;
unsigned short bold : 1;
unsigned short faint : 1;
#if defined(SUPPORT_ITALIC)
unsigned short italic : 1;
#endif
#if defined(SUPPORT_DBLWIDTH)
unsigned short dblwidth : 1;
#endif
unsigned short underline : 1;
unsigned short blink : 1;
unsigned short blink2 : 1;
unsigned short inverse : 1;
unsigned short invisible : 1;
unsigned short strike : 1;
unsigned short fg256 : 1;
unsigned short bg256 : 1;
unsigned short fgintense : 1;
unsigned short bgintense : 1;
unsigned short autowrapped : 1;
unsigned short newline : 1;
unsigned short tab : 1;
#if defined(SUPPORT_80_132_COLUMNS)
unsigned short is_80_132_mode_allowed : 1;
#endif
};
typedef struct _Grid_Cell Grid_Cell;
struct _Grid_Cell
{
int codepoint;
Grid_Att att;
};
typedef struct _Grid_Save Grid_Save;
struct _Grid_Save
{
unsigned int gen : 8;
unsigned int comp : 1;
unsigned int z : 1;
unsigned int w : 22;
Grid_Cell cell[1];
};
typedef struct _Grid_Save_Comp Grid_Save_Comp;
struct _Grid_Save_Comp
{
unsigned int gen : 8;
unsigned int comp : 1;
unsigned int z : 1;
unsigned int w : 22; // compressed size in bytes
unsigned int wout; // output width in Grid_Cells
};
typedef struct _Grid Grid;
struct _Grid
{
Evas_Object_Smart_Clipped_Data __clipped_data;
Evas *evas;
Evas_Object *win;
Evas_Object *o_event;
int w, h;
int backmax, backpos;
Grid_Cell *cells, *cells2;
Grid_Save **back;
struct
{
int size, chw, chh;
const char *name;
} font;
struct
{
int w, h;
Evas_Object *obj;
} grid;
struct
{
Eina_Bool active : 1;
} selection;
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);