1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/************************************************************************/
/* */
/* Ted: Interaction of the application and the current document with */
/* the color chooser etc. */
/* */
/************************************************************************/
# include "tedConfig.h"
# include <stddef.h>
# include <stdlib.h>
# include <stdio.h>
# include <ctype.h>
# include "tedApp.h"
# include <appDebugon.h>
/************************************************************************/
/* */
/* Allocate a color for the current document. */
/* */
/************************************************************************/
int tedAppAllocateDocumentColor( EditApplication * ea,
const RGB8Color * rgb8 )
{
EditDocument * ed= ea->eaCurrentDocument;
int color;
if ( ! ed )
{ XDEB(ed); return -1; }
color= tedDocAllocateDocumentColor( ed, rgb8 );
if ( color < 0 )
{ LDEB(color); return -1; }
return color;
}
/************************************************************************/
/* */
/* Allocate a color for a document. */
/* */
/************************************************************************/
int tedDocAllocateDocumentColor( EditDocument * ed,
const RGB8Color * rgb8 )
{
TedDocument * td= (TedDocument *)ed->edPrivateData;
BufferDocument * bd= td->tdDocument;
DocumentProperties * dp= &(bd->bdProperties);
const int maxColors= 256;
const int avoidZero= 1;
int color;
color= bmInsertColor( &(dp->dpColors), &(dp->dpColorCount),
avoidZero, maxColors, rgb8 );
if ( color < 0 )
{ LDEB(color); return -1; }
return color;
}
|