File: tedFont.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (105 lines) | stat: -rw-r--r-- 2,780 bytes parent folder | download | duplicates (2)
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
/************************************************************************/
/*									*/
/*  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 or selection.		*/
/*									*/
/************************************************************************/

int tedGetDocumentAttributes(	TedDocument *		td,
				PropertyMask *		pUpdMask,
				TextAttribute *		pTaNew )
    {
    BufferDocument *		bd= td->tdDocument;

    DocumentSelection		ds;
    SelectionGeometry		sg;
    SelectionDescription	sd;

    if  ( ! tedHasSelection( td ) )
	{ return 1;	}

    if  ( tedGetSelection( &ds, &sg, &sd, td ) )
	{ LDEB(1); return 1;	}

    docGetSelectionAttributes( bd, &ds, pUpdMask, pTaNew );

    return 0;
    }

int tedGetDocumentAttributeString(	char *		scratch,
					TedDocument *	td )
    {
    int				rval= 0;

    BufferDocument *		bd= td->tdDocument;
    const DocumentProperties *	dp= &(bd->bdProperties);
    const DocumentFontList *	dfl= &(dp->dpFontList);

    PropertyMask		doneMask;
    PropertyMask		updMask;
    TextAttribute		taNew;
    ExpandedTextAttribute	etaNew;

    PROPmaskCLEAR( &doneMask );
    PROPmaskCLEAR( &updMask );
    utilInitTextAttribute( &taNew );
    docInitExpandedTextAttribute( &etaNew );

    if  ( tedGetDocumentAttributes( td, &updMask, &taNew ) )
	{ rval= -1; goto ready;	}

    docExpandTextAttribute( &doneMask, &etaNew, &taNew, &updMask,
					dfl, dp->dpColors, dp->dpColorCount );

    docExpandedAttributeToString( scratch, &updMask, dfl, &etaNew );

  ready:
    docCleanExpandedTextAttribute( &etaNew );

    return rval;
    }

/************************************************************************/
/*									*/
/*  Change the attributes of a particule.				*/
/*									*/
/************************************************************************/

int tedChangeParticuleAttributes(
				PropertyMask *			pTaAllMask,
				AppDrawingData *		add,
				ScreenFontList *		sfl,
				BufferDocument *		bd,
				BufferItem *			paraBi,
				int				partFrom,
				int				partUpto,
				const TextAttribute *		taSet,
				const PropertyMask *		taSetMask )
    {
    if  ( docChangeParticuleAttributes( pTaAllMask, bd,
						paraBi, partFrom, partUpto,
						taSet, taSetMask ) )
	{ LDEB(1); return -1;	}

    if  ( tedOpenParaScreenFonts( bd, add, sfl, paraBi, partFrom, partUpto ) )
	{ LDEB(1); return -1;	}

    return 0;
    }