Rev 7756 | Rev 7758 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7756 | Rev 7757 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | #include "..\lib\obj\libio.h" |
21 | #include "..\lib\obj\libio.h" |
22 | #include "..\lib\obj\libimg.h" |
22 | #include "..\lib\obj\libimg.h" |
23 | #include "..\lib\obj\http.h" |
23 | #include "..\lib\obj\http.h" |
24 | #include "..\lib\obj\iconv.h" |
24 | #include "..\lib\obj\iconv.h" |
25 | #include "..\lib\obj\proc_lib.h" |
25 | #include "..\lib\obj\proc_lib.h" |
- | 26 | ||
26 | //useful patterns |
27 | //useful patterns |
27 | #include "..\lib\patterns\history.h" |
28 | #include "..\lib\patterns\history.h" |
28 | #include "..\lib\patterns\http_downloader.h" |
29 | #include "..\lib\patterns\http_downloader.h" |
29 | #include "..\lib\patterns\simple_open_dialog.h" |
30 | #include "..\lib\patterns\simple_open_dialog.h" |
Line -... | Line 31... | ||
- | 31 | ||
- | 32 | #include "show_src.h" |
|
- | 33 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
|
- | 34 | #include "download_manager.h" |
|
- | 35 | _history history; |
|
- | 36 | #include "history.h" |
|
- | 37 | ||
- | 38 | bool debug_mode = false; |
|
- | 39 | dword col_bg = 0xE3E2E2; |
|
- | 40 | dword panel_color = 0xE3E2E2; |
|
- | 41 | dword border_color = 0x787878; |
|
- | 42 | #include "..\TWB\TWB.c" |
|
30 | 43 | ||
31 | #ifdef LANG_RUS |
44 | #ifdef LANG_RUS |
32 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 2.0 beta2"; |
45 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 2.0 beta4"; |
33 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
46 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
34 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
47 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
35 | char help[] = FROM "html\\help_ru.htm""\0"; |
48 | char help[] = FROM "html\\help_ru.htm""\0"; |
36 | char accept_language[]= "Accept-Language: ru\n"; |
49 | char accept_language[]= "Accept-Language: ru\n"; |
Line 41... | Line 54... | ||
41 | ¥¥¤¦¥à § £à㧮ª"; |
54 | ¥¥¤¦¥à § £à㧮ª"; |
42 | char link_menu[] = |
55 | char link_menu[] = |
43 | "®¯¨à®¢ âì áá뫪ã |
56 | "®¯¨à®¢ âì áá뫪ã |
44 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
57 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
45 | #else |
58 | #else |
46 | char version[]="Text-based Browser 2.0 beta2"; |
59 | char version[]="Text-based Browser 2.0 beta4"; |
47 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
60 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
48 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
61 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
49 | char help[] = FROM "html\\help_en.htm""\0"; |
62 | char help[] = FROM "html\\help_en.htm""\0"; |
50 | char accept_language[]= "Accept-Language: en\n"; |
63 | char accept_language[]= "Accept-Language: en\n"; |
51 | char rmb_menu[] = |
64 | char rmb_menu[] = |
Line 58... | Line 71... | ||
58 | Download link contents"; |
71 | Download link contents"; |
59 | #endif |
72 | #endif |
Line 60... | Line 73... | ||
60 | 73 | ||
Line 61... | Line -... | ||
61 | #define URL_SIZE 4000 |
- | |
62 | - | ||
63 | dword col_bg = 0xE3E2E2; |
- | |
64 | dword panel_color = 0xE3E2E2; |
- | |
65 | dword border_color = 0x787878; |
- | |
66 | - | ||
67 | bool debug_mode = false; |
- | |
68 | - | ||
69 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
- | |
70 | - | ||
71 | #include "..\TWB\TWB.c" |
- | |
72 | #include "history.h" |
- | |
73 | #include "show_src.h" |
- | |
74 | #include "download_manager.h" |
74 | #define URL_SIZE 4000 |
75 | 75 | ||
76 | #define URL_SERVICE_HISTORY "WebView:history" |
76 | #define URL_SERVICE_HISTORY "WebView:history" |
Line 77... | Line 77... | ||
77 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
77 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
Line 156... | Line 156... | ||
156 | loop() switch(WaitEvent()) |
156 | loop() switch(WaitEvent()) |
157 | { |
157 | { |
158 | case evMouse: |
158 | case evMouse: |
159 | edit_box_mouse stdcall (#address_box); |
159 | edit_box_mouse stdcall (#address_box); |
160 | mouse.get(); |
160 | mouse.get(); |
161 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y)) |
161 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first)) |
162 | && (mouse.pkm) && (mouse.up) { |
162 | && (mouse.pkm) && (mouse.up) { |
163 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
163 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
164 | break; |
164 | break; |
165 | } |
165 | } |
166 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
166 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
Line 248... | Line 248... | ||
248 | } |
248 | } |
249 | else |
249 | else |
250 | { |
250 | { |
251 | http.handle_redirect(); |
251 | http.handle_redirect(); |
252 | http.free(); |
252 | http.free(); |
253 | GetAbsoluteURL(#http.redirect_url); |
253 | GetAbsoluteURL(#http.redirect_url, history.current()); |
254 | debug("Redirect: "); debugln(#http.redirect_url); |
254 | debug("Redirect: "); debugln(#http.redirect_url); |
255 | history.back(); |
255 | history.back(); |
256 | OpenPage(#http.redirect_url); |
256 | OpenPage(#http.redirect_url); |
257 | } |
257 | } |
258 | break; |
258 | break; |
Line 275... | Line 275... | ||
275 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
275 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
276 | WB1.list.wheel_size = 7 * basic_line_h; |
276 | WB1.list.wheel_size = 7 * basic_line_h; |
277 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
277 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
278 | WB1.list.visible = WB1.list.h; |
278 | WB1.list.visible = WB1.list.h; |
279 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
279 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
280 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20); |
280 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); |
281 | OpenPage(history.current()); |
281 | OpenPage(history.current()); |
282 | } |
282 | } |
283 | } |
283 | } |
Line 299... | Line 299... | ||
299 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
299 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
300 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
300 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
301 | if (!header) { |
301 | if (!header) { |
302 | OpenPage(history.current()); |
302 | OpenPage(history.current()); |
303 | WB1.DrawScroller(); |
303 | WB1.DrawScroller(); |
304 | } |
- | |
305 | else { |
304 | } else { |
306 | WB1.DrawPage(); |
305 | WB1.DrawPage(); |
307 | DrawOmnibox(); |
306 | DrawOmnibox(); |
308 | } |
- | |
309 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, |
307 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, |
310 | scroll_wv.size_y-1, scroll_wv.bckg_col); |
308 | scroll_wv.size_y-1, scroll_wv.bckg_col); |
- | 309 | } |
|
311 | DrawProgress(); |
310 | DrawProgress(); |
312 | } |
311 | } |
Line 313... | Line 312... | ||
313 | 312 | ||
Line 399... | Line 398... | ||
399 | wv_progress_bar.value = 0; |
398 | wv_progress_bar.value = 0; |
400 | DrawOmnibox(); |
399 | DrawOmnibox(); |
401 | } |
400 | } |
Line 402... | Line 401... | ||
402 | 401 | ||
403 | //rewrite into |
402 | //rewrite into |
404 | //bool strrpl(dword dst, from, to, dst_len); !!!!!!!! |
403 | //bool strrpl(dword dst, from, into, dst_len); |
405 | void ReplaceSpaceInUrl(dword url, size) { |
404 | bool ReplaceSpaceInUrl(dword url, size) { |
- | 405 | unsigned int i, j; |
|
406 | unsigned int i, j; |
406 | bool was_changed=false; |
407 | for (i=size-3; i>0; i--) |
407 | for (i=url+size-3; i>url; i--) |
408 | { |
408 | { |
409 | if (ESBYTE[i]!=' ') continue; |
409 | if (ESBYTE[i]!=' ') continue; |
- | 410 | for (j=url+size-3; j>=i; j--) { |
|
410 | for (j=size-3; j>i; j--) { |
411 | ESBYTE[j+3]=ESBYTE[j+2]; |
411 | ESBYTE[j+2]=ESBYTE[j+1]; |
412 | ESBYTE[j+2]=ESBYTE[j+1]; |
412 | ESBYTE[j+1]=ESBYTE[j]; |
413 | ESBYTE[j+1]=ESBYTE[j]; |
413 | } |
414 | } |
414 | ESBYTE[i] = '%'; |
415 | ESBYTE[i] = '%'; |
415 | ESBYTE[i+1] = '2'; |
416 | ESBYTE[i+1] = '2'; |
- | 417 | ESBYTE[i+2] = '0'; |
|
416 | ESBYTE[i+2] = '0'; |
418 | was_changed = true; |
417 | } |
419 | } |
418 | debugln(url); |
420 | return was_changed; |
Line 419... | Line 421... | ||
419 | } |
421 | } |
420 | 422 | ||
421 | bool GetLocalFileData(dword _path) |
423 | bool GetLocalFileData(dword _path) |
Line 460... | Line 462... | ||
460 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
462 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
461 | //WEB PAGE |
463 | //WEB PAGE |
462 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, |
464 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, |
463 | address_box.top-3, 17, skin.h, 85, SKIN_Y); |
465 | address_box.top-3, 17, skin.h, 85, SKIN_Y); |
Line 464... | Line 466... | ||
464 | 466 | ||
- | 467 | if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) { |
|
- | 468 | strcpy(#editURL, #new_url); |
|
- | 469 | DrawOmnibox(); |
|
- | 470 | } |
|
465 | //ReplaceSpaceInUrl(#new_url, URL_SIZE); |
471 | |
466 | if (!strncmp(#new_url,"http:",5)) { |
472 | if (!strncmp(#new_url,"http:",5)) { |
467 | http.get(#new_url); |
473 | http.get(#new_url); |
468 | } else if (!strncmp(#new_url,"https://",8)) { |
474 | } else if (!strncmp(#new_url,"https://",8)) { |
469 | strcpy(#new_url, "http://gate.aspero.pro/?site="); |
475 | strcpy(#new_url, "http://gate.aspero.pro/?site="); |
Line 507... | Line 513... | ||
507 | StopLoading(); |
513 | StopLoading(); |
508 | history.back(); |
514 | history.back(); |
509 | } |
515 | } |
Line 510... | Line 516... | ||
510 | 516 | ||
511 | strcpy(#new_url, _click_URL); |
517 | strcpy(#new_url, _click_URL); |
Line 512... | Line 518... | ||
512 | GetAbsoluteURL(#new_url); |
518 | GetAbsoluteURL(#new_url, history.current()); |
513 | 519 | ||
514 | if (strrchr(#new_url, '#')!=0) { |
520 | if (strrchr(#new_url, '#')!=0) { |
515 | anchors.take_anchor_from(#new_url); |
521 | anchors.take_anchor_from(#new_url); |
Line 592... | Line 598... | ||
592 | DrawOmnibox(); |
598 | DrawOmnibox(); |
593 | if(!strrchr(#editURL, '#')) { |
599 | if(!strrchr(#editURL, '#')) { |
594 | strcat(#editURL, #anchors.current); |
600 | strcat(#editURL, #anchors.current); |
595 | DrawOmnibox(); |
601 | DrawOmnibox(); |
596 | } |
602 | } |
- | 603 | WB1.ParseHtml(); |
|
597 | if (source_mode) { |
604 | if (source_mode) { |
598 | source_mode = false; |
605 | source_mode = false; |
599 | WB1.ParseHtml(); |
- | |
600 | ShowSource(bufpointer, bufsize); |
606 | ShowSource(bufpointer, bufsize); |
601 | return; |
607 | } else { |
602 | } |
- | |
603 | WB1.ParseHtml(); |
- | |
604 | WB1.DrawPage(); |
608 | WB1.DrawPage(); |
605 | } |
609 | } |
606 | } |
610 | } |
- | 611 | } |
|
Line 607... | Line 612... | ||
607 | 612 | ||
608 | byte UrlExtIs(dword base, ext) |
613 | byte UrlExtIs(dword base, ext) |
609 | { |
614 | { |
610 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |
615 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |