Rev 7945 | Rev 7976 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7945 | Rev 7970 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | DOWNLOAD_LINK_CONTENTS, |
62 | DOWNLOAD_LINK_CONTENTS, |
63 | TAB_ID, |
63 | TAB_ID, |
64 | TAB_CLOSE_ID = 900 |
64 | TAB_CLOSE_ID = 900 |
65 | }; |
65 | }; |
Line -... | Line 66... | ||
- | 66 | ||
- | 67 | enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB }; |
|
66 | 68 | ||
Line 67... | Line 69... | ||
67 | #include "..\TWB\TWB.c" //HTML Parser, a core component |
69 | #include "..\TWB\TWB.c" //HTML Parser, a core component |
68 | 70 | ||
Line 123... | Line 125... | ||
123 | strcpy(#downloader_edit, #param+19); |
125 | strcpy(#downloader_edit, #param+19); |
124 | Downloader(); |
126 | Downloader(); |
125 | ExitProcess(); |
127 | ExitProcess(); |
126 | } else if (!strncmp(#param, "-download ", 10)) { |
128 | } else if (!strncmp(#param, "-download ", 10)) { |
127 | strcpy(#downloader_edit, #param+10); |
129 | strcpy(#downloader_edit, #param+10); |
128 | //CreateThread(#Downloader,#downloader_stak+4092); |
- | |
129 | Downloader(); |
130 | Downloader(); |
130 | ExitProcess(); |
131 | ExitProcess(); |
131 | } else if (!strncmp(#param, "-source ", 8)) { |
132 | } else if (!strncmp(#param, "-source ", 8)) { |
132 | source_mode = true; |
133 | source_mode = true; |
133 | history.add(#param + 8); |
134 | history.add(#param + 8); |
Line 149... | Line 150... | ||
149 | ESDWORD[shared_url] = '\0'; |
150 | ESDWORD[shared_url] = '\0'; |
150 | } |
151 | } |
Line 151... | Line 152... | ||
151 | 152 | ||
152 | void main() |
153 | void main() |
153 | { |
154 | { |
154 | int i, btn, redirect_count=0; |
155 | int i, redirect_count=0; |
155 | LoadLibraries(); |
156 | LoadLibraries(); |
156 | CreateDir("/tmp0/1/Downloads"); |
157 | CreateDir("/tmp0/1/Downloads"); |
157 | //CreateDir("/tmp0/1/WebView_Cache"); |
158 | //CreateDir("/tmp0/1/WebView_Cache"); |
158 | HandleParam(); |
159 | HandleParam(); |
Line 163... | Line 164... | ||
163 | loop() switch(@WaitEventTimeout(30)) |
164 | loop() switch(@WaitEventTimeout(30)) |
164 | { |
165 | { |
165 | case evMouse: |
166 | case evMouse: |
166 | edit_box_mouse stdcall (#address_box); |
167 | edit_box_mouse stdcall (#address_box); |
167 | mouse.get(); |
168 | mouse.get(); |
168 | PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first); |
- | |
169 | if (PageLinks.active == -1) && (mouse.pkm) && (mouse.up) { |
- | |
170 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(); |
- | |
171 | break; |
- | |
172 | } |
169 | |
173 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
170 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
- | 171 | ||
174 | scrollbar_v_mouse (#scroll_wv); |
172 | scrollbar_v_mouse (#scroll_wv); |
175 | if (WB1.list.first != scroll_wv.position) |
173 | if (scroll_wv.delta) { |
176 | { |
- | |
177 | WB1.list.first = scroll_wv.position; |
174 | WB1.list.first = scroll_wv.position; |
178 | WB1.DrawPage(); |
175 | WB1.DrawPage(); |
179 | break; |
176 | break; |
180 | } |
177 | } |
- | 178 | ||
181 | if (mouse.up) && (! address_box.flags & ed_focus) && (address_box.flags & ed_shift_bac) |
179 | if (links.hover(WB1.list.y, WB1.list.first)) |
182 | { |
180 | { |
- | 181 | if (mouse.mkm) { |
|
- | 182 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
|
183 | DrawOmnibox(); //reset text selection |
183 | EventClickLink(TARGET_NEW_WINDOW); |
- | 184 | } else { |
|
- | 185 | EventClickLink(TARGET_NEW_TAB); |
|
- | 186 | } |
|
- | 187 | } |
|
- | 188 | if (mouse.lkm) { |
|
- | 189 | CursorPointer.Restore(); |
|
- | 190 | EventClickLink(TARGET_SAME_TAB); |
|
- | 191 | } |
|
- | 192 | if (mouse.pkm) { |
|
- | 193 | CursorPointer.Restore(); |
|
- | 194 | EventShowLinkMenu(); |
|
- | 195 | } |
|
- | 196 | } else { |
|
- | 197 | CursorPointer.Restore(); |
|
- | 198 | if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) { |
|
- | 199 | EventShowPageMenu(); |
|
- | 200 | } |
|
184 | } |
201 | } |
185 | break; |
202 | break; |
Line 186... | Line 203... | ||
186 | 203 | ||
187 | case evButton: |
204 | case evButton: |
188 | btn = GetButtonID(); |
- | |
189 | if (1==btn) ExitProcess(); else ProcessEvent(btn); |
205 | ProcessEvent( GetButtonID() ); |
Line 190... | Line 206... | ||
190 | break; |
206 | break; |
191 | 207 | ||
192 | case evKey: |
- | |
Line 193... | Line 208... | ||
193 | GetKeys(); |
208 | case evKey: |
194 | //if (key_scancode == SCAN_CODE_F1) {DebugTabs();break;} |
209 | GetKeys(); |
195 | 210 | ||
Line 350... | Line 365... | ||
350 | if (!BrowserWidthChanged()) { |
365 | if (!BrowserWidthChanged()) { |
351 | WB1.DrawPage(); |
366 | WB1.DrawPage(); |
352 | DrawOmnibox(); |
367 | DrawOmnibox(); |
353 | } |
368 | } |
354 | DrawProgress(); |
369 | DrawProgress(); |
355 | DrawStatusBar(NULL); |
370 | DrawStatusBar(); |
356 | DrawTabsBar(); |
371 | DrawTabsBar(); |
357 | } |
372 | } |
Line 358... | Line 373... | ||
358 | 373 | ||
359 | bool BrowserWidthChanged() |
374 | bool BrowserWidthChanged() |
Line 386... | Line 401... | ||
386 | } |
401 | } |
Line 387... | Line 402... | ||
387 | 402 | ||
388 | 403 | ||
389 | void ProcessEvent(dword id__) |
- | |
390 | { |
404 | void ProcessEvent(dword id__) |
391 | char new_clip_url[URL_SIZE+1]; |
405 | { |
- | 406 | switch (id__) |
|
- | 407 | { |
|
- | 408 | case 1: |
|
392 | switch (id__) |
409 | ExitProcess(); |
393 | { |
410 | break; |
394 | case ENCODINGS...ENCODINGS+6: |
411 | case ENCODINGS...ENCODINGS+6: |
395 | EventChangeEncodingAndLoadPage(id__-ENCODINGS); |
412 | EventChangeEncodingAndLoadPage(id__-ENCODINGS); |
396 | return; |
413 | return; |
Line 448... | Line 465... | ||
448 | pages_cache.clear(); |
465 | pages_cache.clear(); |
449 | notify(#clear_cache_ok); |
466 | notify(#clear_cache_ok); |
450 | EventRefreshPage(); |
467 | EventRefreshPage(); |
451 | return; |
468 | return; |
452 | case IN_NEW_TAB: |
469 | case IN_NEW_TAB: |
453 | open_new_tab = true; |
- | |
454 | EventClickLink(PageLinks.GetURL(PageLinks.active)); |
470 | EventClickLink(TARGET_NEW_TAB); |
455 | open_new_tab = false; |
- | |
456 | return; |
471 | return; |
457 | case IN_NEW_WINDOW: |
472 | case IN_NEW_WINDOW: |
458 | open_new_window = true; |
- | |
459 | EventClickLink(PageLinks.GetURL(PageLinks.active)); |
473 | EventClickLink(TARGET_NEW_WINDOW); |
460 | open_new_window = false; |
- | |
461 | return; |
474 | return; |
462 | case COPY_LINK_URL: |
475 | case COPY_LINK_URL: |
463 | strncpy(#new_clip_url, PageLinks.GetURL(PageLinks.active), URL_SIZE); |
- | |
464 | GetAbsoluteURL(#new_clip_url, history.current()); |
- | |
465 | Clipboard__CopyText(#new_clip_url); |
476 | Clipboard__CopyText(GetAbsoluteActiveURL()); |
466 | notify("'URL copied to clipboard'O"); |
477 | notify("'URL copied to clipboard'O"); |
467 | return; |
478 | return; |
468 | case DOWNLOAD_LINK_CONTENTS: |
479 | case DOWNLOAD_LINK_CONTENTS: |
469 | if (!downloader_opened) { |
480 | if (!downloader_opened) { |
470 | strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active)); |
481 | strcpy(#downloader_edit, GetAbsoluteActiveURL()); |
471 | GetAbsoluteURL(#downloader_edit, history.current()); |
- | |
472 | CreateThread(#Downloader,#downloader_stak+4092); |
482 | CreateThread(#Downloader,#downloader_stak+4092); |
473 | } |
483 | } |
474 | return; |
484 | return; |
475 | case OPEN_FILE: |
485 | case OPEN_FILE: |
476 | EventOpenDialog(); |
486 | EventOpenDialog(); |
Line 563... | Line 573... | ||
563 | } |
573 | } |
Line 564... | Line 574... | ||
564 | 574 | ||
565 | void OpenPage(dword _open_URL) |
575 | void OpenPage(dword _open_URL) |
566 | { |
576 | { |
- | 577 | char new_url[URL_SIZE+1]; |
|
567 | char new_url[URL_SIZE+1]; |
578 | char new_url_full[URL_SIZE+1]; |
Line 568... | Line 579... | ||
568 | int unz_id; |
579 | int unz_id; |
Line 569... | Line -... | ||
569 | - | ||
570 | StopLoading(); |
- | |
571 | - | ||
572 | if (open_new_tab) { |
- | |
573 | open_new_tab = false; |
- | |
574 | EventOpenNewTab(_open_URL); |
- | |
575 | return; |
580 | |
Line 576... | Line 581... | ||
576 | } |
581 | StopLoading(); |
Line 577... | Line 582... | ||
577 | 582 | ||
578 | SetOmniboxText(_open_URL); |
583 | SetOmniboxText(_open_URL); |
- | 584 | ||
579 | 585 | strncpy(#new_url, _open_URL, URL_SIZE); |
|
- | 586 | ||
Line 580... | Line 587... | ||
580 | strncpy(#new_url, _open_URL, URL_SIZE); |
587 | //Exclude # from the URL to the load page |
Line 581... | Line 588... | ||
581 | 588 | //We will bring it back when we get the buffer |
|
582 | //Exclude # from the URL to the load page |
589 | if (strrchr(#new_url, '#')) { |
Line 603... | Line 610... | ||
603 | } |
610 | } |
Line 604... | Line 611... | ||
604 | 611 | ||
605 | if (!strncmp(#new_url,"http:",5)) { |
612 | if (!strncmp(#new_url,"http:",5)) { |
606 | http.get(#new_url); |
613 | http.get(#new_url); |
607 | } else if (!strncmp(#new_url,"https://",8)) { |
614 | } else if (!strncmp(#new_url,"https://",8)) { |
608 | strcpy(#new_url, "http://gate.aspero.pro/?site="); |
615 | strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
609 | strncat(#new_url, _open_URL, URL_SIZE); |
616 | strncat(#new_url_full, #new_url, URL_SIZE); |
610 | http.get(#new_url); |
617 | http.get(#new_url_full); |
Line 611... | Line 618... | ||
611 | } |
618 | } |
Line 612... | Line 619... | ||
612 | 619 | ||
Line 629... | Line 636... | ||
629 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
636 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
630 | } |
637 | } |
631 | } |
638 | } |
632 | } |
639 | } |
Line -... | Line 640... | ||
- | 640 | ||
- | 641 | ||
- | 642 | bool EventClickAnchor() |
|
- | 643 | { |
|
- | 644 | dword aURL = links.active_url; |
|
- | 645 | ||
- | 646 | if (anchors.get_pos_by_name(aURL+1)!=-1) { |
|
- | 647 | WB1.list.first = anchors.get_pos_by_name(aURL+1); |
|
- | 648 | //WB1.list.CheckDoesValuesOkey(); |
|
- | 649 | strcpy(#editURL, history.current()); |
|
- | 650 | strcat(#editURL, aURL); |
|
- | 651 | DrawOmnibox(); |
|
- | 652 | WB1.DrawPage(); |
|
- | 653 | return true; |
|
- | 654 | } |
|
- | 655 | return false; |
|
- | 656 | } |
|
633 | 657 | ||
634 | void EventClickLink(dword _click_URL) |
658 | void EventClickLink(dword _target) |
635 | { |
659 | { |
636 | char new_url[URL_SIZE+1]; |
660 | char new_url[URL_SIZE+1]; |
- | 661 | char new_url_full[URL_SIZE+1]; |
|
- | 662 | dword aURL = GetAbsoluteActiveURL(); |
|
Line 637... | Line -... | ||
637 | char new_url_full[URL_SIZE+1]; |
- | |
638 | 663 | if (!aURL) return; |
|
- | 664 | ||
639 | if (open_new_window) { |
665 | strcpy(#new_url, aURL); |
640 | strncpy(#new_url, _click_URL, sizeof(new_url)); |
666 | |
641 | GetAbsoluteURL(#new_url, history.current()); |
- | |
642 | strcpy(#new_url_full, "-new "); |
667 | if (ESBYTE[aURL]=='#') { |
643 | strncat(#new_url_full, #new_url, sizeof(new_url_full)); |
668 | if (_target == TARGET_SAME_TAB) { |
- | 669 | EventClickAnchor(); |
|
- | 670 | return; |
|
- | 671 | } else { |
|
- | 672 | strcpy(#new_url, history.current()); |
|
644 | RunProgram(#program_path, #new_url_full); |
673 | strcat(#new_url, aURL); |
Line 645... | Line 674... | ||
645 | return; |
674 | } |
646 | } |
675 | } |
647 | - | ||
648 | if (ESBYTE[_click_URL]=='#') { |
676 | |
649 | if (anchors.get_pos_by_name(_click_URL+1)!=-1) { |
677 | if (_target == TARGET_NEW_TAB) { |
- | 678 | EventOpenNewTab(#new_url); |
|
650 | WB1.list.first = anchors.get_pos_by_name(_click_URL+1); |
679 | return; |
651 | WB1.list.CheckDoesValuesOkey(); |
680 | } |
652 | } |
681 | |
653 | strcpy(#editURL, history.current()); |
682 | if (_target == TARGET_NEW_WINDOW) { |
654 | strcat(#editURL, _click_URL); |
683 | strcpy(#new_url_full, "-new "); |
655 | DrawOmnibox(); |
684 | strncat(#new_url_full, #new_url, URL_SIZE); |
Line 656... | Line 685... | ||
656 | WB1.DrawPage(); |
685 | RunProgram(#program_path, #new_url_full); |
657 | return; |
686 | return; |
658 | } |
687 | } |
659 | 688 | ||
Line 660... | Line 689... | ||
660 | if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) { |
689 | if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) { |
661 | notify(_click_URL); |
690 | notify(#new_url); |
662 | return; |
691 | return; |
663 | } |
692 | } |
Line 664... | Line -... | ||
664 | - | ||
665 | if (http.transfer) { |
- | |
666 | StopLoading(); |
- | |
667 | history.back(); |
693 | |
668 | } |
694 | if (http.transfer) { |
669 | 695 | StopLoading(); |
|
670 | strcpy(#new_url, _click_URL); |
696 | history.back(); |
671 | GetAbsoluteURL(#new_url, history.current()); |
697 | } |
Line 715... | Line 741... | ||
715 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
741 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
716 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
742 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
717 | OpenPage(#editURL); |
743 | OpenPage(#editURL); |
718 | } else { |
744 | } else { |
719 | strcpy(#new_url, "http://"); |
745 | strcpy(#new_url, "http://"); |
720 | strncat(#new_url, #editURL, sizeof(new_url)-1); |
746 | strncat(#new_url, #editURL, URL_SIZE-1); |
721 | OpenPage(#new_url); |
747 | OpenPage(#new_url); |
722 | } |
748 | } |
723 | } |
749 | } |
Line 724... | Line 750... | ||
724 | 750 | ||
Line 731... | Line 757... | ||
731 | if(!strrchr(#editURL, '#')) { |
757 | if(!strrchr(#editURL, '#')) { |
732 | strcat(#editURL, #anchors.current); |
758 | strcat(#editURL, #anchors.current); |
733 | DrawOmnibox(); |
759 | DrawOmnibox(); |
734 | } |
760 | } |
735 | WB1.ParseHtml(_bufdata, _in_bufsize); |
761 | WB1.ParseHtml(_bufdata, _in_bufsize); |
736 | DrawStatusBar(NULL); |
762 | DrawStatusBar(); |
737 | DrawActiveTab(); |
763 | DrawActiveTab(); |
738 | if (source_mode) { |
764 | if (source_mode) { |
739 | source_mode = false; |
765 | source_mode = false; |
740 | WB1.custom_encoding = CH_CP866; |
766 | WB1.custom_encoding = CH_CP866; |
741 | ShowSource(WB1.bufpointer, _in_bufsize); |
767 | ShowSource(WB1.bufpointer, _in_bufsize); |
Line 782... | Line 808... | ||
782 | menu_id = OPEN_FILE; |
808 | menu_id = OPEN_FILE; |
783 | } |
809 | } |
Line 784... | Line 810... | ||
784 | 810 | ||
785 | void EventShowEncodingsList() |
811 | void EventShowEncodingsList() |
786 | { |
812 | { |
787 | open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + status_text.start_y + 8, |
813 | open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + Form.cheight - STATUSBAR_H + 12, |
788 | MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); |
814 | MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); |
789 | menu_id = ENCODINGS; |
815 | menu_id = ENCODINGS; |
Line 790... | Line 816... | ||
790 | } |
816 | } |
Line 893... | Line 919... | ||
893 | RunProgram(#program_path, history.current()); |
919 | RunProgram(#program_path, history.current()); |
894 | ExitProcess(); |
920 | ExitProcess(); |
895 | } |
921 | } |
896 | } |
922 | } |
Line 897... | Line 923... | ||
897 | 923 | ||
898 | void DrawStatusBar(dword _status_text) |
924 | void DrawStatusBar() |
899 | { |
- | |
900 | status_text.font_color = sc.work_text; |
- | |
901 | status_text.start_x = 10; |
925 | { |
902 | status_text.start_y = Form.cheight - STATUSBAR_H + 4; |
926 | dword status_y = Form.cheight - STATUSBAR_H + 4; |
903 | status_text.area_size_x = Form.cwidth - status_text.start_x -3 - 70; |
- | |
904 | //DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, sc.work); |
927 | dword status_w = Form.cwidth - 90; |
905 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work); |
928 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work); |
906 | if (_status_text) { |
- | |
907 | status_text.text_pointer = _status_text; |
929 | if (links.active_url) { |
908 | PathShow_prepare stdcall(#status_text); |
930 | ESI = math.min(status_w/6, strlen(links.active_url)); |
909 | PathShow_draw stdcall(#status_text); |
931 | WriteText(10, status_y, 0, sc.work_text, links.active_url); |
910 | } |
932 | } |
911 | DefineHiddenButton(status_text.start_x+status_text.area_size_x+10, status_text.start_y-3, |
- | |
912 | 60, 12, CHANGE_ENCODING); |
- | |
913 | WriteTextCenter(status_text.start_x+status_text.area_size_x+10, |
933 | DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING); |
914 | status_text.start_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets); |
934 | WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets); |
Line 915... | Line 935... | ||
915 | } |
935 | } |
916 | 936 | ||
917 | void DrawOmnibox() |
937 | void DrawOmnibox() |
Line 939... | Line 959... | ||
939 | strcpy(#editURL, _text); |
959 | strcpy(#editURL, _text); |
940 | address_box.flags=0; |
960 | address_box.flags=0; |
941 | DrawOmnibox(); |
961 | DrawOmnibox(); |
942 | } |
962 | } |
Line -... | Line 963... | ||
- | 963 | ||
- | 964 | dword GetAbsoluteActiveURL() |
|
- | 965 | { |
|
- | 966 | char abs_url[URL_SIZE]; |
|
- | 967 | if (links.active_url) { |
|
- | 968 | strncpy(#abs_url, links.active_url, URL_SIZE); |
|
- | 969 | GetAbsoluteURL(#abs_url, history.current()); |
|
- | 970 | return #abs_url; |
|
- | 971 | } |
|
- | 972 | return 0; |
|
Line 943... | Line 973... | ||
943 | 973 | } |
|
944 | 974 |