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