File: tedEditList.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 (170 lines) | stat: -rw-r--r-- 4,353 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
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
/************************************************************************/
/*									*/
/*  List related editing and formatting changes.			*/
/*									*/
/************************************************************************/

#   include	"tedConfig.h"

#   include	<stddef.h>
#   include	<stdlib.h>
#   include	<stdio.h>
#   include	<ctype.h>

#   include	"docLayout.h"
#   include	"tedEdit.h"

#   include	<appDebugon.h>

/************************************************************************/
/*									*/
/*  Change the properties of the list where the selection starts.	*/
/*									*/
/************************************************************************/

static int tedDocChangeCurrentList(	EditDocument *		ed,
					const DocumentList *	dlNew )
    {
    TedDocument *			td= (TedDocument *)ed->edPrivateData;
    BufferDocument *			bd= td->tdDocument;

    DocumentSelection			ds;
    SelectionGeometry			sg;
    SelectionDescription		sd;

    EditOperation			eo;
    const int				fullWidth= 1;

    ListOverride *			lo;
    DocumentList *			dl;
    ListNumberTreeNode *		root;

    tedStartEditOperation( &eo, &ds, &sg, &sd, ed, fullWidth );

    if  ( ! sd.sdHasLists	||
	  sd.sdListOverride < 1	)
	{ LLDEB(sd.sdHasLists,sd.sdListOverride); return -1; }

    if  ( docGetListOfParagraph( &lo, &root, &dl, sd.sdListOverride, bd ) )
	{ LDEB(1); return -1;	}

    if  ( docCopyDocumentList( dl, dlNew, (int *)0, (int *)0 ) )
	{ LDEB(1); return -1;	}

    if  ( docApplyListRuler( root, dl, lo, bd ) )
	{ LDEB(1);	}

    eo.eoFieldUpdate |= FIELDdoLISTTEXT;

    tedEditRefreshLayout( &eo, ed );

    if  ( tedEditFinishOldSelection( ed, &eo ) )
	{ LDEB(1);	}

    tedAdaptToolsToSelection( ed );

    appDocumentChanged( ed, 1 );

    return 0;
    }

/************************************************************************/
/*									*/
/*  Ted: The 'Set' button on the list font tool was pushed.		*/
/*									*/
/************************************************************************/

void tedListFontToolSet(	void *				voidea,
				const ExpandedTextAttribute *	etaSet,
				const PropertyMask *		taSetMask )
    {
    EditApplication *		ea= (EditApplication *)voidea;
    EditDocument *		ed= ea->eaCurrentDocument;
    TedDocument *		td;
    BufferDocument *		bd;
    DocumentProperties *	dp;
    DocumentFontList *		dfl;

    EditOperation		eo;
    const int			fullWidth= 1;

    ListOverride *		lo;
    DocumentList *		dl;
    ListNumberTreeNode *	root;

    DocumentListLevel *		dll;

    PropertyMask		doneMask;
    PropertyMask		explicitMask;
    TextAttribute		taSet;

    DocumentSelection		ds;
    SelectionGeometry		sg;
    SelectionDescription	sd;

    if  ( ! ed )
	{ XDEB(ed); return;	}

    td= (TedDocument *)ed->edPrivateData;
    bd= td->tdDocument;
    dp= &(bd->bdProperties);
    dfl= &(dp->dpFontList);

    tedStartEditOperation( &eo, &ds, &sg, &sd, ed, fullWidth );

    if  ( ! sd.sdHasLists	||
	  sd.sdListOverride < 1	||
	  sd.sdMultiList	||
	  sd.sdMultiLevel	)
	{ LLDEB(sd.sdHasLists,sd.sdListOverride); return; }

    if  ( docGetListOfParagraph( &lo, &root, &dl, sd.sdListOverride, bd ) )
	{ LDEB(1); return;	}

    utilInitTextAttribute( &taSet );
    PROPmaskCLEAR( &doneMask );

    docIndirectTextAttribute( &doneMask, &taSet, etaSet, taSetMask,
				    &(dp->dpColors), &(dp->dpColorCount) );

    dll= &(dl->dlLevels[sd.sdListLevel]);

    utilPropMaskNot( &explicitMask, &(dll->dllTextAttributeMask) );
    utilPropMaskAnd( &explicitMask, taSetMask, taSetMask );

    PROPmaskCLEAR( &doneMask );
    utilUpdateTextAttribute( &doneMask, &(dll->dllTextAttribute),
							&taSet, taSetMask );
    utilPropMaskOr( &(dll->dllTextAttributeMask),
				    &(dll->dllTextAttributeMask), taSetMask );

    utilPropMaskOr( &doneMask, &doneMask, &explicitMask );

    if  ( utilPropMaskIsEmpty( &doneMask ) )
	{ return;	}

    eo.eoFieldUpdate |= FIELDdoLISTTEXT;

    tedEditRefreshLayout( &eo, ed );

    if  ( tedEditFinishOldSelection( ed, &eo ) )
	{ LDEB(1);	}

    tedAdaptToolsToSelection( ed );

    appDocumentChanged( ed, 1 );

    return;
    }

int tedAppChangeCurrentList(	EditApplication *		ea,
				const DocumentList *		dlNew )
    {
    EditDocument *		ed= ea->eaCurrentDocument;

    if  ( ! ed )
	{ XDEB(ed); return -1;	}

    return tedDocChangeCurrentList( ed, dlNew );
    }