Rev 4562 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4562 | Rev 4636 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "..\TWB\links.h" |
1 | #include "..\TWB\links.h" |
Line 2... | Line -... | ||
2 | - | ||
3 | 2 | ||
- | 3 | dword bufpointer; |
|
4 | dword bufpointer; |
4 | dword o_bufpointer; |
Line 5... | Line 5... | ||
5 | dword bufsize; |
5 | dword bufsize; |
Line 6... | Line 6... | ||
6 | 6 | ||
Line 14... | Line 14... | ||
14 | 14 | ||
15 | struct TWebBrowser { |
15 | struct TWebBrowser { |
16 | llist list; |
16 | llist list; |
17 | DrawBufer DrawBuf; |
17 | DrawBufer DrawBuf; |
18 | void GetNewUrl(); |
18 | void GetNewUrl(); |
19 | void ReadHtml(); |
19 | void Prepare(); |
20 | void Parse(); |
20 | void Parse(); |
21 | void WhatTextStyle(); |
21 | void WhatTextStyle(); |
22 | void DrawPage(); |
22 | void DrawPage(); |
23 | void DrawScroller(); |
23 | void DrawScroller(); |
Line 28... | Line 28... | ||
28 | 28 | ||
29 | byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, |
29 | byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, |
30 | link, ignor_text, cur_encoding, text_align; |
30 | link, ignor_text, cur_encoding, text_align; |
Line 31... | Line 31... | ||
31 | byte condition_text_active, condition_text_val, condition_href, condition_max; |
31 | byte condition_text_active, condition_text_val, condition_href, condition_max; |
Line 32... | Line 32... | ||
32 | 32 | ||
Line 33... | Line 33... | ||
33 | enum { _WIN, _DOS, _KOI, _UTF }; |
33 | enum { _WIN, _DOS, _KOI, _UTF, _DEFAULT }; |
34 | 34 | ||
Line 55... | Line 55... | ||
55 | #include "..\TWB\history.h" |
55 | #include "..\TWB\history.h" |
56 | #include "..\TWB\colors.h" |
56 | #include "..\TWB\colors.h" |
57 | #include "..\TWB\unicode_tags.h" |
57 | #include "..\TWB\unicode_tags.h" |
58 | #include "..\TWB\img_cache.h" |
58 | #include "..\TWB\img_cache.h" |
59 | #include "..\TWB\parce_tag.h" |
59 | #include "..\TWB\parce_tag.h" |
- | 60 | #include "..\TWB\table.h" |
|
Line 60... | Line 61... | ||
60 | 61 | ||
Line 138... | Line 139... | ||
138 | 139 | ||
139 | strcat(#newurl, #URL); |
140 | strcat(#newurl, #URL); |
140 | strcpy(#URL, #newurl); |
141 | strcpy(#URL, #newurl); |
Line 141... | Line -... | ||
141 | } |
- | |
142 | 142 | } |
|
143 | 143 | ||
- | 144 | void BufEncode(int set_new_encoding) |
|
144 | void TWebBrowser::ReadHtml(byte encoding) |
145 | { |
145 | { |
146 | cur_encoding = set_new_encoding; |
146 | if (native_http) |
- | |
147 | { |
- | |
148 | if (strncmp(#URL,"http:",5)) { |
147 | if (o_bufpointer==0) |
149 | file_size stdcall (#URL); |
- | |
150 | bufsize = EBX; |
- | |
151 | } |
148 | { |
152 | - | ||
153 | if (!bufsize) return; |
- | |
154 | 149 | debugi(bufsize); |
|
155 | if (strncmp(#URL,"http:",5)) { |
150 | bufsize = strlen(bufpointer); |
156 | mem_Free(bufpointer); |
- | |
157 | bufpointer = mem_Alloc(bufsize); |
- | |
158 | } |
- | |
159 | - | ||
160 | if (strncmp(#URL,"http:",5)) ReadFile(0, bufsize, bufpointer, #URL); |
- | |
161 | 151 | debugi(bufsize); |
|
162 | cur_encoding = encoding; |
- | |
163 | if (encoding==_WIN) wintodos(bufpointer); |
- | |
164 | if (encoding==_UTF) utf8rutodos(bufpointer); |
152 | o_bufpointer = malloc(bufsize); |
165 | if (encoding==_KOI) koitodos(bufpointer); |
153 | strcpy(o_bufpointer, bufpointer); |
166 | } |
154 | } |
167 | else |
- | |
168 | { |
- | |
169 | if (!strncmp(#URL,"http:",5)) |
- | |
170 | file_size stdcall (#download_path); |
- | |
171 | else |
- | |
172 | file_size stdcall (#URL); |
- | |
173 | - | ||
174 | bufsize = EBX; |
- | |
175 | if (!bufsize) return; |
- | |
176 | 155 | else |
|
177 | mem_Free(bufpointer); |
- | |
178 | bufpointer = mem_Alloc(bufsize); |
- | |
179 | if (!strncmp(#URL,"http:",5)) |
- | |
180 | ReadFile(0, bufsize, bufpointer, #download_path); |
- | |
181 | else |
- | |
182 | ReadFile(0, bufsize, bufpointer, #URL); |
- | |
183 | - | ||
184 | cur_encoding = encoding; |
- | |
185 | if (encoding==_WIN) wintodos(bufpointer); |
- | |
186 | if (encoding==_UTF) utf8rutodos(bufpointer); |
156 | { |
- | 157 | strcpy(bufpointer, o_bufpointer); |
|
- | 158 | } |
|
- | 159 | if (set_new_encoding==_WIN) wintodos(bufpointer); |
|
187 | if (encoding==_KOI) koitodos(bufpointer); |
160 | if (set_new_encoding==_UTF) utf8rutodos(bufpointer); |
Line 188... | Line -... | ||
188 | } |
- | |
189 | } |
161 | if (set_new_encoding==_KOI) koitodos(bufpointer); |
- | 162 | } |
|
- | 163 | ||
190 | 164 | void TWebBrowser::Prepare(dword bufpos, in_filesize){ |
|
191 | /* |
- | |
192 | void TWebBrowser::ReadHtml(byte encoding) |
- | |
193 | { |
165 | bufsize = in_filesize; |
194 | - | ||
Line 195... | Line 166... | ||
195 | 166 | bufpointer = bufpos; |
|
196 | } |
167 | Parse(); |
197 | */ |
168 | } |
198 | 169 | ||
199 | 170 | ||
200 | void TWebBrowser::Parse(dword bufpos, in_filesize){ |
- | |
201 | word bukva[2]; |
171 | void TWebBrowser::Parse(){ |
Line 202... | Line 172... | ||
202 | int j, perenos_num; |
172 | word bukva[2]; |
203 | byte ignor_param; |
173 | int j, perenos_num; |
204 | char temp[768]; |
174 | byte ignor_param; |
205 | bufsize = in_filesize; |
175 | char temp[768]; |
Line 370... | Line 340... | ||
370 | if (list.first == 0) list.count = stroka; |
340 | if (list.first == 0) list.count = stroka; |
371 | if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
341 | if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
372 | { |
342 | { |
373 | anchor=NULL; |
343 | anchor=NULL; |
374 | list.first=anchor_line_num; |
344 | list.first=anchor_line_num; |
375 | Parse(bufpointer, bufsize); |
345 | Parse(); |
376 | } |
346 | } |
377 | DrawScroller(); |
347 | DrawScroller(); |
378 | } |
348 | } |
Line 379... | Line 349... | ||
379 | 349 | ||
380 | 350 | ||
381 | 351 | ||
382 | char oldtag[100]; |
352 | char oldtag[100]; |
383 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
- | |
- | 353 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
|
384 | dword hr_color; |
354 | dword hr_color; |
385 | byte opened; |
355 | byte opened; |
386 | 356 | byte meta_encoding; |
|
387 | //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ |
357 | //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ |
388 | if (tag[0] == '/') |
358 | if (tag[0] == '/') |
Line 494... | Line 464... | ||
494 | } |
464 | } |
495 | else |
465 | else |
496 | if (text_color_index > 0) text_color_index--; |
466 | if (text_color_index > 0) text_color_index--; |
497 | return; |
467 | return; |
498 | } |
468 | } |
499 | if(isTag("tr")) || (isTag("br")) { |
469 | if (isTag("br")) { |
500 | TextGoDown(left1, top1, width1); |
470 | TextGoDown(left1, top1, width1); |
501 | return; |
471 | return; |
502 | } |
472 | } |
503 | if (isTag("div")) || (isTag("header")) || (isTag("footer")) { |
473 | if (isTag("div")) || (isTag("header")) || (isTag("footer")) { |
504 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
474 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
Line 508... | Line 478... | ||
508 | IF(oldtag[0] == 'h') return; |
478 | IF(oldtag[0] == 'h') return; |
509 | TextGoDown(left1, top1, width1); |
479 | TextGoDown(left1, top1, width1); |
510 | IF(opened) TextGoDown(left1, top1 + 10, width1); |
480 | IF(opened) TextGoDown(left1, top1 + 10, width1); |
511 | return; |
481 | return; |
512 | } |
482 | } |
- | 483 | ||
- | 484 | ||
- | 485 | if(isTag("table")) { |
|
- | 486 | if (opened) |
|
- | 487 | { |
|
- | 488 | table.active = true; |
|
- | 489 | TextGoDown(left1, top1, width1); |
|
- | 490 | table.NewTable(); |
|
- | 491 | } |
|
- | 492 | else |
|
- | 493 | { |
|
- | 494 | table.active = false; |
|
- | 495 | TextGoDown(left1, top1, width1); |
|
- | 496 | } |
|
- | 497 | } |
|
- | 498 | if(isTag("td")) { |
|
- | 499 | if (opened) |
|
- | 500 | { |
|
- | 501 | // |
|
- | 502 | } |
|
- | 503 | else |
|
- | 504 | { |
|
- | 505 | // |
|
- | 506 | } |
|
- | 507 | } |
|
- | 508 | if(isTag("tr")) { |
|
- | 509 | if (opened) |
|
- | 510 | { |
|
- | 511 | // |
|
- | 512 | } |
|
- | 513 | else |
|
- | 514 | { |
|
- | 515 | TextGoDown(left1, top1, width1); |
|
- | 516 | if (table.cur_row == 0) table.max_cols = table.cur_col; |
|
- | 517 | table.cur_row++; |
|
- | 518 | } |
|
- | 519 | } |
|
513 | /* |
520 | /* |
514 | if (isTag("center")) |
521 | if (isTag("center")) |
515 | { |
522 | { |
516 | if (opened) text_align = ALIGN_CENTER; |
523 | if (opened) text_align = ALIGN_CENTER; |
517 | if (!opened) |
524 | if (!opened) |
Line 615... | Line 622... | ||
615 | { |
622 | { |
616 | do{ |
623 | do{ |
617 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
624 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
618 | { |
625 | { |
619 | strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content= |
626 | strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content= |
- | 627 | strlwr(#options); |
|
620 | if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF); |
628 | if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) meta_encoding = _UTF; |
621 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
629 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI; |
- | 630 | if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN; |
|
622 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
631 | //if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = _DOS; |
- | 632 | if ((cur_encoding==_DEFAULT) && (http_transfer==0)) BufEncode(meta_encoding); |
|
- | 633 | return; |
|
623 | } |
634 | } |
624 | } while(GetNextParam()); |
635 | } while(GetNextParam()); |
625 | return; |
636 | return; |
626 | } |
637 | } |
627 | } |
638 | } |
Line 628... | Line -... | ||
628 | - | ||
629 | /* |
- | |
630 | char *encodings = { |
- | |
631 | "utf-8", _UTF, |
- | |
632 | "utf8", _UTF, |
- | |
633 | "koi8-r", _KOI, |
- | |
634 | "koi8-u", _KOI, |
- | |
635 | "dos", _DOS, |
- | |
636 | "cp-866", _DOS |
- | |
637 | }; |
- | |
638 | */ |
- | |
639 | 639 | ||
640 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
640 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
641 | { |
641 | { |
642 | scroll_wv.max_area = list.count; |
642 | scroll_wv.max_area = list.count; |
643 | scroll_wv.cur_area = list.visible; |
643 | scroll_wv.cur_area = list.visible; |
Line 671... | Line 671... | ||
671 | 671 | ||
672 | int isTag(dword text) |
672 | int isTag(dword text) |
673 | { |
673 | { |
674 | if (!strcmp(#tag,text)) return 1; else return 0; |
674 | if (!strcmp(#tag,text)) return 1; else return 0; |
- | 675 | }>>>>>=>=>>=15)>>>>>>>=>!--> |
|
- | 676 | >': |