140 lines
5.6 KiB
C
140 lines
5.6 KiB
C
#ifndef SHEET_H
|
|
#define SHEET_H
|
|
|
|
#include "cell.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* must be a prime */
|
|
#define LABEL_CACHE 29
|
|
|
|
#define ASCENDING 001
|
|
|
|
typedef size_t ColWidT;
|
|
|
|
typedef struct
|
|
{
|
|
Location soff;
|
|
CoordT sortkey; /* OR-ed value of the above constants */
|
|
} Sortkey;
|
|
|
|
struct Label
|
|
{
|
|
const char *label;
|
|
Location location;
|
|
struct Label *next;
|
|
};
|
|
|
|
typedef enum { MARK_CYCLE = 0, GET_MARK_CUR = 1, GET_MARK_ALL = 2,
|
|
MARKING = 3, MARKED = 4, UNMARKED = 5 } MarkState;
|
|
|
|
typedef struct
|
|
{
|
|
struct Label *labelcache[LABEL_CACHE];
|
|
Location cur;
|
|
Location mark1, mark2;
|
|
CoordT offx, offy;
|
|
Cell **sheet;
|
|
ColWidT *column;
|
|
size_t dim[HYPER];
|
|
size_t orix, oriy;
|
|
CoordT maxx, maxy;
|
|
size_t width;
|
|
char *name;
|
|
void *display;
|
|
size_t max_colors;
|
|
void *palette;
|
|
MarkState marking;
|
|
unsigned int changed:1;
|
|
unsigned int moveonly:1;
|
|
unsigned int clk:1;
|
|
} Sheet;
|
|
|
|
#define LOC_WITHINC(s,x,y,z) ((size_t)x<(s)->dim[X] && (size_t)y<(s)->dim[Y] && (size_t)z<(s)->dim[Z])
|
|
#define LOC_WITHIN(s,l) LOCATION_LT((size_t)l,(s)->dim)
|
|
#define CELL_ATC(s,x,y,z) (*((s)->sheet + ((size_t)(z))*(s)->dim[Y]*(s)->dim[X] + ((size_t)(y))*(s)->dim[X] + (x)))
|
|
#define CELL_AT(s,l) (CELL_ATC(s,l[X],l[Y],l[Z]))
|
|
#define CELL_IS_NULLC(s,x,y,z) (CELL_ATC(s,x,y,z) == NULLCELL)
|
|
#define CELL_IS_NULL(s,l) (CELL_AT(s,l) == NULLCELL)
|
|
#define CELL_IS_GOODC(s,x,y,z) (LOC_WITHINC(s,x,y,z) && !CELL_IS_NULLC(s,x,y,z))
|
|
#define CELL_IS_GOOD(s,l) (LOC_WITHIN(s,l) && !CELL_IS_NULL(s,l))
|
|
#define ALL_COORDS_IN_SHEETC(s,x,y,z) z=0; (size_t)(z)<(s)->dim[Z]; ++z) for (y=0; (size_t)(y)<(s)->dim[Y]; ++y) for (x=0; (size_t)(x)<(s)->dim[X]; ++x
|
|
#define ALL_LOCS_IN_SHEET(s,l) ALL_COORDS_IN_SHEETC(s,l[X],l[Y],l[Z])
|
|
#define ALL_LOCS_IN_REGION(s,l) l[Z]=(s)->mark1[Z]; l[Z]<=(s)->mark2[Z]; ++(l[Z])) for (l[Y]=(s)->mark1[Y]; l[Y]<=(s)->mark2[Y]; ++(l[Y])) for (l[X]=(s)->mark1[X]; l[X]<=(s)->mark2[X]; ++(l[X])
|
|
#define ALL_CELLS_IN_SHEET(s,i,c) i=0,c=*((s)->sheet); i<(s)->dim[X]*(s)->dim[Y]*(s)->dim[Z]; ++i, c=*((s)->sheet+i)
|
|
|
|
extern Sheet *upd_sheet;
|
|
extern Location upd_l;
|
|
extern int max_eval;
|
|
|
|
void initialize_sheet(Sheet *sheet);
|
|
void resize(Sheet *sheet, CoordT x, CoordT y, CoordT z, bool *qextended);
|
|
Cell *initcellofsheet(Sheet *sheet, const Location at, bool *qnew);
|
|
void copycelltosheet(const Cell *fromcell, Sheet *sheet2,
|
|
const Location to, LabelHandling lh);
|
|
Cell *safe_cell_at(Sheet *sheet, const Location at);
|
|
Cell *safe_cell_atc(Sheet *sheet, int x, int y, int z);
|
|
Cell *curcell(Sheet *sheet);
|
|
void cachelabels(Sheet *sheet);
|
|
void freesheet(Sheet *sheet, int all);
|
|
void forceupdate(Sheet *sheet);
|
|
MarkState getmarkstate(Sheet *sheet);
|
|
void dump_current_cell(Sheet *sheet);
|
|
void freecellofsheet(Sheet *sheet, const Location at);
|
|
ColWidT columnwidth(Sheet *sheet, CoordT x, CoordT z);
|
|
bool setwidth(Sheet *sheet, CoordT x, CoordT z, ColWidT width);
|
|
ColWidT cellwidth(Sheet *sheet, const Location at);
|
|
void puttok(Sheet *sheet, const Location at, Token t, TokVariety v);
|
|
Token recompvalue(Sheet *sheet, const Location at);
|
|
Token evaluate_at(Token t, Sheet *sheet, const Location at);
|
|
void update(Sheet *sheet);
|
|
char *geterror(Sheet *sheet, const Location at);
|
|
size_t printvalue(char *s, size_t size, size_t chars, StringFormat sf,
|
|
FloatFormat ff, PrecisionLevel precision,
|
|
Sheet *sheet, const Location at);
|
|
Style getstyle(Sheet *sheet, const Location at);
|
|
bool shadowed(Sheet *sheet, const Location at);
|
|
bool transparent(Sheet *sheet, const Location at);
|
|
PrecisionLevel getprecision(Sheet *sheet, const Location at);
|
|
bool overridestyle(Sheet *sheet, const Location at, Style sty);
|
|
bool setadjust(Sheet *sheet, const Location at, Adjust adjust);
|
|
bool shadow(Sheet *sheet, const Location at, bool yep);
|
|
bool makedim(Sheet *sheet, const Location at, bool yep);
|
|
bool embolden(Sheet *sheet, const Location at, bool yep);
|
|
bool italicize(Sheet *sheet, const Location at, bool yep);
|
|
bool underline(Sheet *sheet, const Location at, bool yep);
|
|
bool setcolor(Sheet *sheet, const Location at, ColorAspect asp, ColorNum col);
|
|
bool lockcell(Sheet *sheet, const Location at, bool yep);
|
|
bool maketrans(Sheet *sheet, const Location at, bool yep);
|
|
bool igncell(Sheet *sheet, const Location at, bool yep);
|
|
void clk(Sheet *sheet, const Location at);
|
|
bool setfltformat(Sheet *sheet, const Location at, FloatFormat ff);
|
|
bool setprecision(Sheet *sheet, const Location at, PrecisionLevel precision);
|
|
void setlabel(Sheet *sheet, const Location at, const char *buf, int update);
|
|
Token findlabel(Sheet *sheet, const char *label);
|
|
void relabel(Sheet* sheet, const Location at,
|
|
const char *oldlabel, const char *newlabel);
|
|
|
|
const char *savetbl(Sheet *sheet, const char *name, int body, const Location beg, const Location end, unsigned int *count);
|
|
const char *savetext(Sheet *sheet, const char *name, const Location beg, const Location end, unsigned int *count);
|
|
const char *savecsv(Sheet *sheet, const char *name, char sep, const Location beg, const Location end, unsigned int *count);
|
|
const char *saveport(Sheet *sheet, const char *name, unsigned int *count);
|
|
const char *loadport(Sheet *sheet, const char *name);
|
|
const char *loadcsv(Sheet *sheet, const char *name);
|
|
|
|
void insertcube(Sheet *sh, const Location beg, const Location end, Dimensions dm);
|
|
void deletecube(Sheet *sh, const Location beg, const Location end, Dimensions dm);
|
|
void moveblock(Sheet *sheet, const Location beg, const Location end,
|
|
const Location dest, int copy);
|
|
const char *sortblock(Sheet *sheet, const Location beg, const Location end,
|
|
Dimensions dm, Sortkey *sk, size_t sklen);
|
|
void mirrorblock(Sheet *sh, const Location beg, const Location end, Dimensions dm);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|