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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/************************************************************************/
/* */
/* Ted: Manipulation of font and text attributes. */
/* */
/************************************************************************/
# include "tedConfig.h"
# include <stddef.h>
# include <stdlib.h>
# include <stdio.h>
# include <ctype.h>
# include "tedApp.h"
# include "tedEdit.h"
# include <appDebugon.h>
/************************************************************************/
/* */
/* Get font properties of the current position. */
/* */
/************************************************************************/
static void docGetPositionAttributes(
const BufferDocument * bd,
const TextParticule * tp,
const char ** pFamilyName,
PropertyMask * pUpdMask,
TextAttribute * pTaNew )
{
const DocumentFontList * dfl= &(bd->bdProperties.dpFontList);
DocumentFont * df;
TextAttribute ta;
utilGetTextAttributeByNumber( &ta, &(bd->bdTextAttributeList),
tp->tpTextAttributeNumber );
df= dfl->dflFonts+ ta.taFontNumber;
*pFamilyName= df->dfName;
*pTaNew= ta;
PROPmaskCLEAR( pUpdMask );
PROPmaskFILL( pUpdMask, TAprop_COUNT );
return;
}
/************************************************************************/
/* */
/* Get the common text properties of the current selection. */
/* */
/* 1) Get the last particule number for the beginning of the */
/* selection. */
/* 2) If the paragraph is part of a list, exclude the bullet from */
/* the selection. */
/* */
/************************************************************************/
void docGetSelectionAttributes( BufferDocument * bd,
const DocumentSelection * ds,
PropertyMask * pUpdMask,
TextAttribute * pTaNew )
{
const DocumentFontList * dfl= &(bd->bdProperties.dpFontList);
BufferItem * paraBi;
int part;
const TextParticule * tp;
int psFamilyNumber= -1;
const char * familyName= (const char *)0;
TextAttribute taNew;
PropertyMask updMask;
int bulletFieldNr= -1;
int bulletPartBegin= -1;
int bulletPartEnd= -1;
int bulletStroffBegin= -1;
int bulletStroffEnd= -1;
int returnBullet= 0;
paraBi= ds->dsBegin.dpBi;
/* 1 */
{
const int lastOne= 1;
if ( docFindParticuleOfPosition( &part, &(ds->dsBegin), lastOne ) )
{ LDEB(ds->dsBegin.dpStroff); }
}
/* 2 */
if ( paraBi->biParaProperties.ppListOverride > 0 )
{
if ( docDelimitParaHeadField( &bulletFieldNr,
&bulletPartBegin, &bulletPartEnd,
&bulletStroffBegin, &bulletStroffEnd, paraBi, bd ) )
{ LDEB(1); }
if ( part <= bulletPartEnd )
{
if ( ! docSelectionInsideParagraph( ds ) ||
ds->dsEnd.dpStroff > bulletStroffEnd )
{ part= bulletPartEnd+ 1; }
else{ returnBullet= 1; }
}
}
tp= paraBi->biParaParticules+ part;
docGetPositionAttributes( bd, tp, &familyName, &updMask, &taNew );
if ( docIsIBarSelection( ds ) || returnBullet )
{
*pUpdMask= updMask;
*pTaNew= taNew;
return;
}
PROPmaskCLEAR( &updMask );
for (;;)
{
int col;
col= paraBi->biParent->biNumberInParent;
if ( ds->dsCol0 < 0 ||
ds->dsCol1 < 0 ||
( col >= ds->dsCol0 && col <= ds->dsCol1 ) )
{
while( part < paraBi->biParaParticuleCount )
{
PropertyMask pm;
PropertyMask pmAll;
TextAttribute ta;
DocumentFont * df;
if ( paraBi == ds->dsEnd.dpBi &&
tp->tpStroff >= ds->dsEnd.dpStroff )
{ break; }
utilGetTextAttributeByNumber( &ta,
&(bd->bdTextAttributeList),
tp->tpTextAttributeNumber );
df= dfl->dflFonts+ ta.taFontNumber;
PROPmaskCLEAR( &pm );
PROPmaskCLEAR( &pmAll );
PROPmaskFILL( &pmAll, TAprop_COUNT );
utilAttributeDifference( &pm, &taNew, &ta, &pmAll );
utilPropMaskOr( &updMask, &updMask, &pm );
tp++; part++;
}
}
if ( paraBi == ds->dsEnd.dpBi )
{ break; }
paraBi= docNextParagraph( paraBi );
if ( ! paraBi )
{ break; }
part= 0;
tp= paraBi->biParaParticules+ part;
/* 2 */
if ( paraBi->biParaProperties.ppListOverride > 0 )
{
if ( docDelimitParaHeadField( &bulletFieldNr,
&bulletPartBegin, &bulletPartEnd,
&bulletStroffBegin, &bulletStroffEnd, paraBi, bd ) )
{ LDEB(1); }
part= bulletPartEnd+ 1;
tp= paraBi->biParaParticules+ part;
}
}
utilPropMaskNot( &updMask, &updMask );
if ( PROPmaskISSET( &updMask, TApropDOC_FONT_NUMBER ) )
{
DocumentFont * df= dfl->dflFonts+ taNew.taFontNumber;
familyName= df->dfName;
psFamilyNumber= df->dfPsFamilyNumber;
}
else{
familyName= (char *)0;
psFamilyNumber= -1;
}
*pUpdMask= updMask;
*pTaNew= taNew;
return;
}
|