aalib.h   aalib.h 
/*
* AA-lib, an ascii-art gfx library
* Copyright (C) 1998,1999,2001 by
*
* Jan Hubicka (hubicka@freesoft.cz)
* Kamil Toman (toman@artax.karlin.mff.cuni.cz)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as publishe
d
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __AALIB_INCLUDED__ #ifndef __AALIB_INCLUDED__
#define __AALIB_INCLUDED__ #define __AALIB_INCLUDED__
#include <stdio.h> #include <stdio.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define __AA_CONST const
/* The -malign-double switch changes binarry compatibility with structures
containing floating point values. To avoid this, set alignment manually
to old value. */
#ifdef __GNUC__
#ifdef __i386__
#define __AA_ALIGN __attribute__ ((__aligned__ (4)))
#define __AA_NOALIGN __attribute__ ((__packed__))
#endif
#endif
#ifndef __AA_ALIGN
#define __AA_ALIGN
#endif
#ifndef __AA_NOALIGN
#define __AA_NOALIGN
#endif
#define AA_LIB_VERSION 1 #define AA_LIB_VERSION 1
#define AA_LIB_MINNOR 2 #define AA_LIB_MINNOR 4
#define AA_LIB_VERSIONCODE 102000 #define AA_LIB_VERSIONCODE 104000
#define AA_NATTRS 5 #define AA_NATTRS 5
#define AA_NPARAMS 5 #define AA_NPARAMS 5
#define AA_NONE 0 /*special keycodes */ #define AA_RESIZE 258 /*special keycodes */
#define AA_RESIZE 258
#define AA_MOUSE 259 #define AA_MOUSE 259
#define AA_UP 300 #define AA_UP 300
#define AA_DOWN 301 #define AA_DOWN 301
#define AA_LEFT 302 #define AA_LEFT 302
#define AA_RIGHT 303 #define AA_RIGHT 303
#define AA_BACKSPACE 304 #define AA_BACKSPACE 304
#define AA_ESC 305 #define AA_ESC 305
#define AA_UNKNOWN 400 #define AA_UNKNOWN 400
#define AA_RELEASE 65536 #define AA_RELEASE 65536
#define AA_NORMAL_MASK 1 /*masks for attributes */ #define AA_NORMAL_MASK 1 /*masks for attributes */
#define AA_DIM_MASK 2 #define AA_DIM_MASK 2
#define AA_BOLD_MASK 4 #define AA_BOLD_MASK 4
#define AA_BOLDFONT_MASK 8 #define AA_BOLDFONT_MASK 8
#define AA_REVERSE_MASK 16 #define AA_REVERSE_MASK 16
#define AA_ALL 128 #define AA_ALL 128
#define AA_EIGHT 256 #define AA_EIGHT 256
#define AA_EXTENDED (AA_ALL|AA_EIGHT) #define AA_EXTENDED (AA_ALL|AA_EIGHT)
#define AA_NORMAL 0 /*attribute numbers */ /* The characters may be output with following attributes: */
#define AA_DIM 1 enum aa_attribute {
#define AA_BOLD 2 AA_NORMAL=0, /* Normal characters. */
#define AA_BOLDFONT 3 AA_DIM=1, /* Dark characters. */
#define AA_REVERSE 4 AA_BOLD=2, /* Bright characters. */
#define AA_SPECIAL 5 AA_BOLDFONT=3, /* Characters rendered in bold font. */
AA_REVERSE=4, /* Reversed (black on whilte) characters. */
AA_SPECIAL=5 /* Render characters in a way easilly visible on the
screen. The exact rendering is driver dependent,
but this mode ought to be used to output texts you
want to make easilly visible in the image. */
};
#define AA_ERRORDISTRIB 1 /*dithering types + AA_NONE */ enum aa_dithering_mode {
#define AA_FLOYD_S 2 AA_NONE=0,
#define AA_DITHERTYPES 3 AA_ERRORDISTRIB=1, /* Error distribution. */
AA_FLOYD_S=2, /* Floyd-Steinberg dithering. */
AA_DITHERTYPES=3 /* Number of supported dithering modes. */
};
#define AA_BUTTON1 1 /*mouse */ #define AA_BUTTON1 1 /*mouse */
#define AA_BUTTON2 2 #define AA_BUTTON2 2
#define AA_BUTTON3 4 #define AA_BUTTON3 4
#define AA_MOUSEMOVEMASK 1 #define AA_MOUSEMOVEMASK 1
#define AA_MOUSEPRESSMASK 2 #define AA_MOUSEPRESSMASK 2
#define AA_PRESSEDMOVEMASK 4 #define AA_PRESSEDMOVEMASK 4
#define AA_MOUSEALLMASK 7 #define AA_MOUSEALLMASK 7
#define AA_HIDECURSOR 8 #define AA_HIDECURSOR 8
#define AA_SENDRELEASE 1 #define AA_SENDRELEASE 1
#define AA_KBDALLMASK 1 #define AA_KBDALLMASK 1
#define AA_USE_PAGES 1 /*save format flags */ #define AA_USE_PAGES 1 /*save format flags */
#define AA_NORMAL_SPACES 8 #define AA_NORMAL_SPACES 8
/* These structures are subject to change in future. Thus they are hidden
behind final user. */
struct aa_driver;
struct aa_kbddriver;
struct aa_mousedriver;
struct aa_edit;
struct aa_hardware_params { struct aa_hardware_params {
struct aa_font *font; __AA_CONST struct aa_font *font; /*Font bitmap used by hardware. */
int supported; int supported; /*Mask of supported features.
int minwidth, minheight; Following masks are available:
int maxwidth, maxheight; AA_NORMAL_MASK, AA_DIM_MASK,
int recwidth, recheight; AA_BOLD_MASK, AA_BOLDFONT_MASK,
int mmwidth, mmheight; AA_REVERSE_MASK
int width, height; */
double dimmul, boldmul; int minwidth, minheight; /*Minimal alowed screen size
in characters */
int maxwidth, maxheight; /*Maximal alowed screen size
in characters */
int recwidth, recheight; /*Recommended screen size (driver
attempts to find resolution nearest
to this value within given bounds
bit min and max fields */
int mmwidth, mmheight; /*Physical screen size */
int width, height; /*Current screen size */
double dimmul __AA_ALIGN; /*Bright value of dim characters (0 bl
ack,
1 white) */
double boldmul __AA_ALIGN; /*Bright value of bold characters
(0 black, 1 white) */
}; };
/*
* aa_context contains information about the display. It is passed to most
* of AA-lib functions. The full definition of structure is present just
* for compatibility with older programs. Dirrect access to it's fields
* is not recommended, because you might surfer to problems with future
* releases of AA-lib. Use standard AA-lib functions instead.
*/
struct aa_context { struct aa_context {
struct aa_driver *driver; __AA_CONST struct aa_driver *driver; /*Current display driver */
struct aa_kbddriver *kbddriver; __AA_CONST struct aa_kbddriver *kbddriver; /*Current keyboard driver *
struct aa_mousedriver *mousedriver; /
struct aa_hardware_params params,driverparams; __AA_CONST struct aa_mousedriver *mousedriver; /*Current mouse driver *
int mulx, muly; /
int imgwidth, imgheight; struct aa_hardware_params __AA_NOALIGN params; /*Parameters of output
unsigned char *imagebuffer; hardware used by AA-lib
unsigned char *textbuffer; . */
unsigned char *attrbuffer; struct aa_hardware_params __AA_NOALIGN driverparams; /*Parameters of ou
unsigned short *table; tput
hardware as repor
ted
by display driver
. */
int mulx, muly; /* Ratio of character size over pixel size
*/
int imgwidth, imgheight; /* Dimensions of emulated image */
unsigned char *imagebuffer; /* Virtual buffer containing image */
unsigned char *textbuffer; /* Virtual buffer containing text */
unsigned char *attrbuffer; /* Virtual buffer containing attributes */
unsigned short *table; /* Precalculated values used by rendering
algorithm.
WARNING!
It is _strongly_ depreached
to access fields behind this point, becau
se
they can change in future releases.*/
unsigned short *filltable; unsigned short *filltable;
struct parameters *parameters; struct parameters *parameters;
int cursorx, cursory, cursorstate; int cursorx, cursory, cursorstate; /* Cursor possition. */
int mousex, mousey, buttons,mousemode; int mousex, mousey, buttons,mousemode; /* Mouse state. */
void (*resizehandler) (struct aa_context *); void (*resizehandler) (struct aa_context *); /* Handler to be called wh
void *driverdata; en
resize happends. */
void *driverdata; /* Internal data used by hardware drivers.
*/
void *kbddriverdata; void *kbddriverdata;
void *mousedriverdata; void *mousedriverdata;
}; };
/*
* The hardware driver specification. Used internally by AA-lib only.
* Provided for compatibility with older programs.
*/
struct aa_driver { struct aa_driver {
char *shortname, *name; __AA_CONST char *shortname, *name;
int (*init) (struct aa_hardware_params *, void *, struct aa_hardware_pa int (*init) (__AA_CONST struct aa_hardware_params *, __AA_CONST void *,
rams *,void **); struct aa_hardware_params *,void **);
void (*uninit) (struct aa_context *); void (*uninit) (struct aa_context *);
void (*getsize) (struct aa_context *, int *, int *); void (*getsize) (struct aa_context *, int *, int *);
void (*setattr) (struct aa_context *, int); void (*setattr) (struct aa_context *, int);
void (*print) (struct aa_context *, char *); void (*print) (struct aa_context *, __AA_CONST char *);
void (*gotoxy) (struct aa_context *, int, int); void (*gotoxy) (struct aa_context *, int, int);
void (*flush) (struct aa_context *); void (*flush) (struct aa_context *);
void (*cursormode) (struct aa_context *, int); void (*cursormode) (struct aa_context *, int);
}; };
/*
* The hardware driver specification. Used internally by AA-lib only.
* Provided for compatibility with older programs.
*/
struct aa_kbddriver { struct aa_kbddriver {
char *shortname, *name; __AA_CONST char *shortname, *name;
int flags; int flags;
int (*init) (struct aa_context *, int mode); int (*init) (struct aa_context *, int mode);
void (*uninit) (struct aa_context *); void (*uninit) (struct aa_context *);
int (*getkey) (struct aa_context *, int); int (*getkey) (struct aa_context *, int);
}; };
/*
* The hardware driver specification. Used internally by AA-lib only.
* Provided for compatibility with older programs.
*/
struct aa_mousedriver { struct aa_mousedriver {
char *shortname, *name; __AA_CONST char *shortname, *name;
int flags; int flags;
int (*init) (struct aa_context *, int mode); int (*init) (struct aa_context *, int mode);
void (*uninit) (struct aa_context *); void (*uninit) (struct aa_context *);
void (*getmouse) (struct aa_context *, int *, int *, int *); void (*getmouse) (struct aa_context *, int *, int *, int *);
void (*cursormode) (struct aa_context *,int); void (*cursormode) (struct aa_context *,int);
}; };
/*
* Parameters used for rendering.
*/
struct aa_renderparams { struct aa_renderparams {
int bright, contrast; int bright; /* Brighness in range 0 (normal) to 255
float gamma; (white) */
int dither; int contrast; /* Contrast value in range 0 (normal)
int inversion; to 127 (white) */
int randomval; float gamma __AA_ALIGN; /* Gama value in the standard range */
}; enum aa_dithering_mode dither; /* Dithering algorithm */
int inversion; /* Set 1 for inversed terminals (black
struct aa_edit { on
int maxsize; white) */
char *data; int randomval; /* Range of random value added to each
int cursor; pixel. Used to crate random dithering
int clearafterpress; effect. */
int printpos;
int x, y, size;
struct aa_context *c;
};
struct parameters {
unsigned int p[AA_NPARAMS];
}; };
struct aa_font { struct aa_font {
unsigned char *data; __AA_CONST unsigned char *data; /* Bitmap of 8xheight font. */
int height; int height; /* Height of font. */
char *name; __AA_CONST char *name; /* Long name of font. */
char *shortname; __AA_CONST char *shortname; /* One-word name of the font.
*/
}; };
/*
* Output format specification used by aa_save driver.
*/
struct aa_format { struct aa_format {
int width, height; int width, height;
int pagewidth, pageheight; int pagewidth, pageheight;
int flags; int flags;
int supported; int supported;
struct aa_font *font; __AA_CONST struct aa_font *font;
char *formatname; __AA_CONST char *formatname;
char *extension; __AA_CONST char *extension;
/*fields after this line may change in future versions*/ /*fields after this line may change in future versions*/
char *head; __AA_CONST char *head;
char *end; __AA_CONST char *end;
char *newline; __AA_CONST char *newline;
char *prints[AA_NATTRS]; __AA_CONST char * __AA_CONST prints[AA_NATTRS];
char *begin[AA_NATTRS]; __AA_CONST char * __AA_CONST begin[AA_NATTRS];
char *ends[AA_NATTRS]; __AA_CONST char * __AA_CONST ends[AA_NATTRS];
char **conversions; __AA_CONST char * __AA_CONST *conversions;
}; };
/*
* Initialization data used by aa_save driver.
*/
struct aa_savedata { struct aa_savedata {
char *name; char *name; /* Base name of the output file. The page number and extens
struct aa_format *format; ion
FILE *file; /*You might specify filename by this way too, in case name is attached automatically. */
is NULL*/ __AA_CONST struct aa_format *format; /* Format to save into. */
}; FILE *file; /* You might specify output file by field too,
in case the name field is NULL*/
struct aa_linkedlist {
char *text;
struct aa_linkedlist *next, *previous;
}; };
typedef struct aa_context aa_context; typedef struct aa_context aa_context;
typedef struct aa_linkedlist aa_linkedlist; typedef struct aa_linkedlist aa_linkedlist;
typedef struct aa_linkedlist aa_reclist; typedef struct aa_linkedlist aa_reclist;
typedef struct aa_renderparams aa_renderparams; typedef struct aa_renderparams aa_renderparams;
//typedef struct aa_hardwareparams aa_hardware_params; typedef struct aa_hardware_params aa_hardwareparams;
typedef struct aa_driver aa_driver; typedef struct aa_driver aa_driver;
typedef struct aa_font aa_font; typedef struct aa_font aa_font;
typedef struct aa_format aa_format; typedef struct aa_format aa_format;
typedef struct aa_savedata aa_savedata; typedef struct aa_savedata aa_savedata;
typedef int aa_palette[256]; typedef int aa_palette[256];
extern struct aa_driver save_d, mem_d; /*
extern char *aa_help; * AA-lib driver used to save ascii-art image into file in used specified f
extern struct aa_format aa_htmlk_format, *aa_formats[]; ormat.
extern struct aa_format aa_nhtml_format, aa_html_format, aa_html_alt_format * Initialize this driver using aa_init function and specify the driver
, * dependent parameters in aa_savedata structure to save image into file.
aa_ansi_format, aa_text_format, aa_more_format, aa_hp_format, * See the texinfo documentation for details.
aa_hp2_format, aa_irc_format, aa_zephyr_format; */
extern struct aa_font *aa_fonts[]; extern __AA_CONST struct aa_driver save_d;
extern int nfonts;
extern struct aa_font aa_font8, aa_font14, aa_font16, aa_font9, aa_fontline /*
, aa_fontgl, * AA-lib memory driver.
aa_fontX13, aa_fontX16, aa_fontX13B, aa_fontcourier, aa_fontvyhen; * Used to render ascii-art images into memory.
extern char *aa_dithernames[]; * You might use this driver to render images into memory and then use your
* own routines to handle them in case you want to avoid AA-lib's output
* mechanizms.
*/
extern __AA_CONST struct aa_driver mem_d;
/*
* AA-lib help string for the default command line parser.
*/
extern __AA_CONST char * __AA_CONST aa_help;
/*
* NULL terminated array of save formats supported by AA-lib.
*/
extern __AA_CONST struct aa_format * __AA_CONST aa_formats[];
extern __AA_CONST struct aa_format aa_nhtml_format, aa_html_format,
aa_html_alt_format, aa_ansi_format, aa_text_format, aa_more_format,
aa_hp_format, aa_hp2_format, aa_irc_format, aa_zephyr_format,
aa_htmlk_format;
/*
* Null-terminated array of available fonts.
*/
extern __AA_CONST struct aa_font *aa_fonts[];
extern __AA_CONST struct aa_font aa_font8, aa_font14, aa_font16, aa_font9,
aa_fontline, aa_fontgl, aa_fontX13, aa_fontX16, aa_fontX13B,
aa_fontcourier, aa_fontvyhen;
/*
* Names of dithering methods supported by AA-lib.
* NULL terminated array containing the names of supported dithering method
s
* as ascii strings.
*/
extern __AA_CONST char * __AA_CONST aa_dithernames[];
/*
* NULL-terminated array of output drivers available in AA-lib.
*/
extern __AA_CONST struct aa_driver * __AA_CONST aa_drivers[];
extern __AA_CONST struct aa_driver curses_d, dos_d, linux_d, slang_d, stdou
t_d,
stderr_d, X11_d, os2vio_d;
/*
* NULL-terminated array of keyboard drivers available in AA_lib.
*/
extern __AA_CONST struct aa_kbddriver * __AA_CONST aa_kbddrivers[];
extern __AA_CONST struct aa_kbddriver kbd_curses_d, kbd_slang_d, kbd_stdin_
d,
kbd_dos_d, kbd_X11_d, kbd_os2_d,
kbd_linux_d;
/*
* NULL terminated array of mouse drivers supported by AA-lib.
*/
extern __AA_CONST struct aa_mousedriver * __AA_CONST aa_mousedrivers[];
extern __AA_CONST struct aa_mousedriver mouse_curses_d, mouse_gpm_d,
mouse_X11_d, mouse_dos_d, mouse_os2_
d;
/*
* List of recommended drivers.
* List of recommended drivers is used by aa_autoinit familly of functions
* and altered by aa_recommend familly of functions.
*/
extern aa_linkedlist *aa_kbdrecommended, *aa_mouserecommended, *aa_displayr
ecommended;
/*
* default hardware paramters requested by AA-lib programs. Pa
* Default hardware paramters requested by AA-lib programs. Passed to aa_in
it
* function familly.
*/
extern struct aa_hardware_params aa_defparams; extern struct aa_hardware_params aa_defparams;
/*
* default rendering parameters.
* Default rendering parameters. Passed to aa_render function familly.
*/
extern struct aa_renderparams aa_defrenderparams; extern struct aa_renderparams aa_defrenderparams;
extern struct aa_driver *aa_drivers[], curses_d, dos_d, linux_d, slang_d,
stdout_d, stderr_d, X11_d, os2vio_d;
extern struct aa_kbddriver *aa_kbddrivers[], kbd_curses_d, kbd_slang_d,
kbd_stdin_d, kbd_dos_d, kbd_X11_d, kbd_os2_d;
extern struct aa_mousedriver *aa_mousedrivers[], mouse_curses_d, mouse_gpm_
d,
mouse_X11_d, mouse_dos_d, mouse_os2_d;
extern aa_linkedlist *aa_kbdrecommended, *aa_mouserecommended, *aa_displayr
ecommended;
#define aa_callnonull(c,x) ((x)!=NULL?((x)(c)):0) /* returns width of the output screen in characters. */
#define aa_scrwidth(a) ((a)->params.width) int aa_scrwidth(
#define aa_scrheight(a) ((a)->params.height) /* Specifies the AA-lib context to operate on. */
#define aa_mmwidth(a) ((a)->params.mmwidth) aa_context *a);
#define aa_mmheight(a) ((a)->params.mmheight) /* returns height of the output screen in characters. */
#define aa_imgwidth(a) ((a)->imgwidth) int aa_scrheight(
#define aa_imgheight(a) ((a)->imgheight) /* Specifies the AA-lib context to operate on. */
#define aa_putpixel(c,x,y,color) ((c)->imagebuffer[(x)+(y)*(aa_imgwidth(c)) aa_context *a);
]=(color)) /* returns width of the output screen in millimeters. */
#define aa_image(c) ((c)->imagebuffer) int aa_mmwidth(
#define aa_text(c) ((c)->textbuffer) /* Specifies the AA-lib context to operate on. */
#define aa_attrs(c) ((c)->attrbuffer) aa_context *a);
#define aa_setpalette(palette,index,r,g,b) ((palette)[index]=(((r)*30+(g)*5 /* returns height of the output screen in millimeters. */
9+(b)*11)>>8)) int aa_mmheight(
#define aa_recommendhikbd(t) aa_recommendhi(&aa_kbdrecommended,t); /* Specifies the AA-lib context to operate on. */
#define aa_recommendhimouse(t) aa_recommendhi(&aa_mouserecommended,t); aa_context *a);
#define aa_recommendhidisplay(t) aa_recommendhi(&aa_displayrecommended,t); /* returns width of the emulated image in pixels. */
#define aa_recommendlowkbd(t) aa_recommendlow(&aa_kbdrecommended,t); int aa_imgwidth(
#define aa_recommendlowmouse(t) aa_recommendlow(&aa_mouserecommended,t); /* Specifies the AA-lib context to operate on. */
#define aa_recommendlowdisplay(t) aa_recommendlow(&aa_displayrecommended,t) aa_context *a);
; /* returns height of the emulated image in pixels. */
int aa_imgheight(
/* Specifies the AA-lib context to operate on. */
aa_context *a);
/*
* returns pointer to the framebuffer emulated by AA-lib.
* The framebuffer is simple array of characters specifying
* the brightness value (or palette index depending on the aa_render
* call). The array is organizated in the aa_imgheight (a) rows of
* aa_imgwidth(a) characters.
* Returns pointer to framebuffer emulated by AA-lib.
*/
char *aa_image(
/* Specifies the AA-lib context to operate on. */
aa_context *a);
/*
* returns pointer to the text output buffer used by AA-lib.
* The text output buffer is simple array of characters specifying
* the ascii-value of the characters.
* The array is organizated in the aa_scrheight (a) rows of
* aa_scrwidth(a) characters.
*
* Returns pointer the text output buffer used by AA-lib.
*/
char *aa_text(
/* Specifies the AA-lib context to operate on. */
aa_context *a);
/*
* returns pointer to the text output buffer used by AA-lib.
* The attribute output buffer is simple array of characters specifying
* the attributes.
* The array is organizated in the aa_scrheight (a) rows of
* aa_scrwidth(a) characters.
*
* Returns pointer the text output buffer used by AA-lib.
*/
char *aa_attrs(
/* Specifies the AA-lib context to operate on. */
aa_context *a);
/*automatical init functions */ /*
aa_context *aa_autoinit(struct aa_hardware_params *params); * returns specification of the fonts used by AA-lib rendering routines.
int aa_autoinitkbd(struct aa_context *context, int mode); */
int aa_autoinitmouse(struct aa_context *c, int mode); __AA_CONST struct aa_font *aa_currentfont(
void aa_recommendhi(aa_linkedlist ** l, char *name); /* Specifies the AA-lib context to operate on. */
void aa_recommendlow(aa_linkedlist ** l, char *name); aa_context *a);
/*
* easy to use AA-lib initialization function.
* Attempts to find available output driver supporting the specified
* parameters. First attempts to initialize the recommended drivers
* and then in order drivers available in the aa_drivers array
* (all regular output drivers compiled into AA-lib).
* Returns pointer to initialized context structure when succesfull or
* NULL on failure.
*/
aa_context *aa_autoinit(
/* Hardware parameters you want. Use aa_defparams
for default values. */
__AA_CONST struct aa_hardware_params *params);
/*
* easy to use AA-lib keyboard initialization function.
* Attempts to find available keyboard driver supporting the specified
* mode. First attempts to initialize the recommended drivers
* and then in order drivers available in the aa_kbddrivers array
* (all regular output drivers compiled into AA-lib).
*
* Every AA-lib program ought to have call to aa_parseoptions before
* first call to aa_init.
*
* Returns 1 when succesfull or 0 on failure.
*/
int aa_autoinitkbd(
/* Specifies the AA-lib context to operate on. */
struct aa_context *context,
/* Mask of extra features you request. Can contain
AA_SENDRELEASE if you are interested in release events
too. */
int mode);
/*
* easy to use AA-lib mouse initialization function.
* Attempts to find available mouse driver supporting the specified
* mode. First attempts to initialize the recommended drivers
* and then in order drivers available in the aa_kbddrivers array
* (all regular output drivers compiled into AA-lib).
* Returns 1 when succesfull or 0 on failure.
*/
int aa_autoinitmouse(
/* Specifies the AA-lib context to operate on. */
struct aa_context *c,
/* Mask of extra features you request. No such feature
s
are available in the current AA-lib version. */
int mode);
/* insert the given driver on beggining of the list of recommended drivers.
*/
void aa_recommendhi(
/* List to operate on (aa_displayrecommended,
aa_kbdrecommended or aa_mouserecommended) */
aa_linkedlist ** l,
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* Add the given driver to the end of list of recommended drivers. */
void aa_recommendlow(
/* List to operate on (aa_displayrecommended,
aa_kbdrecommended or aa_mouserecommended) */
aa_linkedlist ** l,
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
char *aa_getfirst(aa_linkedlist ** l); char *aa_getfirst(aa_linkedlist ** l);
/*init functions */ /*init functions */
aa_context *aa_init(struct aa_driver *driver, struct aa_hardware_params *de
fparams, void *driverdata); /*
int aa_initkbd(struct aa_context *context, struct aa_kbddriver *drv, int mo * open the output display for AA-lib.
de); * This is the most primitive AA-lib initialization function.
int aa_initmouse(struct aa_context *c, struct aa_mousedriver *d, int mode); * Allows better control over the process than the easier to use
* aa_autoinit function.
*
* Every AA-lib program ought to have call to aa_parseoptions before
* first call to aa_init.
*
* returns pointer to new AA-lib context or NULL if failed.
*/
aa_context *aa_init(
/* Driver you want to use. Available drivers are list
ed
in the NULL terminated aa_drivers array. */
__AA_CONST struct aa_driver *driver,
/* Hardware parameters you want. Use aa_defparams
for default values. */
__AA_CONST struct aa_hardware_params *defparams,
/* This pointer is passed dirrectly to driver used
to specify additional driver dependent parameters.
*/
__AA_CONST void *driverdata);
/*
* initialize the AA-lib keyboard driver.
* This is the most primitive AA-lib keyboard initialization function.
* Allows better control over the process than the easier to use
* aa_autoinitkbd function.
* returns 1 on success and 0 on fail.
*/
int aa_initkbd(
/* Specifies the AA-lib context to operate on. */
struct aa_context *context,
/* Driver you wish to use */
__AA_CONST struct aa_kbddriver *drv,
/* Mask of extra features you request. Can contain
AA_SENDRELEASE if you are interested in release events
too. */
int mode);
/*
* initialize the AA-lib mouse driver.
* This is the most primitive AA-lib keyboard initialization function.
* Allows better control over the process than the easier to use
* aa_autoinitmouse function.
* returns 1 on success and 0 on fail.
*/
int aa_initmouse(
/* Specifies the AA-lib context to operate on. */
struct aa_context *c,
/* Driver you wish to use. */
__AA_CONST struct aa_mousedriver *d,
/* Mask of extra features you request. No such features
are available in the current AA-lib version. */
int mode);
/*uninicializing functions */ /*uninicializing functions */
void aa_close(aa_context * c);
void aa_uninitkbd(struct aa_context *context);
void aa_uninitmouse(struct aa_context *context);
/*rendering functions */ /*
void aa_fastrender(aa_context * c, int x1, int y1, int x2, int y2); * close the AA-lib context.
void aa_render(aa_context * c, aa_renderparams * p, int x1, int y1, int x2, * Uninitialize all activated drivers and frees the memory used by context
int y2); * structures.
void aa_renderpalette(aa_context * c, aa_palette table, aa_renderparams * p */
, int x1, int y1, int x2, int y2); void aa_close(aa_context * c /* Specifies the AA-lib context to operate on.
*/
);
/*
* uninitialize the keyboard driver.
* Calls "uninitialize" function of the keyboard driver. It ought to undo
* all actions done by "initialize" function.
*/
void aa_uninitkbd(
/* Specifies the AA-lib context to operate on. */
aa_context *context);
/*
* uninitialize the mouse driver.
* Calls "uninitialize" function of the mouse driver. It ought to undo
* all actions done by "initialize" function.
*/
void aa_uninitmouse(
/* Specifies the AA-lib context to operate on. */
aa_context *context);
/* simple and fast AA-lib rendering function.
* This function does the trick of converting the emulated framebuffer
* into high quality ASCII-art. It is slightly faster and less flexible
* the aa_render function.
*
* Note that to see the effect you need to call aa_flush too.
*
* First call to this function may take a while, because the rendering
* tables are produced.
*/
void aa_fastrender(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* column of top left coner of rendered area
(in characters!) */
int x1,
/* row of top left coner of rendered area */
int y1,
/* column of bottom right coner of rendered area */
int x2,
/* row of bottom right coner of rendered area */
int y2);
/* convert image buffer to ASCII-art.
* This function does the trick of converting the emulated framebuffer
* into high quality ASCII-art. If you want to be really fast, you might
* use aa_fastrender. If you want to emulate palette, use aa_renderpalette
.
*
* Note that to see the effect you need to call aa_flush too.
*
* First call to this function may take a while, because the rendering
* tables are produced.
*/
void aa_render(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* Rendering parametters used to specify brightness, gamma
correction and other usefull stuff. Use aa_defrenderparams
for default values. */
__AA_CONST aa_renderparams * p,
/* column of top left coner of rendered area
(in characters!) */
int x1,
/* row of top left coner of rendered area */
int y1,
/* column of bottom right coner of rendered area */
int x2,
/* row of bottom right coner of rendered area */
int y2);
void aa_renderpalette(aa_context * c, __AA_CONST aa_palette table,
__AA_CONST aa_renderparams * p, int x1, int y1, int x2, int y
2);
aa_renderparams *aa_getrenderparams(void); aa_renderparams *aa_getrenderparams(void);
void aa_flush(aa_context * c); void aa_flush(aa_context * c);
/*text i/o functions */ /* output string to AA-lib output buffers.
void aa_puts(aa_context * c, int x, int y, int attr, char *s); Output given string to AA-lib output buffers. To see the effect you nee
int aa_printf(aa_context *c, int x, int y, int attr, char *fmt, ...); d to
void aa_gotoxy(aa_context * c, int x, int y); call aa_flush too. */
void aa_hidecursor(aa_context * c); void aa_puts(
void aa_showcursor(aa_context * c); /* Specifies the AA-lib context to operate on. */
void aa_getmouse(aa_context * c, int *x, int *y, int *b); aa_context * c,
/* X coordinate of the first character. */
int x,
/* Y coordinate of the first character. */
int y,
/* Attribute to use. */
enum aa_attribute attr,
/* String to output. */
__AA_CONST char *s);
/*
* print text to AA-lib output buffers.
* Print given text to AA-lib output buffers. To see the effect you need t
o
* call aa_flush too.
*/
int aa_printf(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* X coordinate of the first character. */
int x,
/* Y coordinate of the first character. */
int y,
/* Attribute to use. */
enum aa_attribute attr,
/* Text to output in standard printf format. */
__AA_CONST char *fmt, ...);
/*
* move the hardware cursor (if any) to specified position.
* Move the hardware cursor (if any) to specified position.
* To see the effect you need to call aa_flush too.
*/
void aa_gotoxy(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* X coordinate of new position. */
int x,
/* Y coordinate of the position. */
int y);
/*
* hide the hardware cursor.
* Hide the hardware cursor.
* This function may be ignored by some drivers.
*/
void aa_hidecursor(
/* Specifies the AA-lib context to operate on. */
aa_context * c);
/*
* show the hardware cursor.
* Show the hardware cursor.
* This function may not be ignored by some drivers.
*/
void aa_showcursor(
/* Specifies the AA-lib context to operate on. */
aa_context * c);
/*
* Get mouse position as specified by last mouse event read by aa_getevent.
*/
void aa_getmouse(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* Used to return X coordinate of mouse in characters. */
int *x,
/* Used to return Y coordinate of mouse in characters. */
int *y,
/* Used to return button mask of mouse.
(values used are AA_BUTTON1, AA_BUTTON2 and AA_BUTTON3)*
/
int *b);
/*
* hide the mouse cursor.
* Hide the mouse cursor.
* This function may be ignored by some drivers.
*/
void aa_hidemouse(aa_context *c); void aa_hidemouse(aa_context *c);
/*
* show the mouse cursor.
* Show the mouse cursor.
* This function may be ignored by some drivers.
*/
void aa_showmouse(aa_context *c); void aa_showmouse(aa_context *c);
/*hardware parameters control */ /*
int aa_registerfont(struct aa_font *f); * add new font specification to aa_fonts array.
void aa_setsupported(aa_context * c, int supported); * Returns 1 when succesfull or 0 on failure.
void aa_setfont(aa_context * c, struct aa_font *font); */
int aa_registerfont(
/* Font specification structure. */
__AA_CONST struct aa_font *f);
/*
* alter the "supported" field of hardware_params structure used by AA-lib
* This function can be used to alter "supported" field of hardware-params
* structure used by AA-lib.
*/
void aa_setsupported(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* New mask of requested features. Can contain
AA_EXTENDED to enable use of all 256 characters
and AA_EIGHT to enable use of the character numbered
higher than 127. */
int supported);
/* set font specification to be used by rendering functions. */
void aa_setfont(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* Font specification structure. */
__AA_CONST struct aa_font *font);
/*keyboard functions */ /*keyboard functions */
int aa_getevent(aa_context * c, int wait); /* return next event from queue.
int aa_getkey(aa_context * c, int wait); * Return next even from queue. Optionally wait for even when queue is
* empty.
* Returns next event from queue (values lower than 256 are used to report
* ascii values of pressed keys and higher values have special meanings)
* See the AA-lib texinfo documentation for more details.
* 0 is returned when queue is empty and wait is set to 0.
*/
int aa_getevent(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* 1 if you wish to wait for the even when queue is empty.
*/
int wait);
/* return next keypress event from queue.
* Returns next keypress event from queue (values lower than 256 are used
* to report ascii values of pressed keys and higher values are used to
* represent some special keys like arrows)
* See the AA-lib texinfo documentation for more details.
*/
int aa_getkey(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* 1 if you wish to wait for the even when queue is empty.
*/
int wait);
/*resize functions */ /*resize functions */
int aa_resize(aa_context * c); /*
void aa_resizehandler(aa_context * c, void (*handler) (aa_context *)); * Do resize action. This function ought to be called when application
* takes into account the AA_RESIZE event. The context is reinitialized
* and set to new sizes.
* Returns 0 when no resizing is done and 1 when resizing was succesfull.
*/
int aa_resize(
/* Specifies the AA-lib context to operate on. */
aa_context * c);
/*
* Set user handler to be called on resize event.
*/
void aa_resizehandler(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* Function to be called when resize happends. */
void (*handler) (aa_context *));
/*utility */ /*
int aa_parseoptions(struct aa_hardware_params *p, aa_renderparams * r, int * parse the standard command line options used by AA-lib.
*argc, char **argv); * Use this function to parse the standard command line options used by
void aa_edit(aa_context * c, int x, int y, int size, char *s, int maxsize); * AA-lib. Every AA-lib program ought to call this function to let user
struct aa_edit *aa_createedit(aa_context * c, int x, int y, int size, char * specify some extra parameters. The function alters the aa_hardware_para
*s, int maxsize); ms
void aa_editkey(struct aa_edit *e, int c); * and aa_renderparams structures and removes known options from the
* argc/argv lists. It also parse the AAOPTS environment variable.
* When called with NULL for the argc/argv parameters, it parses AAOPTS
* only. At least this call ought to be in every AA-lib program.
* Returns 1 when sucesfull and 0 on failure. The program then can
* print the help text available in aa_help variable.
*/
int aa_parseoptions(
/* Hardware parameters structure to alter. It is expecte
d
* that this structure only with necessary modifications
* will be later used to initialize the AA-lib context.
*/
struct aa_hardware_params *p,
/* Rendering prameters structure to alter. It is expecte
d
* that this structure only with necessary modifications
* will be later used to render images. */
aa_renderparams * r,
/* Pointer to argc parameter passed to function "main".
*/
int *argc,
/* Pointer to argv parameter passed to function "main".
*/
char **argv);
/*
* Simple interactive line editor.
* This function produces the simple interactive line editor that can
* be used by AA-lib programs to input strings.
*/
void aa_edit(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* X coordinate of the edited text. */
int x,
/* Y coordinate of the edited text. */
int y,
/* Length of the editor window. */
int size,
/* Buffer to edit (containing default value). */
char *s,
/* Size of the buffer. */
int maxsize);
/*
* Simple interactive line editor provided as helper function.
*
* You might use this function to input strings in AA-lib programs.
* This function initializes the aa_edit structure used by event-based
* editor. You might then call the aa_editkey function when key is pressed.
*
* Returns pointer to edit context when succesfull and NULL on failure.
*/
struct aa_edit *aa_createedit(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* X coordinate of the edited text. */
int x,
/* Y coordinate of the edited text. */
int y,
/* Length of the editor window. */
int size,
/* Buffer to edit (containing default value). */
char *s,
/* Size of the buffer. */
int maxsize);
/* Notify the line editor about keypress. */
void aa_editkey(
/* Editor context to use (see aa_createedit) */
struct aa_edit *e,
/* Key pressed */
int c);
/*
* put pixel to emulated framebuffer
*/
void aa_putpixel(
/* Specifies the AA-lib context to operate on. */
aa_context * c,
/* X coordinate. */
int x,
/* Y coordinate. */
int y,
/* Palette index or brightness value (0..255) */
int color);
/* insert the given driver on beggining of the list of recommended keyboard
drivers. */
void aa_recommendhikbd(
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* Add the given driver to the end of list of keyboard recommended drivers.
*/
void aa_recommendlowkbd(
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* insert the given driver on beggining of the list of recommended mouse dr
ivers. */
void aa_recommendhimouse(
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* Add the given driver to the end of list of mouse recommended drivers. *
/
void aa_recommendlowmouse(
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* insert the given driver on beggining of the list of recommended display
drivers. */
void aa_recommendhidisplay(
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* Add the given driver to the end of list of display recommended drivers.
*/
void aa_recommendlowdisplay(
/* Name of the driver (ought to match the "shortname"
field of the driver definition structure). */
__AA_CONST char *name);
/* This macro implementations are proved for faster compilation. */
#ifdef __GNUC__
/* The putpixel macro can be implemented reliably only using GNU-C extensio
n. */
#define aa_putpixel(c,x,y,color) ({aa_context *___aa_context=(c); ((___aa_
context)->imagebuffer[(x)+(y)*(aa_imgwidth(___aa_context))]=(color)); 0;})
#endif
#define aa_setpalette(palette,index,r,g,b) ((palette)[index]=(((r)*30+(g)*5
9+(b)*11)>>8))
#define aa_recommendhikbd(t) aa_recommendhi(&aa_kbdrecommended,t);
#define aa_recommendhimouse(t) aa_recommendhi(&aa_mouserecommended,t);
#define aa_recommendhidisplay(t) aa_recommendhi(&aa_displayrecommended,t);
#define aa_recommendlowkbd(t) aa_recommendlow(&aa_kbdrecommended,t);
#define aa_recommendlowmouse(t) aa_recommendlow(&aa_mouserecommended,t);
#define aa_recommendlowdisplay(t) aa_recommendlow(&aa_displayrecommended,t)
;
#define aa_scrwidth(a) ((a)->params.width)
#define aa_scrheight(a) ((a)->params.height)
#define aa_mmwidth(a) ((a)->params.mmwidth)
#define aa_mmheight(a) ((a)->params.mmheight)
#define aa_imgwidth(a) ((a)->imgwidth)
#define aa_imgheight(a) ((a)->imgheight)
#define aa_image(c) ((c)->imagebuffer)
#define aa_text(c) ((c)->textbuffer)
#define aa_attrs(c) ((c)->attrbuffer)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 41 change blocks. 
170 lines changed or deleted 867 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/