Rev 8278 | Rev 8292 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7739 | leency | 1 | //Copyright 2007-2020 by Veliant & Leency |
6978 | leency | 2 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
3067 | leency | 3 | |
4085 | leency | 4 | #ifndef AUTOBUILD |
5 | #include "lang.h--" |
||
6 | #endif |
||
7 | |||
3107 | leency | 8 | //libraries |
7771 | leency | 9 | #define MEMSIZE 1024 * 1000 |
5499 | leency | 10 | #include "..\lib\gui.h" |
4508 | leency | 11 | #include "..\lib\draw_buf.h" |
12 | #include "..\lib\list_box.h" |
||
13 | #include "..\lib\cursor.h" |
||
5978 | leency | 14 | #include "..\lib\collection.h" |
6795 | leency | 15 | #include "..\lib\random.h" |
7037 | leency | 16 | #include "..\lib\clipboard.h" |
5981 | leency | 17 | |
7437 | leency | 18 | // *.obj libraries |
5499 | leency | 19 | #include "..\lib\obj\box_lib.h" |
7049 | leency | 20 | #include "..\lib\obj\libio.h" |
21 | #include "..\lib\obj\libimg.h" |
||
5499 | leency | 22 | #include "..\lib\obj\http.h" |
5690 | leency | 23 | #include "..\lib\obj\iconv.h" |
7748 | leency | 24 | #include "..\lib\obj\proc_lib.h" |
7757 | leency | 25 | |
5408 | leency | 26 | //useful patterns |
5978 | leency | 27 | #include "..\lib\patterns\history.h" |
6058 | leency | 28 | #include "..\lib\patterns\http_downloader.h" |
7748 | leency | 29 | #include "..\lib\patterns\simple_open_dialog.h" |
7759 | leency | 30 | #include "..\lib\patterns\toolbar_button.h" |
7914 | leency | 31 | #include "..\lib\patterns\restart_process.h" |
5408 | leency | 32 | |
8278 | leency | 33 | char editbox_icons[] = FROM "res/editbox_icons.raw"; |
34 | |||
8016 | leency | 35 | #define URL_SIZE 4000 |
36 | |||
8291 | leency | 37 | char version[]="WebView 2.7"; |
8016 | leency | 38 | |
7771 | leency | 39 | #include "texts.h" |
40 | #include "cache.h" |
||
7757 | leency | 41 | #include "show_src.h" |
7771 | leency | 42 | |
7757 | leency | 43 | bool debug_mode = false; |
7771 | leency | 44 | |
7791 | leency | 45 | enum { |
46 | NEW_TAB=600, |
||
47 | ENCODINGS=700, |
||
48 | BACK_BUTTON=800, |
||
49 | FORWARD_BUTTON, |
||
50 | REFRESH_BUTTON, |
||
51 | GOTOURL_BUTTON, |
||
52 | CHANGE_ENCODING, |
||
53 | SANDWICH_BUTTON, |
||
54 | VIEW_SOURCE, |
||
55 | EDIT_SOURCE, |
||
56 | OPEN_FILE, |
||
57 | NEW_WINDOW, |
||
58 | VIEW_HISTORY, |
||
59 | DOWNLOAD_MANAGER, |
||
60 | CLEAR_CACHE, |
||
61 | UPDATE_BROWSER, |
||
62 | IN_NEW_TAB, |
||
63 | IN_NEW_WINDOW, |
||
64 | COPY_LINK_URL, |
||
65 | DOWNLOAD_LINK_CONTENTS, |
||
66 | TAB_ID, |
||
67 | TAB_CLOSE_ID = 900 |
||
68 | }; |
||
69 | |||
8016 | leency | 70 | _history history; |
71 | |||
7970 | leency | 72 | enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB }; |
73 | |||
7759 | leency | 74 | #include "..\TWB\TWB.c" //HTML Parser, a core component |
7757 | leency | 75 | |
7759 | leency | 76 | TWebBrowser WB1; |
7758 | leency | 77 | |
7771 | leency | 78 | #include "history.h" |
7752 | leency | 79 | |
7758 | leency | 80 | #define PADDING 9 |
81 | #define TSZE 25 |
||
7771 | leency | 82 | #define STATUSBAR_H 15 |
83 | #define TAB_H 20 |
||
7758 | leency | 84 | dword TOOLBAR_H = PADDING+TSZE+PADDING+2; |
4677 | leency | 85 | |
7759 | leency | 86 | _http http = 0; |
7758 | leency | 87 | |
7750 | leency | 88 | bool source_mode = false; |
7282 | leency | 89 | |
5718 | leency | 90 | progress_bar wv_progress_bar; |
7750 | leency | 91 | char stak[4096]; |
92 | proc_info Form; |
||
7748 | leency | 93 | |
7780 | leency | 94 | int menu_id=NULL; |
95 | |||
7771 | leency | 96 | #include "tabs.h" |
97 | |||
7748 | leency | 98 | char default_dir[] = "/rd/1"; |
7788 | leency | 99 | od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" }; |
7748 | leency | 100 | |
7755 | leency | 101 | char editURL[URL_SIZE+1]; |
7758 | leency | 102 | edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
103 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
||
4534 | leency | 104 | |
7914 | leency | 105 | dword shared_url; |
7784 | leency | 106 | |
8016 | leency | 107 | dword http_get_type; |
108 | |||
7748 | leency | 109 | void LoadLibraries() |
110 | { |
||
111 | load_dll(boxlib, #box_lib_init,0); |
||
112 | load_dll(libio, #libio_init,1); |
||
113 | load_dll(libimg, #libimg_init,1); |
||
114 | load_dll(libHTTP, #http_lib_init,1); |
||
115 | load_dll(iconv_lib, #iconv_open,0); |
||
116 | load_dll(Proc_lib, #OpenDialog_init,0); |
||
117 | OpenDialog_init stdcall (#o_dialog); |
||
118 | } |
||
119 | |||
120 | void HandleParam() |
||
121 | { |
||
8278 | leency | 122 | if (!param) { |
123 | history.add(URL_SERVICE_HOMEPAGE); |
||
124 | } else { |
||
125 | if (!strncmp(#param, "-source ", 8)) { |
||
7750 | leency | 126 | source_mode = true; |
7765 | leency | 127 | history.add(#param + 8); |
7936 | leency | 128 | } else if (!strncmp(#param, "-new ", 5)) { |
129 | history.add(#param + 5); |
||
7748 | leency | 130 | } else { |
7914 | leency | 131 | if (GetProcessesCount("WEBVIEW") == 1) { |
132 | history.add(#param); |
||
133 | } else { |
||
134 | shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE); |
||
135 | strncpy(shared_url, #param, URL_SIZE); |
||
136 | ExitProcess(); |
||
137 | } |
||
7748 | leency | 138 | } |
139 | } |
||
7914 | leency | 140 | shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE); |
7920 | leency | 141 | ESDWORD[shared_url] = '\0'; |
7748 | leency | 142 | } |
143 | |||
3067 | leency | 144 | void main() |
145 | { |
||
7970 | leency | 146 | int i, redirect_count=0; |
7748 | leency | 147 | LoadLibraries(); |
7764 | leency | 148 | //CreateDir("/tmp0/1/WebView_Cache"); |
7748 | leency | 149 | HandleParam(); |
6045 | leency | 150 | WB1.list.SetFont(8, 14, 10011000b); |
5779 | leency | 151 | WB1.list.no_selection = true; |
7759 | leency | 152 | WB1.custom_encoding = -1; |
6978 | leency | 153 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
7914 | leency | 154 | loop() switch(@WaitEventTimeout(30)) |
6978 | leency | 155 | { |
156 | case evMouse: |
||
157 | edit_box_mouse stdcall (#address_box); |
||
158 | mouse.get(); |
||
7970 | leency | 159 | |
7282 | leency | 160 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
7970 | leency | 161 | |
6978 | leency | 162 | scrollbar_v_mouse (#scroll_wv); |
7970 | leency | 163 | if (scroll_wv.delta) { |
6978 | leency | 164 | WB1.list.first = scroll_wv.position; |
165 | WB1.DrawPage(); |
||
3067 | leency | 166 | break; |
6978 | leency | 167 | } |
7970 | leency | 168 | |
169 | if (links.hover(WB1.list.y, WB1.list.first)) |
||
7758 | leency | 170 | { |
7970 | leency | 171 | if (mouse.mkm) { |
172 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
||
173 | EventClickLink(TARGET_NEW_WINDOW); |
||
174 | } else { |
||
175 | EventClickLink(TARGET_NEW_TAB); |
||
176 | } |
||
177 | } |
||
178 | if (mouse.lkm) { |
||
179 | CursorPointer.Restore(); |
||
180 | EventClickLink(TARGET_SAME_TAB); |
||
181 | } |
||
182 | if (mouse.pkm) { |
||
183 | CursorPointer.Restore(); |
||
184 | EventShowLinkMenu(); |
||
185 | } |
||
186 | } else { |
||
187 | CursorPointer.Restore(); |
||
188 | if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) { |
||
189 | EventShowPageMenu(); |
||
190 | } |
||
7758 | leency | 191 | } |
6978 | leency | 192 | break; |
5711 | leency | 193 | |
6978 | leency | 194 | case evButton: |
8016 | leency | 195 | ProcessEvent( @GetButtonID() ); |
6978 | leency | 196 | break; |
5711 | leency | 197 | |
6978 | leency | 198 | case evKey: |
199 | GetKeys(); |
||
7771 | leency | 200 | |
201 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
||
202 | if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;} |
||
203 | } |
||
204 | |||
7772 | leency | 205 | if (ProcessCtrlKeyEvent()) break; |
7743 | leency | 206 | |
207 | if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON); |
||
208 | |||
7506 | leency | 209 | if (address_box.flags & ed_focus) |
6978 | leency | 210 | { |
7742 | leency | 211 | if (key_scancode == SCAN_CODE_ENTER) { |
212 | ProcessEvent(key_scancode); |
||
7771 | leency | 213 | } else { |
6978 | leency | 214 | EAX = key_editbox; |
215 | edit_box_key stdcall(#address_box); |
||
5530 | leency | 216 | } |
7771 | leency | 217 | } else { |
7422 | leency | 218 | #define KEY_SCROLL_N 11 |
219 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
||
220 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
||
7743 | leency | 221 | if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();} |
6978 | leency | 222 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
223 | else ProcessEvent(key_scancode); |
||
224 | } |
||
225 | break; |
||
226 | |||
227 | case evReDraw: |
||
7780 | leency | 228 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), //40 |
7755 | leency | 229 | GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
6978 | leency | 230 | GetProcessInfo(#Form, SelfInfo); |
7780 | leency | 231 | ProcessMenuClick(); |
7806 | leency | 232 | sc.get(); |
7759 | leency | 233 | if (Form.status_window>2) break; |
6978 | leency | 234 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
235 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
||
7748 | leency | 236 | draw_window(); |
6978 | leency | 237 | break; |
238 | |||
239 | case evNetwork: |
||
7758 | leency | 240 | if (http.transfer <= 0) break; |
241 | http.receive(); |
||
242 | EventUpdateProgressBar(); |
||
8291 | leency | 243 | if (http.check_content_type()) && (!strncmp(#http.content_type,"application",11)) { |
244 | EventOpenDownloader(history.current()); |
||
245 | StopLoading(); |
||
246 | history.back(); |
||
247 | EventRefreshPage(); |
||
248 | } |
||
7758 | leency | 249 | if (http.receive_result != 0) break; |
250 | if (http.status_code >= 300) && (http.status_code < 400) |
||
251 | { |
||
252 | // Handle redirects |
||
253 | if (redirect_count<=5) { |
||
254 | redirect_count++; |
||
255 | http.handle_redirect(); |
||
256 | history.back(); |
||
8016 | leency | 257 | if (http_get_type==PAGE) OpenPage(#http.redirect_url); |
258 | else if (http_get_type==IMG) http.get(#http.redirect_url); |
||
7758 | leency | 259 | } else { |
260 | notify("'Too many redirects.' -E"); |
||
261 | StopLoading(); |
||
7791 | leency | 262 | redirect_count = 0; |
4536 | leency | 263 | } |
7758 | leency | 264 | } else { |
265 | // Loading the page is complete, free resources |
||
266 | redirect_count = 0; |
||
8291 | leency | 267 | http.hfree(); |
8016 | leency | 268 | if (http_get_type==PAGE) { |
269 | cache.add(history.current(), http.content_pointer, http.content_received, PAGE); |
||
270 | LoadInternalPage(http.content_pointer, http.content_received); |
||
271 | } |
||
272 | else if (http_get_type==IMG) { |
||
273 | cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG); |
||
274 | WB1.page_img.set_data(cache.data.get_last(), http.content_received); |
||
275 | GetImg(); |
||
276 | } |
||
6978 | leency | 277 | } |
7914 | leency | 278 | break; |
279 | default: |
||
280 | if (ESDWORD[shared_url] != '\0') { |
||
281 | EventOpenNewTab(shared_url); |
||
282 | ESDWORD[shared_url] = '\0'; |
||
283 | ActivateWindow(GetProcessSlot(Form.ID)); |
||
284 | } |
||
6978 | leency | 285 | } |
3067 | leency | 286 | } |
287 | |||
7772 | leency | 288 | bool ProcessCtrlKeyEvent() |
289 | { |
||
290 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) |
||
291 | { |
||
8016 | leency | 292 | case SCAN_CODE_KEY_O: EventOpenDialog(); return true; |
293 | case SCAN_CODE_KEY_H: ProcessEvent(VIEW_HISTORY); return true; |
||
294 | case SCAN_CODE_KEY_U: EventViewSource(); return true; |
||
295 | case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true; |
||
296 | case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true; |
||
297 | case SCAN_CODE_KEY_J: ProcessEvent(DOWNLOAD_MANAGER); return true; |
||
298 | case SCAN_CODE_KEY_R: ProcessEvent(REFRESH_BUTTON); return true; |
||
299 | case SCAN_CODE_ENTER: EventSeachWeb(); return true; |
||
300 | case SCAN_CODE_LEFT: ProcessEvent(BACK_BUTTON); return true; |
||
301 | case SCAN_CODE_RIGHT: ProcessEvent(FORWARD_BUTTON); return true; |
||
302 | case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true; |
||
303 | case SCAN_CODE_TAB: EventActivateNextTab(); return true; |
||
304 | default: return false; |
||
7772 | leency | 305 | } |
306 | } |
||
307 | |||
3067 | leency | 308 | void SetElementSizes() |
309 | { |
||
7758 | leency | 310 | address_box.width = Form.cwidth - address_box.left - 52 - 16; |
7771 | leency | 311 | WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, |
312 | Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H); |
||
7759 | leency | 313 | WB1.list.wheel_size = 7 * BASIC_LINE_H; |
7746 | leency | 314 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
6794 | leency | 315 | WB1.list.visible = WB1.list.h; |
3067 | leency | 316 | } |
317 | |||
5981 | leency | 318 | |
7748 | leency | 319 | void draw_window() |
3067 | leency | 320 | { |
7758 | leency | 321 | int i; |
7910 | leency | 322 | bool burger_active = false; |
323 | if (menu_id == OPEN_FILE) burger_active = true; |
||
324 | |||
3067 | leency | 325 | SetElementSizes(); |
7758 | leency | 326 | |
7806 | leency | 327 | DrawBar(0,0, Form.cwidth,PADDING, sc.work); |
328 | DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work); |
||
329 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180)); |
||
330 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph); |
||
331 | DrawBar(0, PADDING, address_box.left-2, TSZE+1, sc.work); |
||
332 | DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, sc.work); |
||
7758 | leency | 333 | |
7910 | leency | 334 | DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false); |
335 | DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false); |
||
336 | DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu |
||
7758 | leency | 337 | |
7806 | leency | 338 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
7758 | leency | 339 | |
340 | DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, |
||
341 | WB1.list.h-1, scroll_wv.bckg_col); |
||
342 | |||
7771 | leency | 343 | if (!BrowserWidthChanged()) { |
344 | WB1.DrawPage(); |
||
345 | DrawOmnibox(); |
||
346 | } |
||
347 | DrawProgress(); |
||
7970 | leency | 348 | DrawStatusBar(); |
7771 | leency | 349 | DrawTabsBar(); |
350 | } |
||
351 | |||
352 | bool BrowserWidthChanged() |
||
353 | { |
||
354 | dword source_mode_holder; |
||
355 | if (WB1.list.w!=DrawBuf.bufw) { |
||
356 | DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); |
||
7758 | leency | 357 | if (!strncmp(history.current(),"http",4)) { |
7759 | leency | 358 | //nihuya ne izyashnoe reshenie, no pust' poka butet tak |
7771 | leency | 359 | source_mode_holder = source_mode; |
7758 | leency | 360 | LoadInternalPage(#loading_text, sizeof(loading_text)); |
7771 | leency | 361 | source_mode = source_mode_holder; |
7758 | leency | 362 | } |
363 | OpenPage(history.current()); |
||
7771 | leency | 364 | return true; |
7282 | leency | 365 | } |
7771 | leency | 366 | return false; |
3067 | leency | 367 | } |
368 | |||
7771 | leency | 369 | |
7759 | leency | 370 | void EventChangeEncodingAndLoadPage(int _new_encoding) |
371 | { |
||
372 | dword newbuf, newsize; |
||
373 | WB1.custom_encoding = _new_encoding; |
||
374 | newsize = strlen(WB1.o_bufpointer); |
||
375 | newbuf = malloc(newsize); |
||
376 | memmov(newbuf, WB1.o_bufpointer, newsize); |
||
377 | LoadInternalPage(newbuf, newsize); |
||
378 | free(newbuf); |
||
379 | } |
||
3067 | leency | 380 | |
7759 | leency | 381 | |
6698 | leency | 382 | void ProcessEvent(dword id__) |
4413 | leency | 383 | { |
6698 | leency | 384 | switch (id__) |
4413 | leency | 385 | { |
7970 | leency | 386 | case 1: |
387 | ExitProcess(); |
||
388 | break; |
||
7759 | leency | 389 | case ENCODINGS...ENCODINGS+6: |
390 | EventChangeEncodingAndLoadPage(id__-ENCODINGS); |
||
391 | return; |
||
7758 | leency | 392 | case NEW_WINDOW: |
393 | RunProgram(#program_path, NULL); |
||
6698 | leency | 394 | return; |
5711 | leency | 395 | case SCAN_CODE_BS: |
5718 | leency | 396 | case BACK_BUTTON: |
6021 | leency | 397 | if (history.back()) { |
7755 | leency | 398 | OpenPage(history.current()); |
5978 | leency | 399 | } |
5711 | leency | 400 | return; |
5718 | leency | 401 | case FORWARD_BUTTON: |
6021 | leency | 402 | if (history.forward()) { |
7755 | leency | 403 | OpenPage(history.current()); |
5978 | leency | 404 | } |
5711 | leency | 405 | return; |
5718 | leency | 406 | case GOTOURL_BUTTON: |
5772 | leency | 407 | case SCAN_CODE_ENTER: |
7742 | leency | 408 | EventSubmitOmnibox(); |
5711 | leency | 409 | return; |
5718 | leency | 410 | case REFRESH_BUTTON: |
7893 | leency | 411 | EventRefreshPage(); |
5713 | leency | 412 | return; |
7759 | leency | 413 | case CHANGE_ENCODING: |
7770 | leency | 414 | EventShowEncodingsList(); |
7759 | leency | 415 | return; |
5718 | leency | 416 | case SANDWICH_BUTTON: |
7770 | leency | 417 | EventShowMainMenu(); |
4415 | leency | 418 | return; |
5718 | leency | 419 | case VIEW_SOURCE: |
7750 | leency | 420 | EventViewSource(); |
5718 | leency | 421 | break; |
422 | case EDIT_SOURCE: |
||
7755 | leency | 423 | if (check_is_the_adress_local(history.current())) { |
424 | RunProgram("/rd/1/tinypad", history.current()); |
||
7750 | leency | 425 | } else { |
7759 | leency | 426 | CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm"); |
5718 | leency | 427 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
428 | } |
||
4415 | leency | 429 | return; |
5718 | leency | 430 | case VIEW_HISTORY: |
7755 | leency | 431 | OpenPage(URL_SERVICE_HISTORY); |
4544 | leency | 432 | return; |
5718 | leency | 433 | case DOWNLOAD_MANAGER: |
8278 | leency | 434 | EventOpenDownloader(""); |
4413 | leency | 435 | return; |
7765 | leency | 436 | case UPDATE_BROWSER: |
437 | EventUpdateBrowser(); |
||
438 | return; |
||
7770 | leency | 439 | case CLEAR_CACHE: |
8016 | leency | 440 | cache.clear(); |
7770 | leency | 441 | notify(#clear_cache_ok); |
7893 | leency | 442 | EventRefreshPage(); |
7770 | leency | 443 | return; |
7789 | simsanutiy | 444 | case IN_NEW_TAB: |
7970 | leency | 445 | EventClickLink(TARGET_NEW_TAB); |
7789 | simsanutiy | 446 | return; |
447 | case IN_NEW_WINDOW: |
||
7970 | leency | 448 | EventClickLink(TARGET_NEW_WINDOW); |
7789 | simsanutiy | 449 | return; |
7282 | leency | 450 | case COPY_LINK_URL: |
7970 | leency | 451 | Clipboard__CopyText(GetAbsoluteActiveURL()); |
7037 | leency | 452 | notify("'URL copied to clipboard'O"); |
453 | return; |
||
7208 | leency | 454 | case DOWNLOAD_LINK_CONTENTS: |
8278 | leency | 455 | EventOpenDownloader( GetAbsoluteActiveURL() ); |
7208 | leency | 456 | return; |
7758 | leency | 457 | case OPEN_FILE: |
458 | EventOpenDialog(); |
||
459 | return; |
||
7282 | leency | 460 | case SCAN_CODE_F12: |
461 | debug_mode ^= 1; |
||
462 | if (debug_mode) notify("'Debug mode ON'-I"); |
||
463 | else notify("'Debug mode OFF'-I"); |
||
464 | return; |
||
7771 | leency | 465 | case NEW_TAB: |
466 | if (http.transfer) break; |
||
467 | EventOpenNewTab(URL_SERVICE_HOMEPAGE); |
||
468 | return; |
||
469 | case TAB_ID...TAB_ID+TABS_MAX: |
||
470 | if (http.transfer) break; |
||
471 | if (mouse.mkm) { |
||
472 | EventTabClose(id__ - TAB_ID); |
||
473 | } else { |
||
474 | EventTabClick(id__ - TAB_ID); |
||
475 | } |
||
476 | return; |
||
477 | case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: |
||
478 | EventTabClose(id__ - TAB_CLOSE_ID); |
||
479 | return; |
||
4413 | leency | 480 | } |
481 | } |
||
482 | |||
4636 | leency | 483 | void StopLoading() |
484 | { |
||
7281 | leency | 485 | if (http.transfer) |
4647 | leency | 486 | { |
7281 | leency | 487 | EAX = http.transfer; |
4647 | leency | 488 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
489 | $push EAX // save it on the stack |
||
7281 | leency | 490 | http_free stdcall (http.transfer); // abort connection |
4647 | leency | 491 | $pop EAX |
5631 | pavelyakov | 492 | free(EAX); // free data |
7281 | leency | 493 | http.transfer=0; |
7746 | leency | 494 | pause(10); |
4647 | leency | 495 | } |
5519 | leency | 496 | wv_progress_bar.value = 0; |
7743 | leency | 497 | DrawOmnibox(); |
4645 | leency | 498 | } |
499 | |||
7756 | leency | 500 | //rewrite into |
7757 | leency | 501 | //bool strrpl(dword dst, from, into, dst_len); |
502 | bool ReplaceSpaceInUrl(dword url, size) { |
||
7756 | leency | 503 | unsigned int i, j; |
7757 | leency | 504 | bool was_changed=false; |
505 | for (i=url+size-3; i>url; i--) |
||
7720 | leency | 506 | { |
7756 | leency | 507 | if (ESBYTE[i]!=' ') continue; |
7757 | leency | 508 | for (j=url+size-3; j>=i; j--) { |
509 | ESBYTE[j+3]=ESBYTE[j+2]; |
||
7756 | leency | 510 | ESBYTE[j+2]=ESBYTE[j+1]; |
511 | ESBYTE[j+1]=ESBYTE[j]; |
||
512 | } |
||
513 | ESBYTE[i] = '%'; |
||
514 | ESBYTE[i+1] = '2'; |
||
515 | ESBYTE[i+2] = '0'; |
||
7757 | leency | 516 | was_changed = true; |
7720 | leency | 517 | } |
7757 | leency | 518 | return was_changed; |
7720 | leency | 519 | } |
520 | |||
7801 | leency | 521 | bool HandleUrlFiles(dword _path, _data) |
522 | { |
||
523 | dword url_from_file; |
||
524 | if (!UrlExtIs(_path, "url")) return false; |
||
7945 | leency | 525 | if (! url_from_file = strstri(_data, "URL=")) return false; |
7801 | leency | 526 | replace_char(url_from_file, '\n', '\0', strlen(url_from_file)); |
7945 | leency | 527 | OpenPage(url_from_file); |
528 | return true; |
||
7801 | leency | 529 | } |
530 | |||
7755 | leency | 531 | bool GetLocalFileData(dword _path) |
4416 | leency | 532 | { |
7801 | leency | 533 | dword data, size; |
7755 | leency | 534 | file_size stdcall (_path); |
7801 | leency | 535 | if (!EBX) return false; |
536 | |||
537 | size = EBX; |
||
538 | data = malloc(size); |
||
539 | ReadFile(0, size, data, _path); |
||
540 | if (!HandleUrlFiles(_path, data)) { |
||
541 | LoadInternalPage(data, size); |
||
4692 | leency | 542 | } |
7801 | leency | 543 | free(data); |
544 | return true; |
||
7755 | leency | 545 | } |
7282 | leency | 546 | |
7755 | leency | 547 | void OpenPage(dword _open_URL) |
548 | { |
||
549 | char new_url[URL_SIZE+1]; |
||
7970 | leency | 550 | char new_url_full[URL_SIZE+1]; |
7788 | leency | 551 | int unz_id; |
7755 | leency | 552 | |
553 | StopLoading(); |
||
554 | |||
7771 | leency | 555 | SetOmniboxText(_open_URL); |
556 | |||
7755 | leency | 557 | strncpy(#new_url, _open_URL, URL_SIZE); |
558 | |||
559 | //Exclude # from the URL to the load page |
||
560 | //We will bring it back when we get the buffer |
||
7970 | leency | 561 | if (strrchr(#new_url, '#')) { |
562 | anchors.take_anchor_from(#new_url); |
||
563 | } |
||
7755 | leency | 564 | |
565 | history.add(#new_url); |
||
566 | |||
7976 | leency | 567 | /* |
568 | There could be several possible types of addresses: |
||
569 | - cached page (only http/https) |
||
570 | - internal page |
||
571 | - web page |
||
572 | - local file |
||
573 | So we need to detect what incoming address is |
||
574 | and then halndle it in the propper way. |
||
575 | */ |
||
576 | |||
8016 | leency | 577 | if (cache.has(#new_url)) { |
7764 | leency | 578 | //CACHED PAGE |
8016 | leency | 579 | LoadInternalPage(cache.current_buf, cache.current_size); |
7764 | leency | 580 | |
581 | } else if (!strncmp(#new_url,"WebView:",8)) { |
||
7755 | leency | 582 | //INTERNAL PAGE |
8278 | leency | 583 | if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home)); |
584 | else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help)); |
||
7976 | leency | 585 | else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); |
8278 | leency | 586 | else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
7800 | leency | 587 | |
7755 | leency | 588 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
589 | //WEB PAGE |
||
7757 | leency | 590 | if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) { |
591 | strcpy(#editURL, #new_url); |
||
592 | } |
||
593 | |||
8016 | leency | 594 | http_get_type = PAGE; |
7755 | leency | 595 | if (!strncmp(#new_url,"http:",5)) { |
596 | http.get(#new_url); |
||
597 | } else if (!strncmp(#new_url,"https://",8)) { |
||
7970 | leency | 598 | strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
599 | strncat(#new_url_full, #new_url, URL_SIZE); |
||
600 | http.get(#new_url_full); |
||
7282 | leency | 601 | } |
7758 | leency | 602 | |
603 | DrawOmnibox(); |
||
604 | |||
7755 | leency | 605 | if (!http.transfer) { |
4646 | leency | 606 | StopLoading(); |
8278 | leency | 607 | LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
4646 | leency | 608 | } |
7755 | leency | 609 | } else { |
610 | //LOCAL PAGE |
||
7788 | leency | 611 | if (UrlExtIs(#new_url,".docx")) { |
612 | DeleteFile("/tmp0/1/temp/word/document.xml"); |
||
613 | CreateDir("/tmp0/1/temp"); |
||
614 | unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url)); |
||
615 | while (GetProcessSlot(unz_id)) pause(2); |
||
616 | strcpy(#new_url, "/tmp0/1/temp/word/document.xml"); |
||
617 | } |
||
7755 | leency | 618 | if (!GetLocalFileData(#new_url)) { |
8278 | leency | 619 | LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
4650 | leency | 620 | } |
4636 | leency | 621 | } |
4416 | leency | 622 | } |
4415 | leency | 623 | |
8278 | leency | 624 | dword EventOpenDownloader(dword _url) |
625 | { |
||
626 | //char download_params[URL_SIZE+50]; |
||
627 | return RunProgram("/sys/network/dl", _url); |
||
628 | } |
||
7970 | leency | 629 | |
630 | bool EventClickAnchor() |
||
4508 | leency | 631 | { |
7970 | leency | 632 | dword aURL = links.active_url; |
633 | |||
634 | if (anchors.get_pos_by_name(aURL+1)!=-1) { |
||
635 | WB1.list.first = anchors.get_pos_by_name(aURL+1); |
||
636 | //WB1.list.CheckDoesValuesOkey(); |
||
637 | strcpy(#editURL, history.current()); |
||
638 | strcat(#editURL, aURL); |
||
639 | DrawOmnibox(); |
||
640 | WB1.DrawPage(); |
||
641 | return true; |
||
642 | } |
||
643 | return false; |
||
644 | } |
||
645 | |||
646 | void EventClickLink(dword _target) |
||
647 | { |
||
7756 | leency | 648 | char new_url[URL_SIZE+1]; |
7936 | leency | 649 | char new_url_full[URL_SIZE+1]; |
7970 | leency | 650 | dword aURL = GetAbsoluteActiveURL(); |
651 | if (!aURL) return; |
||
4415 | leency | 652 | |
7970 | leency | 653 | strcpy(#new_url, aURL); |
654 | |||
655 | if (ESBYTE[aURL]=='#') { |
||
656 | if (_target == TARGET_SAME_TAB) { |
||
657 | EventClickAnchor(); |
||
658 | return; |
||
659 | } else { |
||
660 | strcpy(#new_url, history.current()); |
||
661 | strcat(#new_url, aURL); |
||
662 | } |
||
663 | } |
||
664 | |||
665 | if (_target == TARGET_NEW_TAB) { |
||
666 | EventOpenNewTab(#new_url); |
||
7758 | leency | 667 | return; |
668 | } |
||
669 | |||
7970 | leency | 670 | if (_target == TARGET_NEW_WINDOW) { |
671 | strcpy(#new_url_full, "-new "); |
||
672 | strncat(#new_url_full, #new_url, URL_SIZE); |
||
673 | RunProgram(#program_path, #new_url_full); |
||
7755 | leency | 674 | return; |
5768 | leency | 675 | } |
7742 | leency | 676 | |
7970 | leency | 677 | if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) { |
678 | notify(#new_url); |
||
7755 | leency | 679 | return; |
7742 | leency | 680 | } |
4508 | leency | 681 | |
7771 | leency | 682 | if (http.transfer) { |
5774 | leency | 683 | StopLoading(); |
6021 | leency | 684 | history.back(); |
5774 | leency | 685 | } |
6730 | leency | 686 | |
7755 | leency | 687 | if (strrchr(#new_url, '#')!=0) { |
688 | anchors.take_anchor_from(#new_url); |
||
689 | OpenPage(#new_url); |
||
6730 | leency | 690 | return; |
691 | } |
||
692 | |||
7755 | leency | 693 | if (!strncmp(#new_url,"WebView:",8)) { |
694 | OpenPage(#new_url); |
||
7742 | leency | 695 | return; |
696 | } |
||
6730 | leency | 697 | |
7755 | leency | 698 | if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0) |
5774 | leency | 699 | { |
7755 | leency | 700 | if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true) |
6730 | leency | 701 | { |
7755 | leency | 702 | if (strchr(#new_url, '|')) { |
703 | ESBYTE[strchr(#new_url, '|')] = NULL; |
||
704 | RunProgram(#new_url, strlen(#new_url)+1+#new_url); |
||
705 | } else { |
||
706 | RunProgram("/sys/@open", #new_url); |
||
7422 | leency | 707 | } |
6730 | leency | 708 | return; |
709 | } |
||
7755 | leency | 710 | } else { |
711 | if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) |
||
712 | || (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true) |
||
713 | || (UrlExtIs(#new_url,".7z")==true) { |
||
8278 | leency | 714 | EventOpenDownloader(#new_url); |
6730 | leency | 715 | return; |
5774 | leency | 716 | } |
717 | } |
||
7755 | leency | 718 | OpenPage(#new_url); |
719 | } |
||
720 | |||
721 | void EventSubmitOmnibox() |
||
722 | { |
||
723 | char new_url[URL_SIZE+1]; |
||
724 | if (!editURL[0]) return; |
||
725 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
||
726 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
||
727 | OpenPage(#editURL); |
||
728 | } else { |
||
729 | strcpy(#new_url, "http://"); |
||
7970 | leency | 730 | strncat(#new_url, #editURL, URL_SIZE-1); |
7755 | leency | 731 | OpenPage(#new_url); |
6931 | leency | 732 | } |
5774 | leency | 733 | } |
734 | |||
7755 | leency | 735 | void LoadInternalPage(dword _bufdata, _in_bufsize){ |
736 | if (!_bufdata) || (!_in_bufsize) { |
||
8278 | leency | 737 | LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
7755 | leency | 738 | } else { |
739 | WB1.list.first = 0; //scroll page to the top |
||
740 | DrawOmnibox(); |
||
741 | if(!strrchr(#editURL, '#')) { |
||
742 | strcat(#editURL, #anchors.current); |
||
743 | DrawOmnibox(); |
||
744 | } |
||
7759 | leency | 745 | WB1.ParseHtml(_bufdata, _in_bufsize); |
7970 | leency | 746 | DrawStatusBar(); |
7771 | leency | 747 | DrawActiveTab(); |
7756 | leency | 748 | if (source_mode) { |
749 | source_mode = false; |
||
7799 | leency | 750 | WB1.custom_encoding = CH_CP866; |
7759 | leency | 751 | ShowSource(WB1.bufpointer, _in_bufsize); |
7757 | leency | 752 | } else { |
8016 | leency | 753 | WB1.DrawPage(); |
7756 | leency | 754 | } |
8016 | leency | 755 | //GetImg(); |
7742 | leency | 756 | } |
757 | } |
||
758 | |||
7799 | leency | 759 | bool UrlExtIs(dword base, ext) |
7742 | leency | 760 | { |
7755 | leency | 761 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |
7742 | leency | 762 | return false; |
763 | } |
||
764 | |||
765 | void DrawProgress() |
||
766 | { |
||
767 | dword persent; |
||
768 | if (http.transfer == 0) return; |
||
7755 | leency | 769 | if (wv_progress_bar.max) { |
770 | persent = wv_progress_bar.value*100/wv_progress_bar.max; |
||
771 | } else { |
||
772 | persent = 10; |
||
773 | } |
||
7758 | leency | 774 | DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB); |
7742 | leency | 775 | } |
776 | |||
7770 | leency | 777 | void EventShowPageMenu() |
6782 | leency | 778 | { |
8020 | leency | 779 | open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu); |
7780 | leency | 780 | menu_id = VIEW_SOURCE; |
6782 | leency | 781 | } |
782 | |||
7770 | leency | 783 | void EventShowLinkMenu() |
7759 | leency | 784 | { |
8020 | leency | 785 | open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu); |
7789 | simsanutiy | 786 | menu_id = IN_NEW_TAB; |
7759 | leency | 787 | } |
788 | |||
7780 | leency | 789 | void EventShowMainMenu() |
790 | { |
||
8020 | leency | 791 | open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3, |
792 | MENU_TOP_RIGHT, NULL, #main_menu); |
||
7780 | leency | 793 | menu_id = OPEN_FILE; |
794 | } |
||
795 | |||
7770 | leency | 796 | void EventShowEncodingsList() |
7758 | leency | 797 | { |
8020 | leency | 798 | open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12, |
799 | MENU_BOT_RIGHT, WB1.cur_encoding + 1, |
||
800 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); |
||
7780 | leency | 801 | menu_id = ENCODINGS; |
7758 | leency | 802 | } |
803 | |||
7780 | leency | 804 | void ProcessMenuClick() |
6795 | leency | 805 | { |
7780 | leency | 806 | int click_id; |
7910 | leency | 807 | if (menu_id) { |
808 | if (click_id = get_menu_click()) { |
||
809 | click_id += menu_id - 1; |
||
810 | ProcessEvent(click_id); |
||
811 | } |
||
812 | if (!menu_process_id) menu_id = NULL; |
||
7780 | leency | 813 | } |
6795 | leency | 814 | } |
815 | |||
7281 | leency | 816 | void EventUpdateProgressBar() |
817 | { |
||
818 | wv_progress_bar.max = http.content_length; |
||
819 | if (wv_progress_bar.value != http.content_received) |
||
820 | { |
||
821 | wv_progress_bar.value = http.content_received; |
||
822 | DrawProgress(); |
||
823 | } |
||
824 | } |
||
6795 | leency | 825 | |
7743 | leency | 826 | void EventSeachWeb() |
827 | { |
||
7755 | leency | 828 | char new_url[URL_SIZE+1]; |
829 | replace_char(#editURL, ' ', '_', URL_SIZE); |
||
830 | strcpy(#new_url, "https://www.google.com/search?q="); |
||
831 | strncat(#new_url, #editURL, URL_SIZE); |
||
832 | OpenPage(#new_url); |
||
7743 | leency | 833 | } |
834 | |||
7748 | leency | 835 | void EventOpenDialog() |
836 | { |
||
837 | OpenDialog_start stdcall (#o_dialog); |
||
838 | if (o_dialog.status) { |
||
7755 | leency | 839 | OpenPage(#openfile_path); |
7748 | leency | 840 | } |
841 | } |
||
842 | |||
7750 | leency | 843 | void EventViewSource() |
844 | { |
||
7755 | leency | 845 | char source_view_param[URL_SIZE+1]; |
7771 | leency | 846 | //strcpy(#source_view_param, "-source "); |
847 | //strncat(#source_view_param, history.current(), URL_SIZE); |
||
848 | //RunProgram(#program_path, #source_view_param); |
||
849 | source_mode = true; |
||
850 | EventOpenNewTab(history.current()); |
||
7750 | leency | 851 | } |
852 | |||
7893 | leency | 853 | void EventRefreshPage() |
854 | { |
||
855 | if (http.transfer) { |
||
856 | StopLoading(); |
||
857 | draw_window(); |
||
858 | } else { |
||
859 | OpenPage(history.current()); |
||
860 | } |
||
861 | } |
||
862 | |||
7765 | leency | 863 | dword GetFileSize(dword _path) |
864 | { |
||
865 | BDVK bdvk; |
||
866 | if (GetFileInfo(_path, #bdvk)!=0) { |
||
867 | return 0; |
||
868 | } else { |
||
869 | return bdvk.sizelo; |
||
870 | } |
||
871 | } |
||
872 | |||
873 | void EventUpdateBrowser() |
||
874 | { |
||
875 | dword downloader_id, slot_n; |
||
876 | dword current_size; |
||
877 | dword new_size; |
||
878 | int error; |
||
879 | |||
880 | draw_window(); |
||
881 | |||
8278 | leency | 882 | downloader_id = EventOpenDownloader(#update_param); |
7765 | leency | 883 | do { |
884 | slot_n = GetProcessSlot(downloader_id); |
||
885 | pause(10); |
||
886 | } while (slot_n!=0); |
||
887 | |||
888 | current_size = GetFileSize(#program_path); |
||
889 | new_size = GetFileSize("/tmp0/1/Downloads/WebView.com"); |
||
890 | |||
891 | if (!new_size) || (new_size<5000) { |
||
892 | notify(#update_download_error); |
||
893 | return; |
||
894 | } |
||
895 | |||
896 | if (current_size == new_size) { |
||
897 | notify(#update_is_current); |
||
898 | return; |
||
899 | } |
||
900 | |||
901 | if (error = CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) { |
||
902 | notify(#update_can_not_copy); |
||
903 | } else { |
||
904 | notify(#update_ok); |
||
905 | RunProgram(#program_path, history.current()); |
||
906 | ExitProcess(); |
||
907 | } |
||
908 | } |
||
909 | |||
7970 | leency | 910 | void DrawStatusBar() |
6795 | leency | 911 | { |
7970 | leency | 912 | dword status_y = Form.cheight - STATUSBAR_H + 4; |
913 | dword status_w = Form.cwidth - 90; |
||
7806 | leency | 914 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work); |
7970 | leency | 915 | if (links.active_url) { |
916 | ESI = math.min(status_w/6, strlen(links.active_url)); |
||
917 | WriteText(10, status_y, 0, sc.work_text, links.active_url); |
||
7758 | leency | 918 | } |
8016 | leency | 919 | if (http.transfer>0) && (http_get_type==IMG) { |
920 | // |
||
921 | } |
||
7970 | leency | 922 | DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING); |
923 | WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets); |
||
7758 | leency | 924 | } |
925 | |||
926 | void DrawOmnibox() |
||
927 | { |
||
7784 | leency | 928 | int imgxoff; |
7758 | leency | 929 | |
7806 | leency | 930 | DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, sc.work_graph, |
931 | sc.work_graph, sc.work_graph, sc.work_dark); |
||
7758 | leency | 932 | DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8); |
933 | DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color); |
||
934 | DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color); |
||
935 | |||
936 | if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0; |
||
937 | EditBox_UpdateText(#address_box, address_box.flags); |
||
938 | edit_box_draw stdcall(#address_box); |
||
7784 | leency | 939 | if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0; |
940 | _PutImage(address_box.left+address_box.width+1, address_box.top-1, 16, 23, imgxoff + #editbox_icons); |
||
941 | DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, 23, REFRESH_BUTTON); |
||
7758 | leency | 942 | |
943 | DrawProgress(); |
||
944 | } |
||
945 | |||
7771 | leency | 946 | void SetOmniboxText(dword _text) |
947 | { |
||
948 | strcpy(#editURL, _text); |
||
949 | address_box.flags=0; |
||
950 | DrawOmnibox(); |
||
951 | } |
||
7758 | leency | 952 | |
7970 | leency | 953 | dword GetAbsoluteActiveURL() |
954 | { |
||
955 | char abs_url[URL_SIZE]; |
||
956 | if (links.active_url) { |
||
957 | strncpy(#abs_url, links.active_url, URL_SIZE); |
||
8291 | leency | 958 | get_absolute_url(#abs_url, history.current()); |
7970 | leency | 959 | return #abs_url; |
960 | } |
||
961 | return 0; |
||
962 | } |
||
7771 | leency | 963 | |
8016 | leency | 964 | dword GetImg() |
965 | { |
||
966 | while (WB1.page_img.next_url()) { |
||
967 | if (cache.has(WB1.page_img.current_url())) continue; |
||
968 | http_get_type = IMG; |
||
969 | http.get(WB1.page_img.current_url()); |
||
970 | return; |
||
971 | } |
||
972 | DrawOmnibox(); |
||
973 | WB1.DrawPage(); |
||
974 | } |
||
975 | |||
5631 | pavelyakov | 976 | stop:5000)>=5)>>=>280)>120)> |