Rev 7743 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7743 | Rev 7746 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | llist list; |
20 | llist list; |
21 | _style style; |
21 | _style style; |
22 | DrawBufer DrawBuf; |
22 | DrawBufer DrawBuf; |
23 | int zoom; |
23 | int zoom; |
24 | void Prepare(); |
24 | bool opened; //is this a "start tag" or "end tag" |
- | 25 | void SetPageDefaults(); |
|
- | 26 | void Prepare(); |
|
25 | void SetStyle(); |
27 | void SetStyle(); |
26 | void DrawStyle(); |
28 | void DrawStyle(); |
27 | void DrawPage(); |
29 | void DrawPage(); |
28 | void DrawScroller(); |
30 | void DrawScroller(); |
29 | void LoadInternalPage(); |
31 | void LoadInternalPage(); |
Line 34... | Line 36... | ||
34 | 36 | ||
Line 35... | Line 37... | ||
35 | 37 | ||
36 | bool |
38 | bool |
37 | link, |
- | |
38 | ignor_text, |
39 | link, |
39 | cur_encoding, |
40 | cur_encoding, |
40 | t_html, |
41 | t_html, |
Line 41... | Line 42... | ||
41 | t_body; |
42 | t_body; |
Line 110... | Line 111... | ||
110 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
111 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
111 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
112 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
112 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
113 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
113 | if (link) { |
114 | if (link) { |
114 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]); |
115 | if (streq[0]=' ') && (line[1]==NULL) {} else { |
- | 116 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]); |
|
115 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); //TODO: set bigger underline_h for style.h |
117 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); |
116 | } |
118 | } |
- | 119 | } |
|
117 | stolbec += stolbec_len; |
120 | stolbec += stolbec_len; |
118 | } |
121 | } |
119 | } |
122 | } |
120 | //============================================================================================ |
123 | //============================================================================================ |
121 | void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){ |
124 | void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){ |
Line 123... | Line 126... | ||
123 | bufpointer = bufpos; |
126 | bufpointer = bufpos; |
124 | Prepare(); |
127 | Prepare(); |
125 | } |
128 | } |
126 | //============================================================================================ |
129 | //============================================================================================ |
127 | void TWebBrowser::Prepare(){ |
130 | void TWebBrowser::SetPageDefaults() |
128 | word bukva[2]; |
131 | { |
129 | dword j; |
- | |
130 | byte ignor_param; |
132 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = |
131 | dword bufpos; |
- | |
132 | dword line_len; |
- | |
133 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = |
- | |
134 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
133 | style.li = link = text_color_index = text_colors[0] = style.li_tab = false; |
135 | style.align = ALIGN_LEFT; |
134 | style.align = ALIGN_LEFT; |
136 | link_color_inactive = 0x0000FF; |
135 | link_color_inactive = 0x0000FF; |
137 | link_color_active = 0xFF0000; |
136 | link_color_active = 0xFF0000; |
138 | page_bg = 0xFFFFFF; |
137 | page_bg = 0xFFFFFF; |
139 | style.bg_color = page_bg; |
138 | style.bg_color = page_bg; |
140 | DrawBuf.Fill(0, page_bg); |
139 | DrawBuf.Fill(0, page_bg); |
141 | PageLinks.Clear(); |
140 | PageLinks.Clear(); |
142 | strcpy(#header, #version); |
141 | strcpy(#header, #version); |
143 | draw_y = body_magrin; |
142 | cur_encoding = CH_NULL; |
- | 143 | draw_y = body_magrin; |
|
144 | stolbec = 0; |
144 | stolbec = 0; |
145 | line = 0; |
145 | line = 0; |
146 | zoom = 1; |
146 | zoom = 1; |
147 | //for plaint text use CP866 for other UTF |
147 | } |
148 | if (strstri(bufpointer, "html")!=-1) |
- | |
149 | { |
- | |
150 | debugln(" found"); |
- | |
151 | style.pre = false; |
- | |
152 | cur_encoding = CH_NULL; |
- | |
153 | } |
- | |
154 | else |
- | |
155 | { |
- | |
156 | debugln("no "); |
- | |
157 | style.pre = true; |
- | |
158 | cur_encoding = CH_NULL; |
- | |
159 | } |
- | |
160 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
148 | //============================================================================================ |
- | 149 | void TWebBrowser::Prepare(){ |
|
- | 150 | word bukva[2]; |
|
- | 151 | dword j; |
|
- | 152 | bool ignor_param; |
|
- | 153 | dword bufpos; |
|
- | 154 | dword line_len; |
|
- | 155 | SetPageDefaults(); |
|
- | 156 | if (strstri(bufpointer, " |
|
- | 157 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
|
161 | { |
158 | { |
162 | if (ignor_text) && (ESBYTE[bufpos]!='<') continue; |
159 | bukva = ESBYTE[bufpos]; |
163 | bukva = ESBYTE[bufpos]; |
- | |
164 | switch (bukva) |
160 | switch (bukva) |
165 | { |
161 | { |
166 | case 0x0a: |
162 | case 0x0a: |
167 | if (style.pre) |
163 | if (style.pre) |
168 | { |
164 | { |
Line 199... | Line 195... | ||
199 | while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize) |
195 | while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize) |
200 | { |
196 | { |
201 | bufpos++; |
197 | bufpos++; |
202 | } |
198 | } |
203 | bufpos+=3; |
199 | bufpos+=2; |
204 | break; |
200 | break; |
205 | } |
201 | } |
206 | tag = attr = tagparam = ignor_param = NULL; |
202 | tag = attr = tagparam = ignor_param = NULL; |
207 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
203 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
208 | { |
204 | { |
209 | bukva = ESBYTE[bufpos]; |
205 | bukva = ESBYTE[bufpos]; |
Line 214... | Line 210... | ||
214 | } |
210 | } |
215 | else |
211 | else |
216 | { |
212 | { |
217 | ignor_param = true; |
213 | ignor_param = true; |
218 | if (!ignor_text) && (strlen(#tagparam)+1 |
214 | if (strlen(#tagparam)+1 |
219 | } |
215 | } |
220 | bufpos++; |
216 | bufpos++; |
221 | } |
217 | } |
222 | strlwr(#tag); |
218 | strlwr(#tag); |
223 | 219 | ||
Line -... | Line 220... | ||
- | 220 | // ignore text inside the next tags |
|
- | 221 | if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { |
|
- | 222 | for (j=10; j>0; j--) tag[j]=tag[j-1]; |
|
- | 223 | tag[0] = '/'; |
|
- | 224 | j = strstri(bufpos, #tag); |
|
- | 225 | if (j!=-1) { |
|
- | 226 | bufpos = j; |
|
- | 227 | } |
|
- | 228 | break; |
|
- | 229 | } |
|
- | 230 | ||
224 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
231 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
225 | if (tagparam) GetNextParam(); |
232 | if (tagparam) GetNextParam(); |
- | 233 | ||
- | 234 | if (tag[0] == '/') |
|
- | 235 | { |
|
- | 236 | opened = 0; |
|
- | 237 | strcpy(#tag, #tag+1); |
|
- | 238 | } |
|
- | 239 | else opened = 1; |
|
- | 240 | ||
- | 241 | if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) { |
|
226 | Perenos(); |
242 | Perenos(); |
227 | DrawStyle(); |
243 | DrawStyle(); |
228 | line = NULL; |
244 | line = NULL; |
229 | if (tag) SetStyle(); |
245 | if (tag) SetStyle(); |
- | 246 | } |
|
230 | strlcpy(#oldtag, #tag, sizeof(oldtag)); |
247 | strlcpy(#oldtag, #tag, sizeof(oldtag)); |
231 | tag = attr = tagparam = ignor_param = NULL; |
248 | tag = attr = tagparam = ignor_param = NULL; |
232 | break; |
249 | break; |
233 | default: |
250 | default: |
234 | DEFAULT_MARK: |
251 | DEFAULT_MARK: |
Line 268... | Line 285... | ||
268 | //============================================================================================ |
285 | //============================================================================================ |
269 | void TWebBrowser::SetStyle() { |
286 | void TWebBrowser::SetStyle() { |
270 | char img_path[4096]; |
287 | char img_path[4096]; |
271 | int left1 = body_magrin + list.x; |
288 | int left1 = body_magrin + list.x; |
272 | bool opened; |
289 | int meta_encoding; |
273 | int meta_encoding; |
- | |
274 | if (tag[0] == '/') |
290 | if (istag("html")) { |
275 | { |
- | |
276 | opened = 0; |
- | |
277 | strcpy(#tag, #tag+1); |
- | |
278 | } |
- | |
279 | else opened = 1; |
- | |
280 | if (istag("html")) { |
- | |
281 | t_html = opened; |
291 | t_html = opened; |
282 | return; |
292 | return; |
283 | } |
293 | } |
284 | if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; } |
294 | if(istag("title")) { |
285 | if (istag("form")) if (!opened) ignor_text = false; |
- | |
286 | if(istag("title")) { |
- | |
287 | if (opened) header=NULL; |
295 | if (opened) header=NULL; |
288 | return; |
296 | return; |
289 | } |
297 | } |
290 | if (ignor_text) return; |
298 | |
291 | - | ||
Line 292... | Line 299... | ||
292 | IF(istag("q")) |
299 | IF(istag("q")) |
293 | { |
300 | { |
294 | if (opened) strcat(#line, " \""); |
301 | if (opened) strcat(#line, " \""); |
295 | if (!opened) strcat(#line, "\" "); |
302 | if (!opened) strcat(#line, "\" "); |
Line 358... | Line 365... | ||
358 | } |
365 | } |
359 | else if (text_color_index > 0) text_color_index--; |
366 | else if (text_color_index > 0) text_color_index--; |
360 | return; |
367 | return; |
361 | } |
368 | } |
362 | if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) { |
369 | if (istag("div")) { |
- | 370 | if (streq(#oldtag,"div")) && (opened) return; |
|
- | 371 | NewLine(); |
|
- | 372 | //IF (oldtag[0] != 'h') |
|
- | 373 | return; |
|
- | 374 | } |
|
- | 375 | if (istag("header")) || (istag("article")) || (istag("footer")) || (istag("figure")) { |
|
363 | IF(oldtag[0] != 'h') NewLine(); |
376 | NewLine(); |
364 | return; |
377 | return; |
365 | } |
378 | } |
366 | if (istag("p")) { |
379 | if (istag("p")) { |
367 | IF(oldtag[0] == 'h') return; |
380 | IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return; |
368 | NewLine(); |
381 | NewLine(); |
369 | IF(opened) NewLine(); |
382 | //IF(opened) NewLine(); |
370 | return; |
383 | return; |
371 | } |
384 | } |
372 | if (istag("br")) { NewLine(); return; } |
385 | if (istag("br")) { NewLine(); return; } |
373 | if (istag("tr")) { if (opened) NewLine(); return; } |
386 | if (istag("tr")) { if (opened) NewLine(); return; } |
374 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
387 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
375 | if (istag("button")) { style.button = opened; stolbec++; return; } |
388 | if (istag("button")) { style.button = opened; stolbec++; return; } |
Line 381... | Line 394... | ||
381 | if (istag("img")) { |
394 | if (istag("img")) { |
382 | do{ |
395 | do{ |
383 | if (isattr("src=")) strcpy(#img_path, #val); |
396 | if (isattr("src=")) strcpy(#img_path, #val); |
384 | if (isattr("alt=")) sprintf(#line, "[%s]", #val); |
397 | if (isattr("alt=")) sprintf(#line, "[%s]", #val); |
385 | } while(GetNextParam()); |
398 | if (isattr("title=")) sprintf(#line, "[%s]", #val); |
- | 399 | } while(GetNextParam()); |
|
386 | style.image = true; |
400 | debugln(#val); |
- | 401 | style.image = true; |
|
387 | text_color_index++; |
402 | text_color_index++; |
388 | text_colors[text_color_index] = 0x9A6F29; |
403 | text_colors[text_color_index] = 0x9A6F29; |
389 | if (!line) { |
404 | if (!line) { |
390 | if (!strncmp(#img_path, "data:", 5)) img_path=0; |
405 | if (!strncmp(#img_path, "data:", 5)) img_path=0; |
391 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
406 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
Line 453... | Line 468... | ||
453 | if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999; |
468 | if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999; |
454 | $push edi; |
469 | $push edi; |
455 | NewLine(); |
470 | NewLine(); |
456 | $pop edi; |
471 | $pop edi; |
457 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
472 | draw_y += 10; |
- | 473 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
|
458 | NewLine(); |
474 | NewLine(); |
459 | return; |
475 | draw_y += 10; |
- | 476 | return; |
|
460 | } |
477 | } |
461 | if (istag("meta")) || (istag("?xml")) { |
478 | if (istag("meta")) || (istag("?xml")) { |
462 | meta_encoding = CH_NULL; |
479 | meta_encoding = CH_NULL; |
463 | do{ |
480 | do{ |
464 | if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding=")) |
481 | if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding=")) |
Line 475... | Line 492... | ||
475 | if (meta_encoding!=CH_NULL) BufEncode(meta_encoding); |
492 | if (meta_encoding!=CH_NULL) BufEncode(meta_encoding); |
476 | return; |
493 | return; |
477 | } |
494 | } |
478 | } |
495 | } |
479 | 496 | //============================================================================================ |
|
480 | void TWebBrowser::BufEncode(dword set_new_encoding) |
- | |
- | 497 | void TWebBrowser::BufEncode(dword set_new_encoding) |
|
481 | { |
498 | { |
482 | if (cur_encoding == set_new_encoding) return; |
499 | if (cur_encoding == set_new_encoding) return; |
483 | if (o_bufpointer==0) |
500 | if (o_bufpointer==0) |
484 | { |
501 | { |
485 | o_bufpointer = malloc(bufsize); |
502 | o_bufpointer = malloc(bufsize); |