Rev 7757 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7757 | Rev 7782 | ||
---|---|---|---|
1 | #define MEMSIZE 4096*100 |
1 | #define MEMSIZE 4096*100 |
2 | 2 | ||
3 | #include "../lib/gui.h" |
3 | #include "../lib/gui.h" |
4 | #include "../lib/kfont.h" |
4 | #include "../lib/kfont.h" |
5 | #include "../lib/io.h" |
5 | #include "../lib/io.h" |
6 | #include "../lib/cursor.h" |
6 | #include "../lib/cursor.h" |
- | 7 | #include "../lib/list_box.h" |
|
7 | 8 | ||
8 | #include "../lib/obj/box_lib.h" |
9 | #include "../lib/obj/box_lib.h" |
9 | #include "../lib/obj/libini.h" |
10 | #include "../lib/obj/libini.h" |
10 | #include "../lib/obj/iconv.h" |
11 | #include "../lib/obj/iconv.h" |
11 | #include "../lib/obj/libimg.h" |
12 | #include "../lib/obj/libimg.h" |
12 | #include "../lib/obj/proc_lib.h" |
13 | #include "../lib/obj/proc_lib.h" |
13 | #include "../lib/obj/http.h" |
14 | #include "../lib/obj/http.h" |
14 | 15 | ||
15 | #include "../lib/patterns/simple_open_dialog.h" |
16 | #include "../lib/patterns/simple_open_dialog.h" |
16 | #include "../lib/patterns/history.h" |
17 | #include "../lib/patterns/history.h" |
17 | #include "../lib/patterns/http_downloader.h" |
18 | #include "../lib/patterns/http_downloader.h" |
18 | #include "../browser/download_manager.h" |
19 | #include "../browser/download_manager.h" |
19 | 20 | ||
20 | llist list; |
21 | llist list; |
21 | 22 | ||
22 | #include "link.h" |
23 | #include "link.h" |
23 | #include "canvas.h" |
24 | #include "canvas.h" |
24 | #include "favicon.h" |
25 | #include "favicon.h" |
25 | 26 | ||
26 | _history history; |
27 | _history history; |
27 | 28 | ||
28 | char default_dir[] = "/rd/1"; |
29 | char default_dir[] = "/rd/1"; |
29 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
30 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
30 | 31 | ||
31 | char accept_language[]= "Accept-Language: ru\n"; |
32 | char accept_language[]= "Accept-Language: ru\n"; |
32 | 33 | ||
33 | #define TOOLBAR_H 36 |
34 | #define TOOLBAR_H 36 |
34 | #define TOOLBAR_ICON_WIDTH 26 |
35 | #define TOOLBAR_ICON_WIDTH 26 |
35 | #define TOOLBAR_ICON_HEIGHT 24 |
36 | #define TOOLBAR_ICON_HEIGHT 24 |
36 | #define STATUSBAR_H 15 |
37 | #define STATUSBAR_H 15 |
37 | 38 | ||
38 | #define DEFAULT_EDITOR "/sys/tinypad" |
39 | #define DEFAULT_EDITOR "/sys/tinypad" |
39 | #define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt" |
40 | #define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt" |
40 | 41 | ||
41 | //ATTENTION: each page must have '\0' character at the end of the file |
42 | //ATTENTION: each page must have '\0' character at the end of the file |
42 | char buidin_page_home[] = FROM "buidin_pages\\home.htm"; |
43 | char buidin_page_home[] = FROM "buidin_pages\\home.htm"; |
43 | char buidin_page_about[] = FROM "buidin_pages\\about.htm"; |
44 | char buidin_page_about[] = FROM "buidin_pages\\about.htm"; |
44 | char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm"; |
45 | char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm"; |
45 | 46 | ||
46 | #define UML 4096*2 |
47 | #define UML 4096*2 |
47 | 48 | ||
48 | scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
49 | scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
49 | 50 | ||
50 | proc_info Form; |
51 | proc_info Form; |
51 | char title[4196]; |
52 | char title[4196]; |
52 | 53 | ||
53 | enum { |
54 | enum { |
54 | OPEN_FILE, |
55 | OPEN_FILE, |
55 | MAGNIFY_MINUS, |
56 | MAGNIFY_MINUS, |
56 | MAGNIFY_PLUS, |
57 | MAGNIFY_PLUS, |
57 | CHANGE_ENCODING, |
58 | CHANGE_ENCODING, |
58 | RUN_EDIT, |
59 | RUN_EDIT, |
59 | GO_BACK, |
60 | GO_BACK, |
60 | GO_FORWARD, |
61 | GO_FORWARD, |
61 | SANDWICH |
62 | SANDWICH |
62 | }; |
63 | }; |
63 | 64 | ||
64 | char address[UML]; |
65 | char address[UML]; |
65 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,NULL,2,19,19}; |
66 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,NULL,2,19,19}; |
66 | 67 | ||
67 | bool debug_mode=false; |
68 | bool debug_mode=false; |
68 | 69 | ||
69 | #include "ini.h" |
70 | #include "ini.h" |
70 | #include "gui.h" |
71 | #include "gui.h" |
71 | #include "prepare_page.h" |
72 | #include "prepare_page.h" |
72 | //#include "special.h" |
73 | //#include "special.h" |
- | 74 | ||
- | 75 | int menu_id=0; |
|
73 | 76 | ||
74 | #define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout" |
77 | #define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout" |
75 | 78 | ||
76 | void InitDlls() |
79 | void InitDlls() |
77 | { |
80 | { |
78 | load_dll(boxlib, #box_lib_init, 0); |
81 | load_dll(boxlib, #box_lib_init, 0); |
79 | load_dll(libHTTP, #http_lib_init, 1); |
82 | load_dll(libHTTP, #http_lib_init, 1); |
80 | load_dll(libio, #libio_init, 1); |
83 | load_dll(libio, #libio_init, 1); |
81 | load_dll(libimg, #libimg_init, 1); |
84 | load_dll(libimg, #libimg_init, 1); |
82 | //load_dll(libini, #lib_init, 1); |
85 | //load_dll(libini, #lib_init, 1); |
83 | load_dll(iconv_lib, #iconv_open, 0); |
86 | load_dll(iconv_lib, #iconv_open, 0); |
84 | load_dll(Proc_lib, #OpenDialog_init,0); |
87 | load_dll(Proc_lib, #OpenDialog_init,0); |
85 | } |
88 | } |
86 | 89 | ||
87 | 90 | ||
88 | void main() |
91 | void main() |
89 | { |
92 | { |
90 | InitDlls(); |
93 | InitDlls(); |
91 | OpenDialog_init stdcall (#o_dialog); |
94 | OpenDialog_init stdcall (#o_dialog); |
92 | LoadIniSettings(); |
95 | LoadIniSettings(); |
93 | kfont.init(DEFAULT_FONT); |
96 | kfont.init(DEFAULT_FONT); |
94 | Libimg_LoadImage(#skin, abspath("toolbar.png")); |
97 | Libimg_LoadImage(#skin, abspath("toolbar.png")); |
95 | list.no_selection = true; |
98 | list.no_selection = true; |
96 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
99 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
97 | loop() |
100 | loop() |
98 | { |
101 | { |
99 | switch(WaitEvent()) |
102 | switch(WaitEvent()) |
100 | { |
103 | { |
101 | case evMouse: |
104 | case evMouse: |
102 | HandleMouseEvent(); |
105 | HandleMouseEvent(); |
103 | break; |
106 | break; |
104 | case evKey: |
107 | case evKey: |
105 | HandleKeyEvent(); |
108 | HandleKeyEvent(); |
106 | break; |
109 | break; |
107 | case evButton: |
110 | case evButton: |
108 | HandleButtonEvent(); |
111 | HandleButtonEvent(); |
109 | break; |
112 | break; |
110 | case evNetwork: |
113 | case evNetwork: |
111 | HandleNetworkEvent(); |
114 | HandleNetworkEvent(); |
112 | break; |
115 | break; |
113 | case evReDraw: |
116 | case evReDraw: |
114 | draw_window(); |
117 | draw_window(); |
115 | if (menu.cur_y>=10) && (menu.cur_y<20) { |
- | |
116 | encoding = menu.cur_y - 10; |
- | |
117 | EventPageRefresh(); |
- | |
118 | menu.cur_y = 0; |
- | |
119 | } |
- | |
120 | if (menu.cur_y>=20) { |
- | |
121 | menu.cur_y-=20; |
- | |
122 | if (menu.cur_y==0) EventPageRefresh(); |
- | |
123 | if (menu.cur_y==1) EventRunEdit(); |
118 | if (CheckActiveProcess(Form.ID)) EventMenuClick(); |
124 | if (menu.cur_y==2) EventShowHistory(); |
- | |
125 | if (menu.cur_y==3) EventShowDownloader(); |
- | |
126 | if (menu.cur_y==4) EventShowInfo(); |
- | |
127 | menu.cur_y = 0; |
- | |
128 | } |
- | |
129 | } |
119 | } |
130 | } |
120 | } |
131 | } |
121 | } |
132 | 122 | ||
133 | 123 | ||
134 | void HandleButtonEvent() |
124 | void HandleButtonEvent() |
135 | { |
125 | { |
136 | byte btn = GetButtonID(); |
126 | byte btn = GetButtonID(); |
137 | if (btn==1) { |
127 | if (btn==1) { |
138 | SaveIniSettings(); |
128 | SaveIniSettings(); |
139 | ExitProcess(); |
129 | ExitProcess(); |
140 | } |
130 | } |
141 | switch(btn-10) |
131 | switch(btn-10) |
142 | { |
132 | { |
143 | case GO_BACK: |
133 | case GO_BACK: |
144 | EventGoBack(); |
134 | EventGoBack(); |
145 | break; |
135 | break; |
146 | case GO_FORWARD: |
136 | case GO_FORWARD: |
147 | EventGoForward(); |
137 | EventGoForward(); |
148 | break; |
138 | break; |
149 | case OPEN_FILE: |
139 | case OPEN_FILE: |
150 | EventOpenDialog(); |
140 | EventOpenDialog(); |
151 | break; |
141 | break; |
152 | case MAGNIFY_PLUS: |
142 | case MAGNIFY_PLUS: |
153 | EventMagnifyPlus(); |
143 | EventMagnifyPlus(); |
154 | break; |
144 | break; |
155 | case MAGNIFY_MINUS: |
145 | case MAGNIFY_MINUS: |
156 | EventMagnifyMinus(); |
146 | EventMagnifyMinus(); |
157 | break; |
147 | break; |
158 | case CHANGE_ENCODING: |
148 | case CHANGE_ENCODING: |
159 | EventChangeEncoding(); |
149 | EventChangeEncoding(); |
160 | break; |
150 | break; |
161 | case RUN_EDIT: |
151 | case RUN_EDIT: |
162 | EventRunEdit(); |
152 | EventRunEdit(); |
163 | break; |
153 | break; |
164 | case SANDWICH: |
154 | case SANDWICH: |
165 | EventShowSandwichMenu(); |
155 | EventShowSandwichMenu(); |
166 | break; |
156 | break; |
167 | } |
157 | } |
168 | } |
158 | } |
169 | 159 | ||
170 | 160 | ||
171 | void HandleKeyEvent() |
161 | void HandleKeyEvent() |
172 | { |
162 | { |
173 | GetKeys(); |
163 | GetKeys(); |
174 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
164 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
175 | switch (key_scancode) |
165 | switch (key_scancode) |
176 | { |
166 | { |
177 | case SCAN_CODE_UP: |
167 | case SCAN_CODE_UP: |
178 | EventMagnifyPlus(); |
168 | EventMagnifyPlus(); |
179 | return; |
169 | return; |
180 | case SCAN_CODE_DOWN: |
170 | case SCAN_CODE_DOWN: |
181 | EventMagnifyMinus(); |
171 | EventMagnifyMinus(); |
182 | return; |
172 | return; |
183 | case SCAN_CODE_KEY_O: |
173 | case SCAN_CODE_KEY_O: |
184 | EventOpenDialog(); |
174 | EventOpenDialog(); |
185 | return; |
175 | return; |
186 | case SCAN_CODE_KEY_E: |
176 | case SCAN_CODE_KEY_E: |
187 | EventRunEdit(); |
177 | EventRunEdit(); |
188 | return; |
178 | return; |
189 | case SCAN_CODE_KEY_H: |
179 | case SCAN_CODE_KEY_H: |
190 | EventShowHistory(); |
180 | EventShowHistory(); |
191 | return; |
181 | return; |
192 | case SCAN_CODE_TAB: |
182 | case SCAN_CODE_TAB: |
193 | EventChangeEncoding(); |
183 | EventChangeEncoding(); |
194 | return; |
184 | return; |
195 | } |
185 | } |
196 | } |
186 | } |
197 | switch (key_scancode) |
187 | switch (key_scancode) |
198 | { |
188 | { |
199 | case SCAN_CODE_F1: |
189 | case SCAN_CODE_F1: |
200 | EventShowInfo(); |
190 | EventShowInfo(); |
201 | return; |
191 | return; |
202 | case SCAN_CODE_F12: |
192 | case SCAN_CODE_F12: |
203 | EventChangeDebugMode(); |
193 | EventChangeDebugMode(); |
204 | return; |
194 | return; |
205 | case SCAN_CODE_ENTER: |
195 | case SCAN_CODE_ENTER: |
206 | EventOpenAddress(#address); |
196 | EventOpenAddress(#address); |
207 | return; |
197 | return; |
208 | case SCAN_CODE_BS: |
198 | case SCAN_CODE_BS: |
209 | if (! address_box.flags & ed_focus) { |
199 | if (! address_box.flags & ed_focus) { |
210 | EventGoBack(); |
200 | EventGoBack(); |
211 | return; |
201 | return; |
212 | } |
202 | } |
213 | } |
203 | } |
214 | if (list.ProcessKey(key_scancode)) && (! address_box.flags & ed_focus) { |
204 | if (list.ProcessKey(key_scancode)) && (! address_box.flags & ed_focus) { |
215 | DrawPage(); |
205 | DrawPage(); |
216 | return; |
206 | return; |
217 | } |
207 | } |
218 | if (key_ascii != ASCII_KEY_ENTER) |
208 | if (key_ascii != ASCII_KEY_ENTER) |
219 | && (key_ascii != ASCII_KEY_PGDN) |
209 | && (key_ascii != ASCII_KEY_PGDN) |
220 | && (key_ascii != ASCII_KEY_PGUP) { |
210 | && (key_ascii != ASCII_KEY_PGUP) { |
221 | EAX = key_editbox; |
211 | EAX = key_editbox; |
222 | edit_box_key stdcall(#address_box); |
212 | edit_box_key stdcall(#address_box); |
223 | } |
213 | } |
224 | } |
214 | } |
225 | 215 | ||
226 | 216 | ||
227 | void HandleMouseEvent() |
217 | void HandleMouseEvent() |
228 | { |
218 | { |
229 | edit_box_mouse stdcall (#address_box); |
219 | edit_box_mouse stdcall (#address_box); |
230 | mouse.get(); |
220 | mouse.get(); |
231 | list.wheel_size = 7; |
221 | list.wheel_size = 7; |
232 | 222 | ||
233 | if (link.hover(mouse.x, mouse.y)) { |
223 | if (link.hover(mouse.x, mouse.y)) { |
234 | if (-1 == link.active) { |
224 | if (-1 == link.active) { |
235 | DrawStatusBar( " " ); //just clean status bar |
225 | DrawStatusBar( " " ); //just clean status bar |
236 | } |
226 | } |
237 | else { |
227 | else { |
238 | DrawStatusBar( link.get_active_url() ); |
228 | DrawStatusBar( link.get_active_url() ); |
239 | } |
229 | } |
240 | } |
230 | } |
241 | 231 | ||
242 | if (mouse.key&MOUSE_LEFT) && (mouse.up) { |
232 | if (mouse.key&MOUSE_LEFT) && (mouse.up) { |
243 | if (-1 != link.active) EventOpenAddress( link.get_active_url() ); |
233 | if (-1 != link.active) EventOpenAddress( link.get_active_url() ); |
244 | } |
234 | } |
245 | 235 | ||
246 | if (list.MouseScroll(mouse.vert)) { |
236 | if (list.MouseScroll(mouse.vert)) { |
247 | DrawPage(); |
237 | DrawPage(); |
248 | return; |
238 | return; |
249 | } |
239 | } |
250 | 240 | ||
251 | scrollbar_v_mouse (#scroll); |
241 | scrollbar_v_mouse (#scroll); |
252 | if (list.first != scroll.position) { |
242 | if (list.first != scroll.position) { |
253 | list.first = scroll.position; |
243 | list.first = scroll.position; |
254 | DrawPage(); |
244 | DrawPage(); |
255 | } |
245 | } |
256 | } |
246 | } |
257 | 247 | ||
258 | void HandleNetworkEvent() |
248 | void HandleNetworkEvent() |
259 | { |
249 | { |
260 | char favicon_address[UML]; |
250 | char favicon_address[UML]; |
261 | 251 | ||
262 | if (downloader.state == STATE_IN_PROGRESS) { |
252 | if (downloader.state == STATE_IN_PROGRESS) { |
263 | downloader.MonitorProgress(); |
253 | downloader.MonitorProgress(); |
264 | 254 | ||
265 | if (downloader.httpd.content_length>0) |
255 | if (downloader.httpd.content_length>0) |
266 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE* |
256 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE* |
267 | downloader.httpd.content_received/downloader.httpd.content_length); |
257 | downloader.httpd.content_received/downloader.httpd.content_length); |
268 | else |
258 | else |
269 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2); |
259 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2); |
270 | } |
260 | } |
271 | 261 | ||
272 | if (downloader.state == STATE_COMPLETED) |
262 | if (downloader.state == STATE_COMPLETED) |
273 | { |
263 | { |
274 | if (!strncmp(downloader.url,"http://gate.aspero.pro/",22)) { |
264 | if (!strncmp(downloader.url,"http://gate.aspero.pro/",22)) { |
275 | strcpy(#address,downloader.url + 29); |
265 | strcpy(#address,downloader.url + 29); |
276 | } |
266 | } |
277 | else { |
267 | else { |
278 | strcpy(#address,downloader.url); |
268 | strcpy(#address,downloader.url); |
279 | } |
269 | } |
280 | downloader.Stop(); |
270 | downloader.Stop(); |
281 | DrawAddressBox(); |
271 | DrawAddressBox(); |
282 | io.buffer_data = downloader.bufpointer; |
272 | io.buffer_data = downloader.bufpointer; |
283 | /* |
273 | /* |
284 | get_absolute_url(#favicon_address, #address, "/favicon.ico"); |
274 | get_absolute_url(#favicon_address, #address, "/favicon.ico"); |
285 | favicon.get(#favicon_address); |
275 | favicon.get(#favicon_address); |
286 | */ |
276 | */ |
287 | PostOpenPageActions(); |
277 | PostOpenPageActions(); |
288 | } |
278 | } |
289 | } |
279 | } |
290 | 280 | ||
291 | 281 | ||
292 | /* ----------------------------------------------------- */ |
282 | /* ----------------------------------------------------- */ |
293 | 283 | ||
294 | void EventOpenDialog() |
284 | void EventOpenDialog() |
295 | { |
285 | { |
296 | OpenDialog_start stdcall (#o_dialog); |
286 | OpenDialog_start stdcall (#o_dialog); |
297 | if (o_dialog.status) EventOpenAddress(#openfile_path); |
287 | if (o_dialog.status) EventOpenAddress(#openfile_path); |
298 | } |
288 | } |
299 | 289 | ||
300 | void EventOpenAddress(dword _new_address) |
290 | void EventOpenAddress(dword _new_address) |
301 | { |
291 | { |
302 | char temp[UML]; |
292 | char temp[UML]; |
303 | char getUrl[UML]; |
293 | char getUrl[UML]; |
304 | if (!ESBYTE[_new_address]) return; |
294 | if (!ESBYTE[_new_address]) return; |
305 | debugln("===================================="); |
295 | debugln("===================================="); |
306 | debug("address: "); |
296 | debug("address: "); |
307 | debugln(_new_address); |
297 | debugln(_new_address); |
308 | strlcpy(#address, _new_address, UML); |
298 | strlcpy(#address, _new_address, UML); |
309 | strlwr(#address); |
299 | strlwr(#address); |
310 | DrawAddressBox(); |
300 | DrawAddressBox(); |
311 | 301 | ||
312 | /* |
302 | /* |
313 | There could be several possible types of addresses: |
303 | There could be several possible types of addresses: |
314 | - build in page |
304 | - build in page |
315 | - local file |
305 | - local file |
316 | - url |
306 | - url |
317 | So we need to detect what incoming address is |
307 | So we need to detect what incoming address is |
318 | and then halndle it in the propper way. |
308 | and then halndle it in the propper way. |
319 | */ |
309 | */ |
320 | 310 | ||
321 | io.buffer_data = 0; |
311 | io.buffer_data = 0; |
322 | favicon.get(NULL); |
312 | favicon.get(NULL); |
323 | 313 | ||
324 | // - build in page |
314 | // - build in page |
325 | if (!strncmp(#address,"aelia:",6)) { |
315 | if (!strncmp(#address,"aelia:",6)) { |
326 | debugln("this is buildin page"); |
316 | debugln("this is buildin page"); |
327 | if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home; |
317 | if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home; |
328 | if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about; |
318 | if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about; |
329 | if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory(); |
319 | if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory(); |
330 | PostOpenPageActions(); |
320 | PostOpenPageActions(); |
331 | } |
321 | } |
332 | // - local file |
322 | // - local file |
333 | else if (check_is_the_adress_local(#address)==true) { |
323 | else if (check_is_the_adress_local(#address)==true) { |
334 | debugln("this is local address"); |
324 | debugln("this is local address"); |
335 | io.read(#address); |
325 | io.read(#address); |
336 | PostOpenPageActions(); |
326 | PostOpenPageActions(); |
337 | } |
327 | } |
338 | // - url |
328 | // - url |
339 | else { |
329 | else { |
340 | debugln("this is url"); |
330 | debugln("this is url"); |
341 | if (!strncmp(#address,"https://",8)) { |
331 | if (!strncmp(#address,"https://",8)) { |
342 | sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #address); |
332 | sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #address); |
343 | } |
333 | } |
344 | else if (!strncmp(#address,"http://",7)) { |
334 | else if (!strncmp(#address,"http://",7)) { |
345 | strlcpy(#getUrl, #address, UML); |
335 | strlcpy(#getUrl, #address, UML); |
346 | } |
336 | } |
347 | else { |
337 | else { |
348 | strcpy(#temp, "http://"); |
338 | strcpy(#temp, "http://"); |
349 | strlcpy(#temp, #address, UML); |
339 | strlcpy(#temp, #address, UML); |
350 | strlcpy(#address, #temp, UML); |
340 | strlcpy(#address, #temp, UML); |
351 | DrawAddressBox(); |
341 | DrawAddressBox(); |
352 | strlcpy(#getUrl, #address, UML); |
342 | strlcpy(#getUrl, #address, UML); |
353 | } |
343 | } |
354 | downloader.Start(#getUrl); |
344 | downloader.Start(#getUrl); |
355 | } |
345 | } |
356 | } |
346 | } |
357 | 347 | ||
358 | void PostOpenPageActions() |
348 | void PostOpenPageActions() |
359 | { |
349 | { |
360 | if (!io.buffer_data) { |
350 | if (!io.buffer_data) { |
361 | debugln("page not found"); |
351 | debugln("page not found"); |
362 | io.buffer_data = #buidin_page_not_found; |
352 | io.buffer_data = #buidin_page_not_found; |
363 | } |
353 | } |
364 | 354 | ||
365 | history.add(#address); |
355 | history.add(#address); |
366 | favicon.draw(address_box.left-18, address_box.top-1); |
356 | favicon.draw(address_box.left-18, address_box.top-1); |
367 | 357 | ||
368 | /* |
358 | /* |
369 | Great! So we have the page in our buffer. |
359 | Great! So we have the page in our buffer. |
370 | We don't know is it a plain text or html. |
360 | We don't know is it a plain text or html. |
371 | So we need to parse it and draw. |
361 | So we need to parse it and draw. |
372 | */ |
362 | */ |
373 | 363 | ||
374 | list.KeyHome(); |
364 | list.KeyHome(); |
375 | PreparePage(); |
365 | PreparePage(); |
376 | } |
366 | } |
377 | 367 | ||
378 | void EventMagnifyPlus() |
368 | void EventMagnifyPlus() |
379 | { |
369 | { |
380 | kfont.size.pt++; |
370 | kfont.size.pt++; |
381 | if(!kfont.changeSIZE()) |
371 | if(!kfont.changeSIZE()) |
382 | kfont.size.pt--; |
372 | kfont.size.pt--; |
383 | else |
373 | else |
384 | PreparePage(); |
374 | PreparePage(); |
385 | } |
375 | } |
386 | 376 | ||
387 | void EventMagnifyMinus() |
377 | void EventMagnifyMinus() |
388 | { |
378 | { |
389 | kfont.size.pt--; |
379 | kfont.size.pt--; |
390 | if(!kfont.changeSIZE()) |
380 | if(!kfont.changeSIZE()) |
391 | kfont.size.pt++; |
381 | kfont.size.pt++; |
392 | else |
382 | else |
393 | PreparePage(); |
383 | PreparePage(); |
394 | } |
384 | } |
395 | 385 | ||
396 | void EventRunEdit() |
386 | void EventRunEdit() |
397 | { |
387 | { |
398 | if (check_is_the_adress_local(history.current())==true) { |
388 | if (check_is_the_adress_local(history.current())==true) { |
399 | io.run(DEFAULT_EDITOR, history.current()); |
389 | io.run(DEFAULT_EDITOR, history.current()); |
400 | } |
390 | } |
401 | else { |
391 | else { |
402 | //io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check |
392 | //io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check |
403 | CreateFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); |
393 | CreateFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); |
404 | io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH); |
394 | io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH); |
405 | } |
395 | } |
406 | } |
396 | } |
407 | 397 | ||
408 | void EventChangeEncoding() |
398 | void EventChangeEncoding() |
409 | { |
399 | { |
410 | menu.selected = encoding + 1; |
400 | menu_id = 10; |
411 | menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
401 | open_lmenu(Form.left+Form.cwidth-36,Form.top+TOOLBAR_H+skin_height-6, MENU_ALIGN_TOP_RIGHT, |
- | 402 | encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); |
|
- | 403 | } |
|
- | 404 | ||
- | 405 | void EventShowSandwichMenu() |
|
- | 406 | { |
|
- | 407 | menu_id = 20; |
|
- | 408 | open_lmenu(Form.left+Form.cwidth+3,Form.top+TOOLBAR_H+skin_height-6, |
|
- | 409 | MENU_ALIGN_TOP_RIGHT, 0, SANDWICH_MENU); |
|
- | 410 | } |
|
- | 411 | ||
- | 412 | void EventMenuClick() |
|
- | 413 | { |
|
- | 414 | dword click_id = get_menu_click(); |
|
- | 415 | ||
- | 416 | if (menu_id == 10) && (click_id) { |
|
- | 417 | encoding = click_id-1; |
|
- | 418 | EventPageRefresh(); |
|
- | 419 | menu_id = 0; |
|
- | 420 | } |
|
- | 421 | if (menu_id == 20) {switch(click_id) { |
|
- | 422 | case 1: EventPageRefresh(); break; |
|
- | 423 | case 2: EventRunEdit(); break; |
|
- | 424 | case 3: EventShowHistory(); break; |
|
- | 425 | case 4: EventShowDownloader(); break; |
|
- | 426 | case 5: EventShowInfo(); break; |
|
- | 427 | } menu_id = 0;} |
|
412 | } |
428 | } |
413 | 429 | ||
414 | void EventShowInfo() { |
430 | void EventShowInfo() { |
415 | EventOpenAddress("aelia:about"); |
431 | EventOpenAddress("aelia:about"); |
416 | } |
432 | } |
417 | 433 | ||
418 | void EventShowHistory() |
434 | void EventShowHistory() |
419 | { |
435 | { |
420 | EventOpenAddress("aelia:history"); |
436 | EventOpenAddress("aelia:history"); |
421 | } |
437 | } |
422 | 438 | ||
423 | void EventGoBack() |
439 | void EventGoBack() |
424 | { |
440 | { |
425 | if (history.back()) EventOpenAddress(history.current()); |
441 | if (history.back()) EventOpenAddress(history.current()); |
426 | } |
442 | } |
427 | 443 | ||
428 | void EventGoForward() |
444 | void EventGoForward() |
429 | { |
445 | { |
430 | if (history.forward()) EventOpenAddress(history.current()); |
446 | if (history.forward()) EventOpenAddress(history.current()); |
431 | } |
447 | } |
432 | - | ||
433 | void EventShowSandwichMenu() |
- | |
434 | { |
- | |
435 | menu.selected = 0; |
- | |
436 | menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20); |
- | |
437 | } |
- | |
438 | 448 | ||
439 | void EventPageRefresh() |
449 | void EventPageRefresh() |
440 | { |
450 | { |
441 | EventOpenAddress(history.current()); |
451 | EventOpenAddress(history.current()); |
442 | } |
452 | } |
443 | 453 | ||
444 | void EventShowDownloader() |
454 | void EventShowDownloader() |
445 | { |
455 | { |
446 | if (!downloader_opened) { |
456 | if (!downloader_opened) { |
447 | downloader_edit = NULL; |
457 | downloader_edit = NULL; |
448 | CreateThread(#Downloader,#downloader_stak+4092); |
458 | CreateThread(#Downloader,#downloader_stak+4092); |
449 | } |
459 | } |
450 | } |
460 | } |
451 | 461 | ||
452 | void EventChangeDebugMode() |
462 | void EventChangeDebugMode() |
453 | { |
463 | { |
454 | debug_mode ^= 1; |
464 | debug_mode ^= 1; |
455 | if (debug_mode) notify("'Debug mode ON'-I"); |
465 | if (debug_mode) notify("'Debug mode ON'-I"); |
456 | else notify("'Debug mode OFF'-I"); |
466 | else notify("'Debug mode OFF'-I"); |
457 | return; |
467 | return; |
458 | } |
468 | } |
459 | 469 | ||
460 | /* ------------------------------------------- */ |
470 | /* ------------------------------------------- */ |
461 | 471 | ||
462 | 472 | ||
463 | void draw_window() |
473 | void draw_window() |
464 | { |
474 | { |
465 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
475 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
466 | GetProcessInfo(#Form, SelfInfo); |
476 | GetProcessInfo(#Form, SelfInfo); |
467 | if (Form.status_window>2) return; |
477 | if (Form.status_window>2) return; |
468 | 478 | ||
469 | if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; } |
479 | if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; } |
470 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
480 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
471 | 481 | ||
472 | system.color.get(); |
482 | system.color.get(); |
473 | 483 | ||
474 | list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, |
484 | list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, |
475 | Form.cheight-TOOLBAR_H-STATUSBAR_H, kfont.size.pt+4); |
485 | Form.cheight-TOOLBAR_H-STATUSBAR_H, kfont.size.pt+4); |
476 | 486 | ||
477 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1); |
487 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1); |
478 | DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece); |
488 | DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece); |
479 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F); |
489 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F); |
480 | 490 | ||
481 | DrawToolbarButton(GO_BACK, 8); |
491 | DrawToolbarButton(GO_BACK, 8); |
482 | DrawToolbarButton(GO_FORWARD, 33); |
492 | DrawToolbarButton(GO_FORWARD, 33); |
483 | DrawToolbarButton(OPEN_FILE, 68); |
493 | DrawToolbarButton(OPEN_FILE, 68); |
484 | DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 125); |
494 | DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 125); |
485 | DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 100); |
495 | DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 100); |
486 | DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64); |
496 | DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64); |
487 | DrawToolbarButton(SANDWICH, Form.cwidth - 31); |
497 | DrawToolbarButton(SANDWICH, Form.cwidth - 31); |
488 | 498 | ||
489 | DrawAddressBox(); |
499 | DrawAddressBox(); |
490 | 500 | ||
491 | if ((Form.cwidth-scroll.size_x-1 == list.w) && |
501 | if ((Form.cwidth-scroll.size_x-1 == list.w) && |
492 | (Form.cheight-TOOLBAR_H == list.h) && |
502 | (Form.cheight-TOOLBAR_H == list.h) && |
493 | (list.count) |
503 | (list.count) |
494 | ) |
504 | ) |
495 | { |
505 | { |
496 | DrawPage(); |
506 | DrawPage(); |
497 | } |
507 | } |
498 | else |
508 | else |
499 | { |
509 | { |
500 | if (!kfont.raw) { //this code need to be run |
510 | if (!kfont.raw) { //this code need to be run |
501 | if (param) EventOpenAddress(#param); //only once at browser sturtup |
511 | if (param) EventOpenAddress(#param); //only once at browser sturtup |
502 | else EventOpenAddress("aelia:home"); |
512 | else EventOpenAddress("aelia:home"); |
503 | } |
513 | } |
504 | else PreparePage(); |
514 | else PreparePage(); |
505 | } |
515 | } |
506 | 516 | ||
507 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
517 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
508 | DrawStatusBar(NULL); |
518 | DrawStatusBar(NULL); |
509 | } |
519 | } |
510 | 520 | ||
511 | void DrawPage() |
521 | void DrawPage() |
512 | { |
522 | { |
513 | list.CheckDoesValuesOkey(); |
523 | list.CheckDoesValuesOkey(); |
514 | if (list.count) { |
524 | if (list.count) { |
515 | kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w); |
525 | kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w); |
516 | } |
526 | } |
517 | DrawScroller(); |
527 | DrawScroller(); |
518 | } |
528 | } |
519 | 529 | ||
520 | void DrawAddressBox() |
530 | void DrawAddressBox() |
521 | { |
531 | { |
522 | address_box.left = 97+19; |
532 | address_box.left = 97+19; |
523 | address_box.top = 11; |
533 | address_box.top = 11; |
524 | address_box.width = Form.cwidth - address_box.left - 138; |
534 | address_box.width = Form.cwidth - address_box.left - 138; |
525 | DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C); |
535 | DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C); |
526 | DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color); |
536 | DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color); |
527 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address); |
537 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address); |
528 | address_box.offset = 0; |
538 | address_box.offset = 0; |
529 | edit_box_draw stdcall(#address_box); |
539 | edit_box_draw stdcall(#address_box); |
530 | favicon.draw(address_box.left-18, address_box.top-1); |
540 | favicon.draw(address_box.left-18, address_box.top-1); |
531 | DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff); |
541 | DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff); |
532 | } |
542 | } |
533 | 543 | ||
534 | PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0}; |
544 | PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0}; |
535 | void DrawStatusBar(dword _status_text) |
545 | void DrawStatusBar(dword _status_text) |
536 | { |
546 | { |
537 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work); |
547 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work); |
538 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, 0x8C8C8C); |
548 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, 0x8C8C8C); |
539 | 549 | ||
540 | if (_status_text) { |
550 | if (_status_text) { |
541 | status_text.start_x = 7; |
551 | status_text.start_x = 7; |
542 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
552 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
543 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
553 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
544 | status_text.font_color = system.color.work_text; |
554 | status_text.font_color = system.color.work_text; |
545 | status_text.text_pointer = _status_text; |
555 | status_text.text_pointer = _status_text; |
546 | PathShow_prepare stdcall(#status_text); |
556 | PathShow_prepare stdcall(#status_text); |
547 | PathShow_draw stdcall(#status_text); |
557 | PathShow_draw stdcall(#status_text); |
548 | } |
558 | } |
549 | }>>--->20)> |
559 | }>>---> |
- | 560 |