Subversion Repositories Kolibri OS

Rev

Rev 6377 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6216 leency 1
struct _tag {
2
	dword start;
3
	dword name;
4
	dword param[10];
5
	dword value[10];
6
	void parce();
7
	int nameis();
8
	void clear();
9
};
10
 
11
void _tag::parce()
12
{
13
	dword o = name = start;
14
	while (ESBYTE[o]!=' ') && (ESBYTE[o]) o++; //searching for a space after tag name
15
	ESBYTE[o] = '\0';
16
	strlwr(name);
17
}
18
 
19
int _tag::nameis(dword _in_tag_name)
20
{
21
	if (name) && (strcmp(_in_tag_name, name)==0) return true;
22
	return false;
23
}
24
 
25
void _tag::clear()
26
{
27
	start=name=0;
28
}
29
 
30
 
31
/*
32
unsigned int GetNextParam()
33
{
34
	byte	kavichki=0;
35
	int		i = strlen(#tagparam) - 1;
36
 
37
	if (!tagparam) return 0;
38
 
39
	WHILE((i > 0) && ((tagparam[i] == '"') || (tagparam[i] == ' ') || (tagparam[i] == '\'') || (tagparam[i] == '/')))
40
	{
41
		IF (tagparam[i] == '"') || (tagparam[i] == '\'') kavichki=tagparam[i];
42
		tagparam[i] = 0x00;
43
		i--;
44
	}
45
 
46
	if (kavichki)
47
	{
48
		i=strrchr(#tagparam, kavichki);
49
		strlcpy(#val, #tagparam + i, sizeof(val));
50
	}
51
	else
52
	{
53
		WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1;
54
		i++;
55
		strlcpy(#val, #tagparam + i, sizeof(val));
56
 
57
		WHILE (val[0] == ' ') strcpy(#val, #val+1);
58
	}
59
	tagparam[i] = 0x00;
60
 
61
	FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
62
	{
63
		IF (tagparam[i] == '=') //äåðçêàÿ çàãëóøêà
64
			tagparam[i + 1] = 0x00;
65
	}
66
	strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
67
	tagparam[i] = 0x00;
68
	strlwr(#attr);
69
	return 1;
70
}
71
*/
72
 
73
//
74
//   STYLE
75
//
76
 
77
struct _style {
78
	bool b, u, i, s;
79
	bool h1, h2, h3, h4, h5, h6;
80
	bool a;
81
	bool pre;
82
	bool ignore;
83
	dword color;
84
	void clear();
85
} style;
86
 
87
void _style::clear()
88
{
89
	b=u=i=s=0;
90
	h1=h2=h3=h4=h5=h6=0;
91
	a=0;
92
	pre=0;
93
	ignore=0;
94
	color=0;
95
}
96
 
97
 
98
//
99
//   TEXT
100
//
101
 
102
struct _text {
103
	dword start;
6375 guillem 104
	char str[7];
6216 leency 105
	int x, y;
6378 guillem 106
	void fixSpecial(dword text);
6375 guillem 107
};
108
 
109
 
110
// unicode conversion for special characters
111
char *unicode_tags[]={
112
"nbsp",  " ",
113
"#38",   " ",
114
"#160",  " ",
115
 
6378 guillem 116
"ntilde", "n", // spanish n special ñ
117
"#224",   "à", // spanish a with grove accent 'à'
118
"#241",  "n", // spanish symbol
6375 guillem 119
 
120
"copy",  "(c)",
121
"#169",  "(c)",
122
 
123
"trade", "[TM]",
124
 
125
"reg",   "(r)",
126
"#174",  "(r)",
127
 
128
"bdquo", ",,",
129
 
130
"amp",   "&",
131
"#38",   "&",
132
 
133
"lt",    "<",
134
"#60",   "<",
135
 
136
"gt",    ">",
137
"#62",   ">",
138
 
139
"minus", "-",
140
"ndash", "-",
141
"mdash", "-", //--
142
"#8722", "-",
143
"#8211", "-",
144
"#151",  "-",
145
"#149",  "-",
146
 
147
"rsquo", "'",
148
"#39",   "'",
149
"#96",   "'",
150
"#8217", "'",
151
 
152
"quot",  "\"",
153
"#34",   "\"",
154
"ldquo", "\"",
155
"rdquo", "\"",
156
"#8222", "\"",
157
"#8221", "\"",
158
 
159
"laquo", "<<",
160
"#171",  "<<",
161
"raquo", ">>",
162
"#187",  ">>",
163
 
164
"uarr",  "\24",
165
"darr",  "\25",
166
"rarr",  "\26",
167
"larr",  "\27",
168
 
169
"#1028", "\242",
170
"#1030", "I",
171
"#1031", "\244",
172
 
173
"#8470", "N",
174
"bull",  "-", //âîîáùå çäåñü òî÷êà
175
"percnt","%",
176
 
6378 guillem 177
0};
6375 guillem 178
 
6378 guillem 179
// function to be called to fix the special symbols
180
void _text::fixSpecial(dword text) {
181
	//dword text = start;
182
	byte ch;
183
	int i , j, z;
184
	dword aux;
185
	dword text2 = text;
186
	loop () {
187
		ch = ESBYTE[text];
188
		if (!ch) return;
189
		if (ch=='&') {
190
			i = 0;
191
			j = 0;
192
			text++;
193
			while ( i < 7)  {
194
				ch = ESBYTE[text];
195
				if (ch == ';') {
196
					z = get_symbol(#str);
197
					//debugval("z: ", z);
198
					aux = unicode_tags[z];
199
					strtrim(aux);
200
					debugln(aux);
201
					ch = ESBYTE[aux];
202
					while (ch) {
203
						ESBYTE[text2] = ch;
204
						aux++;
205
						text2++;
206
						ch = ESBYTE[aux];
207
					}
208
					ch = ESBYTE[text2];
209
					//debugval("i: ", i);
210
					while (ch != ';') {
211
						//debugval("j: ", j);
212
						ESBYTE[text2] = ' ';
213
						text2++;
214
						ch = ESBYTE[text2];
215
					}
216
					ESBYTE[text2] = ' ';
217
					//for (j=0;j
218
					//debugln(#str);
219
					//clean_str();
220
					break;
221
				}
222
				str[i] = ch;
223
				if (!ch) return;
224
				text++;
225
				i++;
226
			}
227
			for (i=0; i < 7; i++) str[i] = 0;
228
		}
229
		text++;
230
		text2++;
231
	}
232
}
233
 
234
 
235
 
6375 guillem 236
// function to look for the conversion od special characters
237
// if not found--> return 0
6378 guillem 238
int get_symbol(char *str2) {
239
	int i,j;
240
	//debugln(#str2);
6377 guillem 241
	for (i=0; unicode_tags[i]!=0; i+=2) {
6378 guillem 242
		if (strcmp(str2, unicode_tags[i]) == 0) {
243
			//j = strlen(unicode_tags[i+1]);
6375 guillem 244
			//debugval("i: ", i);
6378 guillem 245
			//strcat(text2, unicode_tags[i+1]);
246
			i++;
247
			return i;
6375 guillem 248
		}
249
	}
6378 guillem 250
	return ' ';
6375 guillem 251
}
252
 
253
 
254