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