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