Subversion Repositories Kolibri OS

Rev

Rev 6053 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6053 Rev 6058
Line 4... Line 4...
4
	strcpy(#title, history.current()+strrchr(history.current(),'/'));
4
	strcpy(#title, history.current()+strrchr(history.current(),'/'));
5
	//get font chars width, need to increase performance
5
	//get font chars width, need to increase performance
6
	get_label_symbols_size();
6
	get_label_symbols_size();
7
	ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
7
	ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
8
	if (strstri(io.buffer_data, "
8
	link.clear();
-
 
9
	if (strstri(io.buffer_data, "
9
		debugln("no  found");
10
		debugln("no  found");
10
		DrawProgress(STEP_2_COUNT_PAGE_HEIGHT);     ParceTxt(false);   //get page height to calculate buffer size
11
		DrawProgress(STEP_2_COUNT_PAGE_HEIGHT);     ParceTxt(false);   //get page height to calculate buffer size
11
		DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceTxt(true);    //draw text in buffer
12
		DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceTxt(true);    //draw text in buffer
12
	} else {
13
	} else {
13
		debugln(" tag found");
14
		debugln(" tag found");
Line 80... Line 81...
80
	bool a;
81
	bool a;
81
	bool pre;
82
	bool pre;
82
	bool ignore;
83
	bool ignore;
83
	dword color;
84
	dword color;
84
} style;
85
	void clear();
-
 
86
} style;
85
 
87
 
Line -... Line 88...
-
 
88
void _style::clear()
-
 
89
{
-
 
90
	b=u=i=s=0;
-
 
91
	h1=h2=h3=h4=h5=h6=0;
-
 
92
	a=0;
-
 
93
	pre=0;
-
 
94
	ignore=0;
-
 
95
	color=0;
-
 
96
}
-
 
97
 
86
struct _text {
98
struct _text {
87
	dword start;
99
	dword start;
88
	int x, y;
100
	int x, y;
89
};
101
};
Line 94... Line 106...
94
	dword param[10];
106
	dword param[10];
95
	dword value[10];
107
	dword value[10];
96
	void parce();
108
	void parce();
97
	int nameis();
109
	int nameis();
98
};
110
	void clear();
-
 
111
};
99
 
112
 
Line 100... Line 113...
100
void _tag::parce()
113
void _tag::parce()
101
{
114
{
102
	dword o = name = start;
115
	dword o = name = start;
Line 106... Line 119...
106
}
119
}
107
 
120
 
Line 108... Line 121...
108
int _tag::nameis(dword _in_tag_name)
121
int _tag::nameis(dword _in_tag_name)
109
{
122
{
110
	if (strcmp(_in_tag_name, name)==0) return true;
123
	if (name) && (strcmp(_in_tag_name, name)==0) return true;
111
	return false;
124
	return false;
112
}
125
}
Line -... Line 126...
-
 
126
 
-
 
127
void _tag::clear() 
-
 
128
{
-
 
129
	start=name=0;
-
 
130
}
113
 
131
 
114
#define HTML_PADDING_X 8;
132
#define HTML_PADDING_X 8;
Line 115... Line 133...
115
#define HTML_PADDING_Y 5;
133
#define HTML_PADDING_Y 5;
Line 125... Line 143...
125
_text text;
143
_text text;
126
_tag tag;
144
_tag tag;
127
dword DOM_pos;
145
dword DOM_pos;
128
 
146
 
Line -... Line 147...
-
 
147
	tag.clear();
-
 
148
	style.clear();
129
	/* Create DOM */
149
	/* Create DOM */
130
	debugln("creating DOM");
150
	debugln("creating DOM");
131
	DOM.len = strlen(io.buffer_data);
151
	DOM.len = strlen(io.buffer_data);
132
	DOM.start = malloc(DOM.len);
152
	DOM.start = malloc(DOM.len);
133
	DOM.end = DOM.start + DOM.len;
153
	DOM.end = DOM.start + DOM.len;
134
	strlcpy(DOM.start, io.buffer_data, DOM.len);
154
	strlcpy(DOM.start, io.buffer_data, DOM.len);
-
 
155
	//RemoveSpecialSymbols(DOM.start, DOM.len);
-
 
156
	//DOM.len = strlen(DOM.start);
Line 135... Line 157...
135
 
157
 
136
	/* Parce DOM */
158
	/* Parce DOM */
137
	debugln("starting DOM parce...");
159
	debugln("starting DOM parce...");
138
	text.start = DOM_pos;
160
	text.start = DOM.start;
139
	for (DOM_pos=DOM.start; DOM_pos
161
	for (DOM_pos=DOM.start; DOM_pos
140
	{
162
	{
141
		if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' ';
163
		if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' ';
142
		ch = ESBYTE[DOM_pos];
-
 
143
		//debugch(ch);
164
		ch = ESBYTE[DOM_pos];
144
		if (ch=='<') {
165
		if (ch=='<') {
145
			ESBYTE[DOM_pos] = '\0';
166
			ESBYTE[DOM_pos] = '\0';
146
			tag.start = DOM_pos + 1;
167
			tag.start = DOM_pos + 1;
147
			if (style.ignore) continue;
168
			if (style.ignore) continue;
148
			if (tag.nameis("title")) {
169
			if (tag.nameis("title")) {
149
				strcpy(#title, text.start);
170
				strcpy(#title, text.start);
150
				continue;
171
				continue;
151
			}
172
			}
152
			while (get_label_len(text.start) + stroka_x + 30 > list.w)
173
			while (get_label_len(text.start) + stroka_x + 30 > list.w)
153
			{
-
 
154
				//debugln("long line cut");
174
			{
155
				zeroch = 0;
175
				zeroch = 0;
156
				for (line_break=tag.start-1; line_break>text.start; line_break--;)
176
				for (line_break=tag.start-1; line_break>text.start; line_break--;)
157
				{
177
				{
158
					ESBYTE[line_break] >< zeroch; //set line end
178
					ESBYTE[line_break] >< zeroch; //set line end
159
					if (get_label_len(text.start) + stroka_x + 30 <= list.w) break;
179
					if (get_label_len(text.start) + stroka_x + 30 <= list.w) break;
160
					ESBYTE[line_break] >< zeroch; //restore line
180
					ESBYTE[line_break] >< zeroch; //restore line
161
				}
181
				}
-
 
182
				if (draw==true) {
-
 
183
					if (style.a) {
162
				if (draw==true) {
184
						link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," ");
-
 
185
						label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
163
					if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
186
					}
164
					WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
187
					WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
165
				}
188
				}
166
				ESBYTE[line_break] >< zeroch; //restore line
189
				ESBYTE[line_break] >< zeroch; //restore line
167
				text.start = line_break;
190
				text.start = line_break;
168
				stroka_x = HTML_PADDING_X;
191
				stroka_x = HTML_PADDING_X;
169
				stroka_y += list.item_h;
192
				stroka_y += list.item_h;
170
			}
193
			}
-
 
194
			if (draw==true) {
-
 
195
				if (style.a) {
171
			if (draw==true) {
196
					link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," ");	
-
 
197
					label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
172
				if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
198
				}
173
				WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
199
				WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
174
			}
200
			}
175
			stroka_x += get_label_len(text.start);
201
			stroka_x += get_label_len(text.start);
176
		}
202
		}