Rev 7743 | Rev 7748 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7743 | Rev 7746 | ||
---|---|---|---|
1 | //HTML Viewer in C-- |
1 | //HTML Viewer in C-- |
2 | //Copyright 2007-2020 by Veliant & Leency |
2 | //Copyright 2007-2020 by Veliant & Leency |
3 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
3 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
4 | 4 | ||
5 | #ifndef AUTOBUILD |
5 | #ifndef AUTOBUILD |
6 | #include "lang.h--" |
6 | #include "lang.h--" |
7 | #endif |
7 | #endif |
8 | 8 | ||
9 | //libraries |
9 | //libraries |
10 | #define MEMSIZE 1024 * 800 |
10 | #define MEMSIZE 1024 * 800 |
11 | #include "..\lib\gui.h" |
11 | #include "..\lib\gui.h" |
12 | #include "..\lib\draw_buf.h" |
12 | #include "..\lib\draw_buf.h" |
13 | #include "..\lib\list_box.h" |
13 | #include "..\lib\list_box.h" |
14 | #include "..\lib\cursor.h" |
14 | #include "..\lib\cursor.h" |
15 | #include "..\lib\collection.h" |
15 | #include "..\lib\collection.h" |
16 | #include "..\lib\random.h" |
16 | #include "..\lib\random.h" |
17 | #include "..\lib\clipboard.h" |
17 | #include "..\lib\clipboard.h" |
18 | 18 | ||
19 | // *.obj libraries |
19 | // *.obj libraries |
20 | #include "..\lib\obj\box_lib.h" |
20 | #include "..\lib\obj\box_lib.h" |
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 | //useful patterns |
25 | //useful patterns |
26 | #include "..\lib\patterns\history.h" |
26 | #include "..\lib\patterns\history.h" |
27 | #include "..\lib\patterns\http_downloader.h" |
27 | #include "..\lib\patterns\http_downloader.h" |
28 | 28 | ||
29 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
29 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
30 | 30 | ||
31 | 31 | ||
32 | #ifdef LANG_RUS |
32 | #ifdef LANG_RUS |
33 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 1.85"; |
33 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 1.9"; |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
36 | char loading[] = " £à㧪 áâà ¨æë... |
36 | char loading[] = " £à㧪 áâà ¨æë... |
37 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
37 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
38 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
38 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
39 | char help[] = FROM "html\\help_ru.htm""\0"; |
39 | char help[] = FROM "html\\help_ru.htm""\0"; |
40 | char accept_language[]= "Accept-Language: ru\n"; |
40 | char accept_language[]= "Accept-Language: ru\n"; |
41 | char rmb_menu[] = |
41 | char rmb_menu[] = |
42 | "®á¬®âà¥âì ¨á室¨ª |
42 | "®á¬®âà¥âì ¨á室¨ª |
43 | ¥¤ ªâ¨à®¢ âì ¨á室¨ª |
43 | ¥¤ ªâ¨à®¢ âì ¨á室¨ª |
44 | áâ®à¨ï |
44 | áâ®à¨ï |
45 | ¥¥¤¦¥à § £à㧮ª"; |
45 | ¥¥¤¦¥à § £à㧮ª"; |
46 | char link_menu[] = |
46 | char link_menu[] = |
47 | "®¯¨à®¢ âì áá뫪ã |
47 | "®¯¨à®¢ âì áá뫪ã |
48 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
48 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
49 | #else |
49 | #else |
50 | char version[]="Text-based Browser 1.85"; |
50 | char version[]="Text-based Browser 1.9"; |
51 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
51 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
52 | ?define T_LAST_SLIDE "This slide is the last" |
52 | ?define T_LAST_SLIDE "This slide is the last" |
53 | char loading[] = "Loading... |
53 | char loading[] = "Loading... |
54 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
54 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
55 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
55 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
56 | char help[] = FROM "html\\help_en.htm""\0"; |
56 | char help[] = FROM "html\\help_en.htm""\0"; |
57 | char accept_language[]= "Accept-Language: en\n"; |
57 | char accept_language[]= "Accept-Language: en\n"; |
58 | char rmb_menu[] = |
58 | char rmb_menu[] = |
59 | "View source |
59 | "View source |
60 | Edit source |
60 | Edit source |
61 | History |
61 | History |
62 | Download Manager"; |
62 | Download Manager"; |
63 | char link_menu[] = |
63 | char link_menu[] = |
64 | "Copy link |
64 | "Copy link |
65 | Download link contents"; |
65 | Download link contents"; |
66 | #endif |
66 | #endif |
67 | 67 | ||
68 | 68 | ||
69 | #define URL_SERVICE_HISTORY "WebView://history" |
69 | #define URL_SERVICE_HISTORY "WebView://history" |
70 | #define URL_SERVICE_HOMEPAGE "WebView://home" |
70 | #define URL_SERVICE_HOMEPAGE "WebView://home" |
71 | #define URL_SERVICE_HELP "WebView://help" |
71 | #define URL_SERVICE_HELP "WebView://help" |
72 | #define URL_SERVICE_SOURCE "WebView://source:" |
72 | #define URL_SERVICE_SOURCE "WebView://source:" |
73 | 73 | ||
74 | proc_info Form; |
74 | proc_info Form; |
75 | 75 | ||
76 | //char search_path[]="http://nigma.ru/index.php?s="; |
76 | //char search_path[]="http://nigma.ru/index.php?s="; |
77 | int redirected = 0; |
77 | int redirected = 0; |
78 | 78 | ||
79 | char stak[4096]; |
79 | char stak[4096]; |
80 | 80 | ||
81 | int action_buf; |
81 | int action_buf; |
82 | 82 | ||
83 | dword TOOLBAR_H = 40; |
83 | dword TOOLBAR_H = 40; |
84 | dword STATUSBAR_H = 15; |
84 | dword STATUSBAR_H = 15; |
85 | 85 | ||
86 | dword col_bg = 0xE3E2E2; |
86 | dword col_bg = 0xE3E2E2; |
87 | dword panel_color = 0xE3E2E2; |
87 | dword panel_color = 0xE3E2E2; |
88 | dword border_color = 0x8C8C8C; |
88 | dword border_color = 0x8C8C8C; |
89 | 89 | ||
90 | bool debug_mode = false; |
90 | bool debug_mode = false; |
91 | bool old_tag_parser_mode = false; |
- | |
92 | 91 | ||
93 | progress_bar wv_progress_bar; |
92 | progress_bar wv_progress_bar; |
94 | bool souce_mode = false; |
93 | bool souce_mode = false; |
95 | bool open_in_a_new_window = false; |
94 | bool open_in_a_new_window = false; |
96 | 95 | ||
97 | enum { |
96 | enum { |
98 | BACK_BUTTON=1000, |
97 | BACK_BUTTON=1000, |
99 | FORWARD_BUTTON, |
98 | FORWARD_BUTTON, |
100 | REFRESH_BUTTON, |
99 | REFRESH_BUTTON, |
101 | GOTOURL_BUTTON, |
100 | GOTOURL_BUTTON, |
102 | SANDWICH_BUTTON, |
101 | SANDWICH_BUTTON, |
103 | VIEW_SOURCE=1100, |
102 | VIEW_SOURCE=1100, |
104 | EDIT_SOURCE, |
103 | EDIT_SOURCE, |
105 | VIEW_HISTORY, |
104 | VIEW_HISTORY, |
106 | //FREE_IMG_CACHE, |
105 | //FREE_IMG_CACHE, |
107 | DOWNLOAD_MANAGER, |
106 | DOWNLOAD_MANAGER, |
108 | COPY_LINK_URL=1200, |
107 | COPY_LINK_URL=1200, |
109 | DOWNLOAD_LINK_CONTENTS, |
108 | DOWNLOAD_LINK_CONTENTS, |
110 | }; |
109 | }; |
111 | 110 | ||
112 | #include "..\TWB\TWB.c" |
111 | #include "..\TWB\TWB.c" |
113 | #include "history.h" |
112 | #include "history.h" |
114 | #include "show_src.h" |
113 | #include "show_src.h" |
115 | #include "download_manager.h" |
114 | #include "download_manager.h" |
116 | 115 | ||
117 | char editURL[sizeof(URL)]; |
116 | char editURL[sizeof(URL)]; |
118 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,2,19,19}; |
117 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,NULL,19,19}; |
119 | 118 | ||
120 | #define SKIN_Y 24 |
119 | #define SKIN_Y 24 |
121 | 120 | ||
122 | void main() |
121 | void main() |
123 | { |
122 | { |
124 | int i; |
123 | int i; |
125 | load_dll(boxlib, #box_lib_init,0); |
124 | load_dll(boxlib, #box_lib_init,0); |
126 | load_dll(libio, #libio_init,1); |
125 | load_dll(libio, #libio_init,1); |
127 | load_dll(libimg, #libimg_init,1); |
126 | load_dll(libimg, #libimg_init,1); |
128 | load_dll(libHTTP, #http_lib_init,1); |
127 | load_dll(libHTTP, #http_lib_init,1); |
129 | load_dll(iconv_lib, #iconv_open,0); |
128 | load_dll(iconv_lib, #iconv_open,0); |
130 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
129 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
131 | skin.h = 26; |
130 | skin.h = 26; |
132 | wv_progress_bar.progress_color = 0x72B7EB; |
131 | wv_progress_bar.progress_color = 0x72B7EB; |
133 | CreateDir("/tmp0/1/downloads"); |
132 | CreateDir("/tmp0/1/downloads"); |
134 | if (param) && (param[0]=='-') && (param[1]=='d') { |
133 | if (param) && (param[0]=='-') && (param[1]=='d') { |
135 | strcpy(#downloader_edit, #param+3); |
134 | strcpy(#downloader_edit, #param+3); |
136 | CreateThread(#Downloader,#downloader_stak+4092); |
135 | CreateThread(#Downloader,#downloader_stak+4092); |
137 | ExitProcess(); |
136 | ExitProcess(); |
138 | } |
137 | } |
139 | else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOMEPAGE); |
138 | else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOMEPAGE); |
140 | WB1.list.SetFont(8, 14, 10011000b); |
139 | WB1.list.SetFont(8, 14, 10011000b); |
141 | WB1.list.no_selection = true; |
140 | WB1.list.no_selection = true; |
142 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
141 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
143 | loop() switch(WaitEvent()) |
142 | loop() switch(WaitEvent()) |
144 | { |
143 | { |
145 | case evMouse: |
144 | case evMouse: |
146 | edit_box_mouse stdcall (#address_box); |
145 | edit_box_mouse stdcall (#address_box); |
147 | mouse.get(); |
146 | mouse.get(); |
148 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y)) |
147 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y)) |
149 | && (bufsize) && (mouse.pkm) && (mouse.up) { |
148 | && (bufsize) && (mouse.pkm) && (mouse.up) { |
150 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
149 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
151 | break; |
150 | break; |
152 | } |
151 | } |
153 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
152 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
154 | scrollbar_v_mouse (#scroll_wv); |
153 | scrollbar_v_mouse (#scroll_wv); |
155 | if (WB1.list.first != scroll_wv.position) |
154 | if (WB1.list.first != scroll_wv.position) |
156 | { |
155 | { |
157 | WB1.list.first = scroll_wv.position; |
156 | WB1.list.first = scroll_wv.position; |
158 | WB1.DrawPage(); |
157 | WB1.DrawPage(); |
159 | break; |
158 | break; |
160 | } |
159 | } |
161 | break; |
160 | break; |
162 | 161 | ||
163 | case evButton: |
162 | case evButton: |
164 | ProcessEvent(GetButtonID()); |
163 | ProcessEvent(GetButtonID()); |
165 | break; |
164 | break; |
166 | 165 | ||
167 | case evKey: |
166 | case evKey: |
168 | GetKeys(); |
167 | GetKeys(); |
169 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
168 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
170 | if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY); |
169 | if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY); |
171 | if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE); |
170 | if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE); |
172 | if (key_scancode == SCAN_CODE_KEY_T) |
171 | if (key_scancode == SCAN_CODE_KEY_T) |
173 | || (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL); |
172 | || (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL); |
174 | if (key_scancode == SCAN_CODE_KEY_W) ExitProcess(); |
173 | if (key_scancode == SCAN_CODE_KEY_W) ExitProcess(); |
175 | if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER); |
174 | if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER); |
176 | if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON); |
175 | if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON); |
177 | if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb(); |
176 | if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb(); |
178 | if (key_scancode == SCAN_CODE_LEFT) ProcessEvent(BACK_BUTTON); |
177 | if (key_scancode == SCAN_CODE_LEFT) ProcessEvent(BACK_BUTTON); |
179 | if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON); |
178 | if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON); |
180 | } |
179 | } |
181 | 180 | ||
182 | if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON); |
181 | if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON); |
183 | 182 | ||
184 | if (address_box.flags & ed_focus) |
183 | if (address_box.flags & ed_focus) |
185 | { |
184 | { |
186 | if (key_scancode == SCAN_CODE_ENTER) { |
185 | if (key_scancode == SCAN_CODE_ENTER) { |
187 | ProcessEvent(key_scancode); |
186 | ProcessEvent(key_scancode); |
188 | } |
187 | } |
189 | else { |
188 | else { |
190 | EAX = key_editbox; |
189 | EAX = key_editbox; |
191 | edit_box_key stdcall(#address_box); |
190 | edit_box_key stdcall(#address_box); |
192 | } |
191 | } |
193 | } |
192 | } |
194 | else |
193 | else |
195 | { |
194 | { |
196 | #define KEY_SCROLL_N 11 |
195 | #define KEY_SCROLL_N 11 |
197 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
196 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
198 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
197 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
199 | if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();} |
198 | if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();} |
200 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
199 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
201 | else ProcessEvent(key_scancode); |
200 | else ProcessEvent(key_scancode); |
202 | } |
201 | } |
203 | break; |
202 | break; |
204 | 203 | ||
205 | case evReDraw: |
204 | case evReDraw: |
206 | if (menu.cur_y) { |
205 | if (menu.cur_y) { |
207 | ProcessEvent(menu.cur_y); |
206 | ProcessEvent(menu.cur_y); |
208 | menu.cur_y = 0; |
207 | menu.cur_y = 0; |
209 | } |
208 | } |
210 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0); |
209 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0); |
211 | GetProcessInfo(#Form, SelfInfo); |
210 | GetProcessInfo(#Form, SelfInfo); |
212 | if (Form.status_window>2) { DrawTitle(#header); break; } |
211 | if (Form.status_window>2) { DrawTitle(#header); break; } |
213 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
212 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
214 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
213 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
215 | Draw_Window(); |
214 | Draw_Window(); |
216 | break; |
215 | break; |
217 | 216 | ||
218 | case evNetwork: |
217 | case evNetwork: |
219 | if (http.transfer > 0) { |
218 | if (http.transfer > 0) { |
220 | http.receive(); |
219 | http.receive(); |
221 | EventUpdateProgressBar(); |
220 | EventUpdateProgressBar(); |
222 | if (http.receive_result == 0) { |
221 | if (http.receive_result == 0) { |
223 | // Handle redirects |
222 | // Handle redirects |
224 | if (http.status_code >= 300) && (http.status_code < 400) |
223 | if (http.status_code >= 300) && (http.status_code < 400) |
225 | { |
224 | { |
226 | redirected++; |
225 | redirected++; |
227 | if (redirected>5) |
226 | if (redirected>5) |
228 | { |
227 | { |
229 | notify("'Too many redirects.' -E"); |
228 | notify("'Too many redirects.' -E"); |
230 | StopLoading(); |
229 | StopLoading(); |
231 | } |
230 | } |
232 | else |
231 | else |
233 | { |
232 | { |
234 | http.handle_redirect(); |
233 | http.handle_redirect(); |
235 | http.free(); |
234 | http.free(); |
236 | GetAbsoluteURL(#http.redirect_url); |
235 | GetAbsoluteURL(#http.redirect_url); |
237 | history.back(); |
236 | history.back(); |
238 | strcpy(#editURL, #URL); |
237 | strcpy(#editURL, #URL); |
239 | DrawOmnibox(); |
238 | DrawOmnibox(); |
240 | OpenPage(); |
239 | OpenPage(); |
241 | //ProcessLink(history.current()); |
240 | //ProcessLink(history.current()); |
242 | } |
241 | } |
243 | break; |
242 | break; |
244 | } |
243 | } |
245 | redirected = 0; |
244 | redirected = 0; |
246 | // Loading the page is complete, free resources |
245 | // Loading the page is complete, free resources |
247 | history.add(#URL); |
246 | history.add(#URL); |
248 | bufpointer = http.content_pointer; |
247 | bufpointer = http.content_pointer; |
249 | bufsize = http.content_received; |
248 | bufsize = http.content_received; |
250 | http.free(); |
249 | http.free(); |
251 | SetPageDefaults(); |
250 | SetPageDefaults(); |
252 | ShowPage(); |
251 | ShowPage(); |
253 | } |
252 | } |
254 | } |
253 | } |
255 | } |
254 | } |
256 | } |
255 | } |
257 | 256 | ||
258 | void SetElementSizes() |
257 | void SetElementSizes() |
259 | { |
258 | { |
260 | address_box.top = TOOLBAR_H/2-10; |
259 | address_box.top = TOOLBAR_H/2-10; |
261 | basic_line_h = calc(WB1.list.font_h * 130) / 100; |
260 | basic_line_h = calc(WB1.list.font_h * 130) / 100; |
262 | address_box.width = Form.cwidth - address_box.left - 50; |
261 | address_box.width = Form.cwidth - address_box.left - 50; |
263 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
262 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
264 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
263 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
265 | WB1.list.wheel_size = 7 * basic_line_h; |
264 | WB1.list.wheel_size = 7 * basic_line_h; |
266 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
265 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
267 | WB1.list.visible = WB1.list.h; |
266 | WB1.list.visible = WB1.list.h; |
268 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
267 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
269 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20); |
268 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20); |
270 | ProcessEvent(REFRESH_BUTTON); |
269 | ProcessEvent(REFRESH_BUTTON); |
271 | } |
270 | } |
272 | } |
271 | } |
273 | 272 | ||
274 | 273 | ||
275 | 274 | ||
276 | void Draw_Window() |
275 | void Draw_Window() |
277 | { |
276 | { |
278 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
277 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
279 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
278 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
280 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
279 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
281 | SetElementSizes(); |
280 | SetElementSizes(); |
282 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color); |
281 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color); |
283 | DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
282 | DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
284 | DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
283 | DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
285 | img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 0, SKIN_Y); |
284 | img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 0, SKIN_Y); |
286 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
285 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
287 | DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
286 | DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
288 | img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y); |
287 | img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y); |
289 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
288 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
290 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
289 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
291 | if (!header) |
290 | if (!header) |
292 | OpenPage(); |
291 | OpenPage(); |
293 | else { |
292 | else { |
294 | WB1.DrawPage(); |
293 | WB1.DrawPage(); |
295 | DrawOmnibox(); |
294 | DrawOmnibox(); |
296 | } |
295 | } |
297 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
296 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
298 | DrawProgress(); |
297 | DrawProgress(); |
299 | } |
298 | } |
300 | 299 | ||
301 | 300 | ||
302 | void ProcessEvent(dword id__) |
301 | void ProcessEvent(dword id__) |
303 | { |
302 | { |
304 | switch (id__) |
303 | switch (id__) |
305 | { |
304 | { |
306 | case 1: |
305 | case 1: |
307 | ExitProcess(); |
306 | ExitProcess(); |
308 | return; |
307 | return; |
309 | case SCAN_CODE_BS: |
308 | case SCAN_CODE_BS: |
310 | case BACK_BUTTON: |
309 | case BACK_BUTTON: |
311 | if (history.back()) { |
310 | if (history.back()) { |
312 | strcpy(#URL, history.current()); |
311 | strcpy(#URL, history.current()); |
313 | OpenPage(); |
312 | OpenPage(); |
314 | } |
313 | } |
315 | return; |
314 | return; |
316 | case FORWARD_BUTTON: |
315 | case FORWARD_BUTTON: |
317 | if (history.forward()) { |
316 | if (history.forward()) { |
318 | strcpy(#URL, history.current()); |
317 | strcpy(#URL, history.current()); |
319 | OpenPage(); |
318 | OpenPage(); |
320 | } |
319 | } |
321 | return; |
320 | return; |
322 | case GOTOURL_BUTTON: |
321 | case GOTOURL_BUTTON: |
323 | case SCAN_CODE_ENTER: |
322 | case SCAN_CODE_ENTER: |
324 | EventSubmitOmnibox(); |
323 | EventSubmitOmnibox(); |
325 | return; |
324 | return; |
326 | case REFRESH_BUTTON: |
325 | case REFRESH_BUTTON: |
327 | if (http.transfer > 0) |
326 | if (http.transfer > 0) |
328 | { |
327 | { |
329 | StopLoading(); |
328 | StopLoading(); |
330 | Draw_Window(); |
329 | Draw_Window(); |
331 | } |
330 | } |
332 | else OpenPage(); |
331 | else OpenPage(); |
333 | return; |
332 | return; |
334 | case SANDWICH_BUTTON: |
333 | case SANDWICH_BUTTON: |
335 | EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); |
334 | EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); |
336 | return; |
335 | return; |
337 | case VIEW_SOURCE: |
336 | case VIEW_SOURCE: |
338 | WB1.list.first = 0; |
337 | WB1.list.first = 0; |
339 | ShowSource(); |
338 | ShowSource(); |
340 | WB1.LoadInternalPage(bufpointer, bufsize); |
339 | WB1.LoadInternalPage(bufpointer, bufsize); |
341 | break; |
340 | break; |
342 | case EDIT_SOURCE: |
341 | case EDIT_SOURCE: |
343 | if (!strncmp(#URL,"http",4)) |
342 | if (!strncmp(#URL,"http",4)) |
344 | { |
343 | { |
345 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
344 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
346 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
345 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
347 | } |
346 | } |
348 | else RunProgram("/rd/1/tinypad", #URL); |
347 | else RunProgram("/rd/1/tinypad", #URL); |
349 | return; |
348 | return; |
350 | // case FREE_IMG_CACHE: |
349 | // case FREE_IMG_CACHE: |
351 | // ImgCache.Free(); |
350 | // ImgCache.Free(); |
352 | // notify(IMAGES_CACHE_CLEARED); |
351 | // notify(IMAGES_CACHE_CLEARED); |
353 | // WB1.DrawPage(); |
352 | // WB1.DrawPage(); |
354 | // return; |
353 | // return; |
355 | case VIEW_HISTORY: |
354 | case VIEW_HISTORY: |
356 | strcpy(#URL, URL_SERVICE_HISTORY); |
355 | strcpy(#URL, URL_SERVICE_HISTORY); |
357 | OpenPage(); |
356 | OpenPage(); |
358 | return; |
357 | return; |
359 | case DOWNLOAD_MANAGER: |
358 | case DOWNLOAD_MANAGER: |
360 | if (!downloader_opened) { |
359 | if (!downloader_opened) { |
361 | downloader_edit = NULL; |
360 | downloader_edit = NULL; |
362 | CreateThread(#Downloader,#downloader_stak+4092); |
361 | CreateThread(#Downloader,#downloader_stak+4092); |
363 | } |
362 | } |
364 | return; |
363 | return; |
365 | case COPY_LINK_URL: |
364 | case COPY_LINK_URL: |
366 | Clipboard__CopyText(PageLinks.GetURL(PageLinks.active)); |
365 | Clipboard__CopyText(PageLinks.GetURL(PageLinks.active)); |
367 | notify("'URL copied to clipboard'O"); |
366 | notify("'URL copied to clipboard'O"); |
368 | return; |
367 | return; |
369 | case DOWNLOAD_LINK_CONTENTS: |
368 | case DOWNLOAD_LINK_CONTENTS: |
370 | if (!downloader_opened) { |
369 | if (!downloader_opened) { |
371 | strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active)); |
370 | strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active)); |
372 | CreateThread(#Downloader,#downloader_stak+4092); |
371 | CreateThread(#Downloader,#downloader_stak+4092); |
373 | } |
372 | } |
374 | return; |
373 | return; |
375 | case SCAN_CODE_F12: |
374 | case SCAN_CODE_F12: |
376 | debug_mode ^= 1; |
375 | debug_mode ^= 1; |
377 | if (debug_mode) notify("'Debug mode ON'-I"); |
376 | if (debug_mode) notify("'Debug mode ON'-I"); |
378 | else notify("'Debug mode OFF'-I"); |
377 | else notify("'Debug mode OFF'-I"); |
379 | return; |
378 | return; |
380 | case SCAN_CODE_F11: |
- | |
381 | old_tag_parser_mode ^= 1; |
- | |
382 | if (old_tag_parser_mode) notify("'Old tag parser ON'-I"); |
- | |
383 | else notify("'Old tag parser OFF'-I"); |
- | |
384 | return; |
- | |
385 | } |
379 | } |
386 | } |
380 | } |
387 | 381 | ||
388 | void StopLoading() |
382 | void StopLoading() |
389 | { |
383 | { |
390 | if (http.transfer) |
384 | if (http.transfer) |
391 | { |
385 | { |
392 | EAX = http.transfer; |
386 | EAX = http.transfer; |
393 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
387 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
394 | $push EAX // save it on the stack |
388 | $push EAX // save it on the stack |
395 | http_free stdcall (http.transfer); // abort connection |
389 | http_free stdcall (http.transfer); // abort connection |
396 | $pop EAX |
390 | $pop EAX |
397 | free(EAX); // free data |
391 | free(EAX); // free data |
398 | http.transfer=0; |
392 | http.transfer=0; |
399 | bufsize = 0; |
393 | bufsize = 0; |
400 | bufpointer = free(bufpointer); |
394 | bufpointer = free(bufpointer); |
- | 395 | pause(10); |
|
401 | } |
396 | } |
402 | wv_progress_bar.value = 0; |
397 | wv_progress_bar.value = 0; |
403 | DrawOmnibox(); |
398 | DrawOmnibox(); |
404 | } |
399 | } |
405 | 400 | ||
406 | void SetPageDefaults() |
401 | void SetPageDefaults() |
407 | { |
402 | { |
408 | strcpy(#header, #version); |
403 | strcpy(#header, #version); |
409 | WB1.list.count = WB1.list.first = 0; |
404 | WB1.list.count = WB1.list.first = 0; |
410 | cur_encoding = CH_NULL; |
405 | cur_encoding = CH_NULL; |
411 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
406 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
412 | } |
407 | } |
413 | 408 | ||
414 | void ReplaceSpaceInUrl() { |
409 | void ReplaceSpaceInUrl() { |
415 | int i; |
410 | int i; |
416 | strcpy(#editURL, #URL); |
411 | strcpy(#editURL, #URL); |
417 | while (i = strchr(#URL, ' ')) |
412 | while (i = strchr(#URL, ' ')) |
418 | { |
413 | { |
419 | i -= #URL; |
414 | i -= #URL; |
420 | strlcpy(#URL+i+3, #editURL+i+1, sizeof(URL)-i-4); |
415 | strlcpy(#URL+i+3, #editURL+i+1, sizeof(URL)-i-4); |
421 | URL[i] = '%'; |
416 | URL[i] = '%'; |
422 | URL[i+1] = '2'; |
417 | URL[i+1] = '2'; |
423 | URL[i+2] = '0'; |
418 | URL[i+2] = '0'; |
424 | } |
419 | } |
425 | strcpy(#editURL, #URL); |
420 | strcpy(#editURL, #URL); |
426 | } |
421 | } |
427 | 422 | ||
428 | void OpenPage() |
423 | void OpenPage() |
429 | { |
424 | { |
430 | char getUrl[sizeof(URL)]; |
425 | char getUrl[sizeof(URL)]; |
431 | StopLoading(); |
426 | StopLoading(); |
432 | souce_mode = false; |
427 | souce_mode = false; |
433 | strcpy(#editURL, #URL); |
428 | strcpy(#editURL, #URL); |
434 | history.add(#URL); |
429 | history.add(#URL); |
435 | if (!strncmp(#URL,"WebView:",8)) |
430 | if (!strncmp(#URL,"WebView:",8)) |
436 | { |
431 | { |
437 | SetPageDefaults(); |
432 | SetPageDefaults(); |
438 | if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage)); |
433 | if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage)); |
439 | else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help)); |
434 | else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help)); |
440 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
435 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
441 | else {bufsize=0; ShowPage();} //page not found |
436 | else {bufsize=0; ShowPage();} //page not found |
442 | DrawOmnibox(); |
437 | DrawOmnibox(); |
443 | return; |
438 | return; |
444 | } |
439 | } |
445 | if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8)) |
440 | if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8)) |
446 | { |
441 | { |
447 | ReplaceSpaceInUrl(); |
442 | ReplaceSpaceInUrl(); |
448 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y); |
443 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y); |
449 | 444 | ||
450 | if (!strncmp(#URL,"http:",5)) { |
445 | if (!strncmp(#URL,"http:",5)) { |
451 | http.get(#URL); |
446 | http.get(#URL); |
452 | } |
447 | } |
453 | if (!strncmp(#URL,"https://",8)) { |
448 | if (!strncmp(#URL,"https://",8)) { |
454 | sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL); |
449 | sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL); |
455 | http.get(#getUrl); |
450 | http.get(#getUrl); |
456 | } |
451 | } |
457 | //http.get(#URL); |
452 | //http.get(#URL); |
458 | if (!http.transfer) |
453 | if (!http.transfer) |
459 | { |
454 | { |
460 | StopLoading(); |
455 | StopLoading(); |
461 | bufsize = 0; |
456 | bufsize = 0; |
462 | bufpointer = free(bufpointer); |
457 | bufpointer = free(bufpointer); |
463 | ShowPage(); |
458 | ShowPage(); |
464 | return; |
459 | return; |
465 | } |
460 | } |
466 | } |
461 | } |
467 | else |
462 | else |
468 | { |
463 | { |
469 | file_size stdcall (#URL); |
464 | file_size stdcall (#URL); |
470 | if (EBX) |
465 | if (EBX) |
471 | { |
466 | { |
472 | bufsize = EBX; |
467 | bufsize = EBX; |
473 | free(bufpointer); |
468 | free(bufpointer); |
474 | bufpointer = malloc(bufsize); |
469 | bufpointer = malloc(bufsize); |
475 | SetPageDefaults(); |
470 | SetPageDefaults(); |
476 | ReadFile(0, bufsize, bufpointer, #URL); |
471 | ReadFile(0, bufsize, bufpointer, #URL); |
477 | } |
472 | } |
478 | ShowPage(); |
473 | ShowPage(); |
479 | } |
474 | } |
480 | } |
475 | } |
481 | 476 | ||
482 | void ProcessAnchor() |
477 | void ProcessAnchor() |
483 | { |
478 | { |
484 | char anchor[256]; |
479 | char anchor[256]; |
485 | int anchor_pos; |
480 | int anchor_pos; |
486 | 481 | ||
487 | anchor_pos = strrchr(#URL, '#')-1; |
482 | anchor_pos = strrchr(#URL, '#')-1; |
488 | strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)); |
483 | strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)); |
489 | URL[anchor_pos] = 0x00; |
484 | URL[anchor_pos] = 0x00; |
490 | 485 | ||
491 | //#1 |
486 | //#1 |
492 | if (URL[0] == NULL) |
487 | if (URL[0] == NULL) |
493 | { |
488 | { |
494 | if (anchor[1] == NULL) { |
489 | if (anchor[1] == NULL) { |
495 | WB1.list.first = 0; |
490 | WB1.list.first = 0; |
496 | } |
491 | } |
497 | else { |
492 | else { |
498 | if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
493 | if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
499 | } |
494 | } |
500 | strcpy(#URL, history.current()); |
495 | strcpy(#URL, history.current()); |
501 | } |
496 | } |
502 | //liner.ru#1 |
497 | //liner.ru#1 |
503 | else |
498 | else |
504 | { |
499 | { |
505 | GetAbsoluteURL(#URL); |
500 | GetAbsoluteURL(#URL); |
506 | OpenPage(); |
501 | OpenPage(); |
507 | if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
502 | if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
508 | } |
503 | } |
509 | 504 | ||
510 | WB1.DrawPage(); |
505 | WB1.DrawPage(); |
511 | strcpy(#editURL, #URL); |
506 | strcpy(#editURL, #URL); |
512 | strcat(#editURL, #anchor); |
507 | strcat(#editURL, #anchor); |
513 | DrawOmnibox(); |
508 | DrawOmnibox(); |
514 | } |
509 | } |
515 | 510 | ||
516 | void EventSubmitOmnibox() |
511 | void EventSubmitOmnibox() |
517 | { |
512 | { |
518 | if (!editURL[0]) return; |
513 | if (!editURL[0]) return; |
519 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
514 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
520 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) |
515 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) |
521 | { |
516 | { |
522 | strcpy(#URL, #editURL); |
517 | strcpy(#URL, #editURL); |
523 | } |
518 | } |
524 | else |
519 | else |
525 | { |
520 | { |
526 | strlcpy(#URL,"http://",7); |
521 | strlcpy(#URL,"http://",7); |
527 | strcat(#URL, #editURL); |
522 | strcat(#URL, #editURL); |
528 | } |
523 | } |
529 | ProcessLink(); |
524 | ProcessLink(); |
530 | } |
525 | } |
531 | 526 | ||
532 | void EventClickLink() |
527 | void EventClickLink() |
533 | { |
528 | { |
534 | strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
529 | strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
535 | GetAbsoluteURL(#URL); |
530 | GetAbsoluteURL(#URL); |
536 | ProcessLink(); |
531 | ProcessLink(); |
537 | } |
532 | } |
538 | 533 | ||
539 | void ProcessLink() |
534 | void ProcessLink() |
540 | { |
535 | { |
541 | if (http.transfer > 0) |
536 | if (http.transfer > 0) |
542 | { |
537 | { |
543 | StopLoading(); |
538 | StopLoading(); |
544 | history.back(); |
539 | history.back(); |
545 | } |
540 | } |
546 | 541 | ||
547 | if (strrchr(#URL, '#')!=0) { |
542 | if (strrchr(#URL, '#')!=0) { |
548 | ProcessAnchor(); |
543 | ProcessAnchor(); |
549 | return; |
544 | return; |
550 | } |
545 | } |
551 | 546 | ||
552 | if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4)) |
547 | if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4)) |
553 | { |
548 | { |
554 | notify(#URL); |
549 | notify(#URL); |
555 | strcpy(#editURL, history.current()); |
550 | strcpy(#editURL, history.current()); |
556 | strcpy(#URL, history.current()); |
551 | strcpy(#URL, history.current()); |
557 | return; |
552 | return; |
558 | } |
553 | } |
559 | 554 | ||
560 | if (!strncmp(#URL,"WebView:",8)) { |
555 | if (!strncmp(#URL,"WebView:",8)) { |
561 | OpenPage(); |
556 | OpenPage(); |
562 | return; |
557 | return; |
563 | } |
558 | } |
564 | 559 | ||
565 | if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0) |
560 | if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0) |
566 | { |
561 | { |
567 | if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true) |
562 | if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true) |
568 | { |
563 | { |
569 | if (strchr(#URL, '|')) { |
564 | if (strchr(#URL, '|')) { |
570 | ESBYTE[strchr(#URL, '|')] = NULL; |
565 | ESBYTE[strchr(#URL, '|')] = NULL; |
571 | RunProgram(#URL, strlen(#URL)+1+#URL); |
566 | RunProgram(#URL, strlen(#URL)+1+#URL); |
572 | } |
567 | } |
573 | else { |
568 | else { |
574 | RunProgram("/sys/@open", #URL); |
569 | RunProgram("/sys/@open", #URL); |
575 | } |
570 | } |
576 | strcpy(#editURL, history.current()); |
571 | strcpy(#editURL, history.current()); |
577 | strcpy(#URL, history.current()); |
572 | strcpy(#URL, history.current()); |
578 | return; |
573 | return; |
579 | } |
574 | } |
580 | } |
575 | } |
581 | else |
576 | else |
582 | { |
577 | { |
583 | if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true) |
578 | if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true) |
584 | || (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true) |
579 | || (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true) |
585 | || (UrlExtIs(".7z")==true) { |
580 | || (UrlExtIs(".7z")==true) { |
586 | if (!downloader_opened) { |
581 | if (!downloader_opened) { |
587 | strcpy(#downloader_edit, #URL); |
582 | strcpy(#downloader_edit, #URL); |
588 | CreateThread(#Downloader,#downloader_stak+4092); |
583 | CreateThread(#Downloader,#downloader_stak+4092); |
589 | strcpy(#editURL, history.current()); |
584 | strcpy(#editURL, history.current()); |
590 | strcpy(#URL, history.current()); |
585 | strcpy(#URL, history.current()); |
591 | } |
586 | } |
592 | else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); |
587 | else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); |
593 | return; |
588 | return; |
594 | } |
589 | } |
595 | } |
590 | } |
596 | if (open_in_a_new_window) |
591 | if (open_in_a_new_window) |
597 | { |
592 | { |
598 | RunProgram(#program_path, #URL); |
593 | RunProgram(#program_path, #URL); |
599 | strcpy(#editURL, history.current()); |
594 | strcpy(#editURL, history.current()); |
600 | strcpy(#URL, history.current()); |
595 | strcpy(#URL, history.current()); |
601 | } |
596 | } |
602 | else |
597 | else |
603 | { |
598 | { |
604 | OpenPage(); |
599 | OpenPage(); |
605 | } |
600 | } |
606 | open_in_a_new_window = false; |
601 | open_in_a_new_window = false; |
607 | } |
602 | } |
608 | 603 | ||
609 | void DrawOmnibox() |
604 | void DrawOmnibox() |
610 | { |
605 | { |
611 | int skin_x_offset; |
606 | int skin_x_offset; |
612 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
607 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
613 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
608 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
614 | //address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
609 | //address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
615 | //address_box.offset = 0; |
610 | //address_box.offset = 0; |
616 | EditBox_UpdateText(#address_box, address_box.flags); |
611 | EditBox_UpdateText(#address_box, address_box.flags); |
617 | edit_box_draw stdcall(#address_box); |
612 | edit_box_draw stdcall(#address_box); |
618 | if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51; |
613 | if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51; |
619 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
614 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
620 | } |
615 | } |
621 | 616 | ||
622 | 617 | ||
623 | void ShowPage() |
618 | void ShowPage() |
624 | { |
619 | { |
625 | DrawOmnibox(); |
620 | DrawOmnibox(); |
626 | if (!bufsize) |
621 | if (!bufsize) |
627 | { |
622 | { |
628 | if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
623 | if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
629 | else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
624 | else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
630 | } |
625 | } |
631 | else |
626 | else |
632 | { |
627 | { |
633 | WB1.Prepare(); |
628 | WB1.Prepare(); |
634 | } |
629 | } |
635 | } |
630 | } |
636 | 631 | ||
637 | byte UrlExtIs(dword ext) |
632 | byte UrlExtIs(dword ext) |
638 | { |
633 | { |
639 | if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
634 | if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
640 | return false; |
635 | return false; |
641 | } |
636 | } |
642 | 637 | ||
643 | void DrawProgress() |
638 | void DrawProgress() |
644 | { |
639 | { |
645 | dword persent; |
640 | dword persent; |
646 | if (http.transfer == 0) return; |
641 | if (http.transfer == 0) return; |
647 | if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; |
642 | if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; |
648 | DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color); |
643 | DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color); |
649 | } |
644 | } |
650 | 645 | ||
651 | void EventShowPageMenu(dword _left, _top) |
646 | void EventShowPageMenu(dword _left, _top) |
652 | { |
647 | { |
653 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); |
648 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); |
654 | } |
649 | } |
655 | 650 | ||
656 | void EventShowLinkMenu(dword _left, _top) |
651 | void EventShowLinkMenu(dword _left, _top) |
657 | { |
652 | { |
658 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL); |
653 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL); |
659 | } |
654 | } |
660 | 655 | ||
661 | void EventUpdateProgressBar() |
656 | void EventUpdateProgressBar() |
662 | { |
657 | { |
663 | wv_progress_bar.max = http.content_length; |
658 | wv_progress_bar.max = http.content_length; |
664 | if (wv_progress_bar.value != http.content_received) |
659 | if (wv_progress_bar.value != http.content_received) |
665 | { |
660 | { |
666 | wv_progress_bar.value = http.content_received; |
661 | wv_progress_bar.value = http.content_received; |
667 | DrawProgress(); |
662 | DrawProgress(); |
668 | } |
663 | } |
669 | } |
664 | } |
670 | 665 | ||
671 | void EventSeachWeb() |
666 | void EventSeachWeb() |
672 | { |
667 | { |
673 | sprintf(#URL, "https://www.google.com/search?q=%s", #editURL); |
668 | sprintf(#URL, "https://www.google.com/search?q=%s", #editURL); |
674 | ProcessLink(); |
669 | ProcessLink(); |
675 | } |
670 | } |
676 | 671 | ||
677 | void DrawStatusBar(dword _status_text) |
672 | void DrawStatusBar(dword _status_text) |
678 | { |
673 | { |
679 | status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10; |
674 | status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10; |
680 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
675 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
681 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
676 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
682 | DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg); |
677 | DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg); |
683 | status_text.text_pointer = _status_text; |
678 | status_text.text_pointer = _status_text; |
684 | PathShow_prepare stdcall(#status_text); |
679 | PathShow_prepare stdcall(#status_text); |
685 | PathShow_draw stdcall(#status_text); |
680 | PathShow_draw stdcall(#status_text); |
686 | } |
681 | } |
687 | 682 | ||
688 | stop:>280)>120)> |
683 | stop:>280)>120)> |