Rev 4693 | Rev 4719 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4693 | Rev 4718 | ||
---|---|---|---|
1 | //HTML Viewer in C-- |
1 | //HTML Viewer in C-- |
2 | //Copyright 2007-2013 by Veliant & Leency |
2 | //Copyright 2007-2013 by Veliant & Leency |
3 | //Asper, lev, Lrz, Barsuk, Nable... |
3 | //Asper, lev, Lrz, Barsuk, Nable... |
4 | //home icon - rachel fu, GPL licence |
4 | //home icon - rachel fu, GPL licence |
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 0x100000 |
11 | #define MEMSIZE 0x100000 |
12 | #include "..\lib\kolibri.h" |
12 | #include "..\lib\kolibri.h" |
13 | #include "..\lib\strings.h" |
13 | #include "..\lib\strings.h" |
14 | #include "..\lib\figures.h" |
14 | #include "..\lib\figures.h" |
15 | #include "..\lib\encoding.h" |
15 | #include "..\lib\encoding.h" |
16 | #include "..\lib\file_system.h" |
16 | #include "..\lib\file_system.h" |
17 | #include "..\lib\mem.h" |
17 | #include "..\lib\mem.h" |
18 | #include "..\lib\dll.h" |
18 | #include "..\lib\dll.h" |
19 | #include "..\lib\draw_buf.h" |
19 | #include "..\lib\draw_buf.h" |
20 | #include "..\lib\list_box.h" |
20 | #include "..\lib\list_box.h" |
21 | #include "..\lib\cursor.h" |
21 | #include "..\lib\cursor.h" |
22 | 22 | ||
23 | //*.obj libraries |
23 | //*.obj libraries |
24 | #include "..\lib\lib.obj\box_lib.h" |
24 | #include "..\lib\lib.obj\box_lib.h" |
25 | #include "..\lib\lib.obj\libio_lib.h" |
25 | #include "..\lib\lib.obj\libio_lib.h" |
26 | #include "..\lib\lib.obj\libimg_lib.h" |
26 | #include "..\lib\lib.obj\libimg_lib.h" |
27 | #include "..\lib\lib.obj\http.h" |
27 | #include "..\lib\lib.obj\http.h" |
28 | 28 | ||
29 | char homepage[] = FROM "html\homepage.htm"; |
29 | char homepage[] = FROM "html\homepage.htm"; |
30 | 30 | ||
31 | #ifdef LANG_RUS |
31 | #ifdef LANG_RUS |
32 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.0 Beta 3"; |
32 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.0 Beta 4"; |
33 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
33 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
34 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
34 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
35 | char loading[] = " £à㧪 áâà ¨æë... |
35 | char loading[] = " £à㧪 áâà ¨æë... |
36 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
36 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
37 | char accept_language[]= "Accept-Language: ru\n"; |
37 | char accept_language[]= "Accept-Language: ru\n"; |
38 | #else |
38 | #else |
39 | char version[]=" Text-based Browser 1.0 Beta 3"; |
39 | char version[]=" Text-based Browser 1.0 Beta 4"; |
40 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
40 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
41 | ?define T_LAST_SLIDE "This slide is the last" |
41 | ?define T_LAST_SLIDE "This slide is the last" |
42 | char loading[] = "Loading... |
42 | char loading[] = "Loading... |
43 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
43 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
44 | char accept_language[]= "Accept-Language: en\n"; |
44 | char accept_language[]= "Accept-Language: en\n"; |
45 | #endif |
45 | #endif |
46 | 46 | ||
47 | proc_info Form; |
47 | proc_info Form; |
48 | #define WIN_W 640 |
48 | #define WIN_W 640 |
49 | #define WIN_H 480 |
49 | #define WIN_H 480 |
50 | 50 | ||
51 | char search_path[]="http://nigma.ru/index.php?s="; |
51 | char search_path[]="http://nigma.ru/index.php?s="; |
52 | char str_location[]="location\0"; |
52 | char str_location[]="location\0"; |
53 | int redirected = 0; |
53 | int redirected = 0; |
54 | 54 | ||
55 | char stak[4096]; |
55 | char stak[4096]; |
56 | mouse m; |
56 | mouse m; |
57 | int action_buf; |
57 | int action_buf; |
58 | 58 | ||
59 | dword http_transfer = 0; |
59 | dword http_transfer = 0; |
60 | dword http_buffer; |
60 | dword http_buffer; |
61 | 61 | ||
62 | dword TAB_H = false; //19; |
62 | dword TAB_H = false; //19; |
63 | dword TAB_W = 150; |
63 | dword TAB_W = 150; |
64 | dword TOOLBAR_H = 31; //50; |
64 | dword TOOLBAR_H = 31; //50; |
65 | dword STATUSBAR_H =16; |
65 | dword STATUSBAR_H =15; |
66 | dword col_bg = 0xE4DFE1; |
66 | dword col_bg; |
67 | dword panel_color = 0xF1F1F1; |
67 | dword panel_color; |
68 | dword border_color = 0x9F9F9F; |
68 | dword border_color; |
69 | 69 | ||
- | 70 | pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; |
|
70 | pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; |
71 | byte souce_mode = false; |
71 | 72 | ||
72 | #include "..\TWB\TWB.c" |
73 | #include "..\TWB\TWB.c" |
73 | #include "menu_rmb.h" |
74 | #include "menu_rmb.h" |
74 | #include "history.h" |
75 | #include "history.h" |
- | 76 | #include "show_src.h" |
|
75 | 77 | ||
76 | char editURL[sizeof(URL)]; |
78 | char editURL[sizeof(URL)]; |
77 | int mouse_twb; |
79 | int mouse_twb; |
78 | edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
80 | edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
79 | 81 | ||
80 | #define URL_SERVICE_HISTORY "WebView://history" |
82 | #define URL_SERVICE_HISTORY "WebView://history" |
81 | #define URL_SERVICE_HOME "WebView://home" |
83 | #define URL_SERVICE_HOME "WebView://home" |
- | 84 | #define URL_SERVICE_SOURCE "WebView://source:" |
|
82 | 85 | ||
83 | enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN }; |
86 | enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN }; |
84 | 87 | ||
85 | struct skin { |
88 | struct struct_skin { |
- | 89 | dword image, w, h; |
|
86 | dword image, w, h; |
90 | int Load(); |
87 | } skin; |
91 | } skin; |
88 | 92 | ||
- | 93 | int struct_skin::Load() |
|
89 | int LoadSkin() |
94 | { |
90 | { |
95 | dword image_data; |
91 | skin.image = load_image(abspath("wv_skin.png")); |
96 | skin.image = load_image(abspath("wv_skin.png")); |
92 | if (!skin.image) notify("WebView skin file 'wv_skin.png' not found, program will terminate"); |
97 | if (!skin.image) notify("WebView skin file 'wv_skin.png' not found, program will terminate"); |
93 | skin.w = DSWORD[skin.image+4]; |
98 | skin.w = DSWORD[skin.image+4]; |
94 | skin.h = DSWORD[skin.image+8]; |
99 | skin.h = DSWORD[skin.image+8]; |
- | 100 | image_data = DSDWORD[skin.image+24]; |
|
- | 101 | ||
- | 102 | col_bg = DSDWORD[DSDWORD[skin.image+24]]; |
|
- | 103 | panel_color = DSDWORD[skin.w*4*4 + image_data]; |
|
- | 104 | border_color = DSDWORD[skin.w*4*7 + image_data]; |
|
- | 105 | progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data]; |
|
- | 106 | $and col_bg, 0x00ffffff |
|
- | 107 | $and panel_color, 0x00ffffff |
|
- | 108 | $and border_color, 0x00ffffff |
|
- | 109 | $and progress_bar.progress_color, 0x00ffffff |
|
95 | } |
110 | } |
96 | 111 | ||
97 | void DrawProgress() |
112 | void DrawProgress() |
98 | { |
113 | { |
99 | unsigned long btn; |
114 | unsigned long btn; |
100 | //progressbar_draw stdcall(#progress_bar); |
115 | //progressbar_draw stdcall(#progress_bar); |
101 | progress_bar.width = progress_bar.left = 0; |
116 | progress_bar.width = progress_bar.left = 0; |
102 | if (http_transfer == 0) return; |
117 | if (http_transfer == 0) return; |
103 | if (progress_bar.max) btn = address_box.width*progress_bar.value/progress_bar.max; else btn = 30; |
118 | if (progress_bar.max) btn = address_box.width*progress_bar.value/progress_bar.max; else btn = 30; |
104 | DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color); |
119 | DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color); |
105 | } |
120 | } |
- | 121 | ||
106 | 122 | ||
107 | void main() |
123 | void main() |
108 | { |
124 | { |
109 | unsigned long key, btn; |
125 | unsigned long key, btn; |
110 | int half_scroll_size; |
126 | int half_scroll_size; |
111 | int scroll_used=0, show_menu; |
127 | int scroll_used=0, show_menu; |
112 | 128 | ||
113 | mem_Init(); |
129 | mem_Init(); |
114 | CursorPointer.Load(#CursorFile); |
130 | CursorPointer.Load(#CursorFile); |
115 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); |
131 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); |
116 | if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); |
132 | if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); |
117 | if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); |
133 | if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); |
118 | if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http"); |
134 | if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http"); |
119 | LoadSkin(); |
135 | skin.Load(); |
120 | 136 | ||
121 | Form.width=WIN_W; |
137 | Form.width=WIN_W; |
122 | Form.height=WIN_H; |
138 | Form.height=WIN_H; |
123 | SetElementSizes(); |
139 | SetElementSizes(); |
124 | if (!URL) strcpy(#URL, URL_SERVICE_HOME); |
140 | if (!URL) strcpy(#URL, URL_SERVICE_HOME); |
125 | OpenPage(); |
141 | OpenPage(); |
126 | 142 | ||
127 | SetEventMask(0xa7); |
143 | SetEventMask(0xa7); |
128 | loop() |
144 | loop() |
129 | { |
145 | { |
130 | WaitEventTimeout(2); |
146 | WaitEventTimeout(2); |
131 | switch(EAX & 0xFF) |
147 | switch(EAX & 0xFF) |
132 | { |
148 | { |
133 | CASE evMouse: |
149 | CASE evMouse: |
134 | if (!CheckActiveProcess(Form.ID)) break; |
150 | if (!CheckActiveProcess(Form.ID)) break; |
135 | //Edit URL |
151 | //Edit URL |
136 | edit_box_mouse stdcall (#address_box); |
152 | edit_box_mouse stdcall (#address_box); |
137 | m.get(); |
153 | m.get(); |
138 | //Links hover |
154 | //Links hover |
139 | if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color); |
155 | if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color); |
140 | //Menu |
156 | //Menu |
141 | if (m.y>WB1.list.y) && (m.y |
157 | if (m.y>WB1.list.y) && (m.y |
142 | { |
158 | { |
143 | if (m.pkm) |
159 | if (m.pkm) |
144 | { |
160 | { |
145 | show_menu = 1; |
161 | show_menu = 1; |
146 | } |
162 | } |
147 | if (!m.pkm) && (show_menu) |
163 | if (!m.pkm) && (show_menu) |
148 | { |
164 | { |
149 | show_menu = 0; |
165 | show_menu = 0; |
150 | SwitchToAnotherThread(); |
166 | SwitchToAnotherThread(); |
151 | CreateThread(#menu_rmb,#stak+4092); |
167 | CreateThread(#menu_rmb,#stak+4092); |
152 | break; |
168 | break; |
153 | } |
169 | } |
154 | } |
170 | } |
155 | //Mouse scroll |
171 | //Mouse scroll |
156 | if (m.vert) |
172 | if (m.vert) |
157 | { |
173 | { |
158 | if (WB1.list.MouseScroll(m.vert)) WB1.Parse(); |
174 | if (WB1.list.MouseScroll(m.vert)) WB1.Parse(); |
159 | } |
175 | } |
160 | //Drag scroller |
176 | //Drag scroller |
161 | scroll_wv.all_redraw = 0; |
177 | scroll_wv.all_redraw = 0; |
162 | if (!m.lkm) scroll_used=0; |
178 | if (!m.lkm) scroll_used=0; |
163 | if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x) |
179 | if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x) |
164 | && (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y) |
180 | && (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y) |
165 | && (WB1.list.count>WB1.list.visible) && (m.lkm) |
181 | && (WB1.list.count>WB1.list.visible) && (m.lkm) |
166 | { |
182 | { |
167 | scroll_used=1; |
183 | scroll_used=1; |
168 | } |
184 | } |
169 | if (scroll_used) |
185 | if (scroll_used) |
170 | { |
186 | { |
171 | half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2; |
187 | half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2; |
172 | if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y; |
188 | if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y; |
173 | btn=WB1.list.first; |
189 | btn=WB1.list.first; |
174 | WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
190 | WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
175 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
191 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
176 | if (btn<>WB1.list.first) WB1.Parse(); |
192 | if (btn<>WB1.list.first) WB1.Parse(); |
177 | } |
193 | } |
178 | break; |
194 | break; |
179 | case evButton: |
195 | case evButton: |
180 | btn=GetButtonID(); |
196 | btn=GetButtonID(); |
181 | if (btn==1) ExitProcess(); |
197 | if (btn==1) ExitProcess(); |
182 | Scan(btn); |
198 | Scan(btn); |
183 | break; |
199 | break; |
184 | case evKey: |
200 | case evKey: |
185 | key = GetKey(); |
201 | key = GetKey(); |
186 | 202 | ||
187 | if (address_box.flags & 0b10) SWITCH(key) |
203 | if (address_box.flags & 0b10) SWITCH(key) |
188 | { CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } |
204 | { CASE 52: CASE 53: CASE 54: CASE 180: CASE 181: goto _EDIT_MARK; } |
189 | 205 | ||
190 | Scan(key); |
206 | Scan(key); |
191 | 207 | ||
192 | _EDIT_MARK: |
208 | _EDIT_MARK: |
193 | if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} |
209 | if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} |
194 | break; |
210 | break; |
195 | case evReDraw: |
211 | case evReDraw: |
196 | if (action_buf) Scan(action_buf); |
212 | if (action_buf) Scan(action_buf); |
197 | Draw_Window(); |
213 | Draw_Window(); |
198 | break; |
214 | break; |
199 | 215 | ||
200 | case evNetwork: |
216 | case evNetwork: |
201 | if (http_transfer > 0) { |
217 | if (http_transfer > 0) { |
202 | http_process stdcall (http_transfer); |
218 | http_process stdcall (http_transfer); |
203 | $push EAX |
219 | $push EAX |
204 | ESI = http_transfer; |
220 | ESI = http_transfer; |
205 | progress_bar.max = ESI.http_msg.content_length; |
221 | progress_bar.max = ESI.http_msg.content_length; |
206 | if (progress_bar.value != ESI.http_msg.content_received) |
222 | if (progress_bar.value != ESI.http_msg.content_received) |
207 | { |
223 | { |
208 | progress_bar.value = ESI.http_msg.content_received; |
224 | progress_bar.value = ESI.http_msg.content_received; |
209 | DrawProgress(); |
225 | DrawProgress(); |
210 | } |
226 | } |
211 | $pop EAX |
227 | $pop EAX |
212 | if (EAX == 0) { |
228 | if (EAX == 0) { |
213 | ESI = http_transfer; |
229 | ESI = http_transfer; |
214 | // Handle redirects |
230 | // Handle redirects |
215 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
231 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
216 | { |
232 | { |
217 | redirected++; |
233 | redirected++; |
218 | if (redirected<=5) |
234 | if (redirected<=5) |
219 | { |
235 | { |
220 | http_find_header_field stdcall (http_transfer, #str_location); |
236 | http_find_header_field stdcall (http_transfer, #str_location); |
221 | if (EAX!=0) { |
237 | if (EAX!=0) { |
222 | ESI = EAX; |
238 | ESI = EAX; |
223 | EDI = #URL; |
239 | EDI = #URL; |
224 | do { |
240 | do { |
225 | $lodsb; |
241 | $lodsb; |
226 | $stosb; |
242 | $stosb; |
227 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
243 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
228 | DSBYTE[EDI-1]='\0'; |
244 | DSBYTE[EDI-1]='\0'; |
229 | } |
245 | } |
230 | } |
246 | } |
231 | else |
247 | else |
232 | { |
248 | { |
233 | //TODO: display error (too many redirects) |
249 | //TODO: display error (too many redirects) |
234 | } |
250 | } |
235 | } |
251 | } |
236 | else |
252 | else |
237 | { |
253 | { |
238 | redirected = 0; |
254 | redirected = 0; |
239 | } |
255 | } |
240 | // Loading the page is complete, free resources |
256 | // Loading the page is complete, free resources |
241 | if (redirected>0) |
257 | if (redirected>0) |
242 | { |
258 | { |
243 | http_free stdcall (http_transfer); |
259 | http_free stdcall (http_transfer); |
244 | http_transfer=0; |
260 | http_transfer=0; |
245 | PageLinks.GetAbsoluteURL(#URL); |
261 | PageLinks.GetAbsoluteURL(#URL); |
246 | BrowserHistory.current--; |
262 | BrowserHistory.current--; |
247 | strcpy(#editURL, #URL); |
263 | strcpy(#editURL, #URL); |
248 | OpenPage(); |
264 | OpenPage(); |
249 | } |
265 | } |
250 | else |
266 | else |
251 | { |
267 | { |
252 | BrowserHistory.AddUrl(); |
268 | BrowserHistory.AddUrl(); |
253 | ESI = http_transfer; |
269 | ESI = http_transfer; |
254 | bufpointer = ESI.http_msg.content_ptr; |
270 | bufpointer = ESI.http_msg.content_ptr; |
255 | bufsize = ESI.http_msg.content_received; |
271 | bufsize = ESI.http_msg.content_received; |
256 | http_free stdcall (http_transfer); |
272 | http_free stdcall (http_transfer); |
257 | http_transfer=0; |
273 | http_transfer=0; |
258 | SetPageDefaults(); |
274 | SetPageDefaults(); |
259 | Draw_Window(); // stop button => refresh button |
275 | Draw_Window(); // stop button => refresh button |
260 | } |
276 | } |
261 | } |
277 | } |
262 | } |
278 | } |
263 | } |
279 | } |
264 | } |
280 | } |
265 | } |
281 | } |
266 | 282 | ||
267 | void SetElementSizes() |
283 | void SetElementSizes() |
268 | { |
284 | { |
269 | address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H; |
285 | address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H; |
270 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
286 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
271 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 10); |
287 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 11); |
272 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6; |
288 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6; |
273 | WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h; |
289 | WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h; |
274 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h); |
290 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h); |
275 | } |
291 | } |
276 | 292 | ||
277 | void Draw_Window() |
293 | void Draw_Window() |
278 | { |
294 | { |
279 | int img_off; |
295 | int img_off; |
280 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0); |
296 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0); |
281 | GetProcessInfo(#Form, SelfInfo); |
297 | GetProcessInfo(#Form, SelfInfo); |
282 | if (Form.status_window>2) { DrawTitle(#header); return; } |
298 | if (Form.status_window>2) { DrawTitle(#header); return; } |
283 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
299 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
284 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
300 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
285 | // tab { |
301 | // tab { |
286 | if (TAB_H) |
302 | if (TAB_H) |
287 | { |
303 | { |
288 | DrawBar(0, 0, TAB_W, TAB_H+1, panel_color); |
304 | DrawBar(0, 0, TAB_W, TAB_H+1, panel_color); |
289 | WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm"); |
305 | WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm"); |
290 | WriteText(4, 6, 0x80, 0, "Index.htm"); |
306 | WriteText(4, 6, 0x80, 0, "Index.htm"); |
291 | DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg); |
307 | DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg); |
292 | DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color); |
308 | DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color); |
293 | img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); |
309 | img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); |
294 | } |
310 | } |
295 | else DrawBar(0,0, Form.cwidth,1, col_bg); |
311 | else DrawBar(0,0, Form.cwidth,1, col_bg); |
296 | // } |
312 | // } |
297 | DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); |
313 | DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); |
298 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9); |
314 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9); |
299 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
315 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
300 | SetElementSizes(); |
316 | SetElementSizes(); |
301 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
317 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
302 | DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color); |
318 | DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color); |
303 | // < / > |
319 | // < / > |
304 | DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0); |
320 | DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0); |
305 | DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0); |
321 | DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0); |
306 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0); |
322 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0); |
307 | // refrash |
323 | // refrash |
308 | DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0); |
324 | DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0); |
309 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
325 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
310 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0); |
326 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0); |
311 | // config |
327 | // config |
312 | DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0); |
328 | DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0); |
313 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0); |
329 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0); |
314 | //status bar |
330 | //status bar |
315 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
331 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
316 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
332 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
317 | progress_bar.top = Form.cheight - STATUSBAR_H + 4; |
333 | progress_bar.top = Form.cheight - STATUSBAR_H + 4; |
318 | ShowPage(); |
334 | ShowPage(); |
319 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
335 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
320 | DrawProgress(); |
336 | DrawProgress(); |
321 | } |
337 | } |
322 | 338 | ||
323 | 339 | ||
324 | void ChangeCharset(byte new_charset) |
340 | void ChangeCharset(byte new_charset) |
325 | { |
341 | { |
326 | BufEncode(new_charset); |
342 | BufEncode(new_charset); |
327 | WB1.Parse(); |
343 | WB1.Parse(); |
328 | } |
344 | } |
329 | 345 | ||
330 | void Scan(int id) |
346 | void Scan(int id) |
331 | { |
347 | { |
332 | action_buf=0; |
348 | action_buf=0; |
333 | if (id >= 400) |
349 | if (id >= 400) |
334 | { |
350 | { |
335 | ProcessLinks(id); |
351 | ProcessLinks(id); |
336 | return; |
352 | return; |
337 | } |
353 | } |
338 | switch (id) |
354 | switch (id) |
339 | { |
355 | { |
340 | case 011: //Ctrk+K |
356 | case 011: //Ctrk+K |
341 | ChangeCharset(_KOI); |
357 | ChangeCharset(_KOI); |
342 | return; |
358 | return; |
343 | 359 | ||
344 | case 021: //Ctrl+U |
360 | case 021: //Ctrl+U |
345 | ChangeCharset(_UTF); |
361 | ChangeCharset(_UTF); |
346 | return; |
362 | return; |
347 | 363 | ||
348 | case 004: //Ctrl+D |
364 | case 004: //Ctrl+D |
349 | ChangeCharset(_DOS); |
365 | ChangeCharset(_DOS); |
350 | return; |
366 | return; |
351 | 367 | ||
352 | case 005: //Win encoding |
368 | case 005: //Win encoding |
353 | ChangeCharset(_WIN); |
369 | ChangeCharset(_WIN); |
354 | return; |
370 | return; |
355 | 371 | ||
356 | case 009: //free img cache |
372 | case 009: //free img cache |
357 | ImgCache.Free(); |
373 | ImgCache.Free(); |
358 | notify(IMAGES_CACHE_CLEARED); |
374 | notify(IMAGES_CACHE_CLEARED); |
359 | WB1.Parse(); |
375 | WB1.Parse(); |
360 | return; |
376 | return; |
361 | 377 | ||
362 | case 003: //history |
378 | case 003: //history |
363 | strcpy(#URL, URL_SERVICE_HISTORY); |
379 | strcpy(#URL, URL_SERVICE_HISTORY); |
364 | OpenPage(); |
380 | OpenPage(); |
365 | return; |
381 | return; |
366 | 382 | ||
367 | case BACK: |
383 | case BACK: |
368 | if (!BrowserHistory.GoBack()) return; |
384 | if (!BrowserHistory.GoBack()) return; |
369 | OpenPage(); |
385 | OpenPage(); |
370 | return; |
386 | return; |
371 | case FORWARD: |
387 | case FORWARD: |
372 | if (!BrowserHistory.GoForward()) return; |
388 | if (!BrowserHistory.GoForward()) return; |
373 | OpenPage(); |
389 | OpenPage(); |
374 | return; |
390 | return; |
375 | case 052: //F3 |
391 | case 052: //F3 |
- | 392 | ShowSource(); |
|
- | 393 | break; |
|
- | 394 | case 053: //F4 |
|
376 | if (strncmp(#URL,"http:",5)==0) |
395 | if (strncmp(#URL,"http:",5)==0) |
377 | { |
396 | { |
378 | WriteFile(bufsize, bufpointer, "/tmp0/1/webview.tmp"); |
397 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
379 | if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/webview.tmp"); |
398 | if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
380 | } |
399 | } |
381 | else |
400 | else |
382 | { |
401 | { |
383 | RunProgram("/rd/1/tinypad", #URL); |
402 | RunProgram("/rd/1/tinypad", #URL); |
384 | } |
403 | } |
385 | return; |
404 | return; |
386 | case 054: //F5 |
405 | case 054: //F5 |
387 | IF(address_box.flags & 0b10) return; |
406 | IF(address_box.flags & 0b10) return; |
388 | case REFRESH: |
407 | case REFRESH: |
389 | if (http_transfer > 0) |
408 | if (http_transfer > 0) |
390 | { |
409 | { |
391 | StopLoading(); |
410 | StopLoading(); |
392 | Draw_Window(); |
411 | Draw_Window(); |
393 | } |
412 | } |
394 | else OpenPage(); |
413 | else OpenPage(); |
395 | return; |
414 | return; |
396 | case 014: |
415 | case 014: |
397 | case 020: |
416 | case 020: |
398 | case NEWTAB: |
417 | case NEWTAB: |
399 | MoveSize(190,80,OLD,OLD); |
418 | MoveSize(190,80,OLD,OLD); |
400 | RunProgram(#program_path, #URL); |
419 | RunProgram(#program_path, #URL); |
401 | return; |
420 | return; |
402 | 421 | ||
403 | case HOME: |
422 | case HOME: |
404 | strcpy(#editURL, "http://kolibrios.org/"); |
423 | strcpy(#editURL, "http://kolibrios.org/"); |
405 | case GOTOURL: |
424 | case GOTOURL: |
406 | case 0x0D: //enter |
425 | case 0x0D: //enter |
- | 426 | if (!editURL[0]) return; |
|
407 | if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0)) |
427 | if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0)) |
408 | { |
428 | { |
409 | strcpy(#URL,"http://"); |
429 | strcpy(#URL,"http://"); |
410 | } |
430 | } |
411 | else |
431 | else |
412 | URL[0] = 0; |
432 | URL[0] = 0; |
413 | strcat(#URL, #editURL); |
433 | strcat(#URL, #editURL); |
414 | OpenPage(); |
434 | OpenPage(); |
415 | return; |
435 | return; |
416 | case SEARCHWEB: |
436 | case SEARCHWEB: |
417 | strcpy(#URL, #search_path); |
437 | strcpy(#URL, #search_path); |
418 | strcat(#URL, #editURL); |
438 | strcat(#URL, #editURL); |
419 | OpenPage(); |
439 | OpenPage(); |
420 | return; |
440 | return; |
421 | 441 | ||
422 | case 183: //PgDown |
442 | case 183: //PgDown |
423 | if (WB1.list.count < WB1.list.visible) return; |
443 | if (WB1.list.count < WB1.list.visible) return; |
424 | IF(WB1.list.first == WB1.list.count - WB1.list.visible) return; |
444 | IF(WB1.list.first == WB1.list.count - WB1.list.visible) return; |
425 | WB1.list.first += WB1.list.visible + 2; |
445 | WB1.list.first += WB1.list.visible + 2; |
426 | IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible; |
446 | IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible; |
427 | WB1.Parse(); |
447 | WB1.Parse(); |
428 | return; |
448 | return; |
429 | 449 | ||
430 | case 184: //PgUp |
450 | case 184: //PgUp |
431 | if (WB1.list.count < WB1.list.visible) return; |
451 | if (WB1.list.count < WB1.list.visible) return; |
432 | IF(WB1.list.first == 0) return; |
452 | IF(WB1.list.first == 0) return; |
433 | WB1.list.first -= WB1.list.visible - 2; |
453 | WB1.list.first -= WB1.list.visible - 2; |
434 | IF(WB1.list.first < 0) WB1.list.first = 0; |
454 | IF(WB1.list.first < 0) WB1.list.first = 0; |
435 | WB1.Parse(); |
455 | WB1.Parse(); |
436 | return; |
456 | return; |
437 | 457 | ||
438 | case 178: |
458 | case 178: |
439 | case BTN_UP: |
459 | case BTN_UP: |
440 | if (WB1.list.first <= 0) return; |
460 | if (WB1.list.first <= 0) return; |
441 | WB1.list.first--; |
461 | WB1.list.first--; |
442 | WB1.Parse(); |
462 | WB1.Parse(); |
443 | return; |
463 | return; |
444 | 464 | ||
445 | case 177: |
465 | case 177: |
446 | case BTN_DOWN: |
466 | case BTN_DOWN: |
447 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
467 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
448 | WB1.list.first++; |
468 | WB1.list.first++; |
449 | WB1.Parse(); |
469 | WB1.Parse(); |
450 | return; |
470 | return; |
451 | 471 | ||
452 | case 180: //home |
472 | case 180: //home |
453 | if (WB1.list.KeyHome()) WB1.Parse(); |
473 | if (WB1.list.KeyHome()) WB1.Parse(); |
454 | return; |
474 | return; |
455 | 475 | ||
456 | case 181: //end |
476 | case 181: //end |
457 | if (WB1.list.count < WB1.list.visible) return; |
477 | if (WB1.list.count < WB1.list.visible) return; |
458 | if (WB1.list.KeyEnd()) WB1.Parse(); |
478 | if (WB1.list.KeyEnd()) WB1.Parse(); |
459 | return; |
479 | return; |
460 | case 312: |
480 | case 312: |
461 | SwitchToAnotherThread(); |
481 | SwitchToAnotherThread(); |
462 | m.y = TOOLBAR_H-6; |
482 | m.y = TOOLBAR_H-6; |
463 | m.x = Form.cwidth - 167; |
483 | m.x = Form.cwidth - 167; |
464 | CreateThread(#menu_rmb,#stak+4092); |
484 | CreateThread(#menu_rmb,#stak+4092); |
465 | } |
485 | } |
466 | } |
486 | } |
467 | 487 | ||
468 | 488 | ||
469 | 489 | ||
470 | void ProcessLinks(int id) |
490 | void ProcessLinks(int id) |
471 | { |
491 | { |
472 | if (http_transfer > 0) |
492 | if (http_transfer > 0) |
473 | { |
493 | { |
474 | StopLoading(); |
494 | StopLoading(); |
475 | BrowserHistory.current--; |
495 | BrowserHistory.current--; |
476 | } |
496 | } |
477 | 497 | ||
478 | strcpy(#URL, PageLinks.GetURL(id-401)); |
498 | strcpy(#URL, PageLinks.GetURL(id-401)); |
479 | //$1 - Condition Script |
499 | //$1 - Condition Script |
480 | if (URL[0] == '$') |
500 | if (URL[0] == '$') |
481 | { |
501 | { |
482 | if (URL[1]=='-') && (condition_href) condition_href--; |
502 | if (URL[1]=='-') && (condition_href) condition_href--; |
483 | if (URL[1]=='+') |
503 | if (URL[1]=='+') |
484 | { |
504 | { |
485 | if (condition_href |
505 | if (condition_href |
486 | } |
506 | } |
487 | if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1); |
507 | if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1); |
488 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
508 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
489 | ShowPage(); |
509 | ShowPage(); |
490 | return; |
510 | return; |
491 | } |
511 | } |
492 | //#1 |
512 | //#1 |
493 | if (URL[0] == '#') |
513 | if (URL[0] == '#') |
494 | { |
514 | { |
495 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
515 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
496 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
516 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
497 | WB1.list.first=WB1.list.count-WB1.list.visible; |
517 | WB1.list.first=WB1.list.count-WB1.list.visible; |
498 | ShowPage(); |
518 | ShowPage(); |
499 | return; |
519 | return; |
500 | } |
520 | } |
501 | //liner.ru#1 |
521 | //liner.ru#1 |
502 | if (strrchr(#URL, '#')!=-1) |
522 | if (strrchr(#URL, '#')!=-1) |
503 | { |
523 | { |
504 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
524 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
505 | URL[strrchr(#URL, '#')-1] = 0x00; |
525 | URL[strrchr(#URL, '#')-1] = 0x00; |
506 | } |
526 | } |
507 | 527 | ||
508 | PageLinks.GetAbsoluteURL(#URL); |
528 | PageLinks.GetAbsoluteURL(#URL); |
509 | 529 | ||
510 | if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) |
530 | if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) |
511 | { |
531 | { |
512 | //if (strstr(#URL,"http:")) |
532 | //if (strstr(#URL,"http:")) |
513 | RunProgram("/sys/media/kiv", #URL); |
533 | RunProgram("/sys/media/kiv", #URL); |
514 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
534 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
515 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
535 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
516 | return; |
536 | return; |
517 | } |
537 | } |
518 | if (!strcmpn(#URL,"mailto:", 7)) |
538 | if (!strcmpn(#URL,"mailto:", 7)) |
519 | { |
539 | { |
520 | notify(#URL); |
540 | notify(#URL); |
521 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
541 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
522 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
542 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
523 | return; |
543 | return; |
524 | } |
544 | } |
525 | OpenPage(); |
545 | OpenPage(); |
526 | return; |
546 | return; |
527 | } |
547 | } |
528 | 548 | ||
529 | void StopLoading() |
549 | void StopLoading() |
530 | { |
550 | { |
531 | if (http_transfer<>0) |
551 | if (http_transfer<>0) |
532 | { |
552 | { |
533 | EAX = http_transfer; |
553 | EAX = http_transfer; |
534 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
554 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
535 | $push EAX // save it on the stack |
555 | $push EAX // save it on the stack |
536 | http_free stdcall (http_transfer); // abort connection |
556 | http_free stdcall (http_transfer); // abort connection |
537 | $pop EAX |
557 | $pop EAX |
538 | mem_Free(EAX); // free data |
558 | mem_Free(EAX); // free data |
539 | http_transfer=0; |
559 | http_transfer=0; |
540 | bufsize = 0; |
560 | bufsize = 0; |
541 | bufpointer = mem_Free(bufpointer); |
561 | bufpointer = mem_Free(bufpointer); |
542 | } |
562 | } |
543 | progress_bar.value = 0; |
563 | progress_bar.value = 0; |
544 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0); |
564 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0); |
545 | } |
565 | } |
546 | 566 | ||
547 | void SetPageDefaults() |
567 | void SetPageDefaults() |
548 | { |
568 | { |
549 | strcpy(#header, #version); |
569 | strcpy(#header, #version); |
550 | pre_text = 0; |
570 | pre_text = 0; |
551 | WB1.list.count = WB1.list.first = 0; |
571 | WB1.list.count = WB1.list.first = 0; |
552 | stroka = 0; |
572 | stroka = 0; |
553 | cur_encoding = _DEFAULT; |
573 | cur_encoding = _DEFAULT; |
554 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
574 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
555 | anchor_line_num=WB1.list.first; |
575 | anchor_line_num=WB1.list.first; |
556 | anchor[0]='|'; |
576 | anchor[0]='|'; |
557 | } |
577 | } |
558 | 578 | ||
559 | void OpenPage() |
579 | void OpenPage() |
560 | { |
580 | { |
561 | StopLoading(); |
581 | StopLoading(); |
- | 582 | souce_mode = false; |
|
562 | strcpy(#editURL, #URL); |
583 | strcpy(#editURL, #URL); |
563 | BrowserHistory.AddUrl(); |
584 | BrowserHistory.AddUrl(); |
564 | if (strncmp(#URL,"WebView:",8)==0) |
585 | if (strncmp(#URL,"WebView:",8)==0) |
565 | { |
586 | { |
566 | SetPageDefaults(); |
587 | SetPageDefaults(); |
567 | if (strcmp(#URL, URL_SERVICE_HOME)==0) |
588 | if (strcmp(#URL, URL_SERVICE_HOME)==0) |
568 | { |
589 | { |
569 | WB1.Prepare(#homepage, sizeof(homepage)); |
590 | WB1.Prepare(#homepage, sizeof(homepage)); |
570 | } |
591 | } |
571 | if (strcmp(#URL, URL_SERVICE_HISTORY)==0) |
592 | if (strcmp(#URL, URL_SERVICE_HISTORY)==0) |
572 | { |
593 | { |
573 | ShowHistory(); |
594 | ShowHistory(); |
574 | } |
595 | } |
575 | return; |
596 | return; |
576 | } |
597 | } |
577 | if (strncmp(#URL,"http:",5)==0) |
598 | if (strncmp(#URL,"http:",5)==0) |
578 | { |
599 | { |
579 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0); |
600 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0); |
580 | http_get stdcall (#URL, #accept_language); |
601 | http_get stdcall (#URL, #accept_language); |
581 | http_transfer = EAX; |
602 | http_transfer = EAX; |
582 | if (http_transfer == 0) |
603 | if (http_transfer == 0) |
583 | { |
604 | { |
584 | StopLoading(); |
605 | StopLoading(); |
585 | bufsize = 0; |
606 | bufsize = 0; |
586 | bufpointer = mem_Free(bufpointer); |
607 | bufpointer = mem_Free(bufpointer); |
587 | ShowPage(); |
608 | ShowPage(); |
588 | return; |
609 | return; |
589 | } |
610 | } |
590 | } |
611 | } |
591 | else |
612 | else |
592 | { |
613 | { |
593 | file_size stdcall (#URL); |
614 | file_size stdcall (#URL); |
594 | bufsize = EBX; |
615 | bufsize = EBX; |
595 | if (bufsize) |
616 | if (bufsize) |
596 | { |
617 | { |
597 | bufpointer = mem_Free(bufpointer); |
618 | mem_Free(bufpointer); |
598 | bufpointer = mem_Alloc(bufsize); |
619 | bufpointer = mem_Alloc(bufsize); |
599 | SetPageDefaults(); |
620 | SetPageDefaults(); |
600 | ReadFile(0, bufsize, bufpointer, #URL); |
621 | ReadFile(0, bufsize, bufpointer, #URL); |
- | 622 | //ShowSource(); |
|
601 | } |
623 | } |
602 | ShowPage(); |
624 | ShowPage(); |
603 | } |
625 | } |
604 | } |
626 | } |
605 | 627 | ||
606 | void ShowPage() |
628 | DrawEditBox() |
607 | { |
629 | { |
608 | address_box.size = address_box.pos = strlen(#editURL); |
630 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
609 | address_box.offset=0; |
631 | address_box.offset = 0; |
- | 632 | edit_box_draw stdcall(#address_box); |
|
- | 633 | } |
|
- | 634 | ||
- | 635 | ||
- | 636 | void ShowPage() |
|
610 | edit_box_draw stdcall(#address_box); |
637 | { |
611 | 638 | DrawEditBox(); |
|
612 | if (!bufsize) |
639 | if (!bufsize) |
613 | { |
640 | { |
614 | PageLinks.Clear(); |
641 | PageLinks.Clear(); |
615 | if (http_transfer<>0) |
642 | if (http_transfer<>0) |
616 | { |
643 | { |
617 | WB1.Prepare(#loading, sizeof(loading)); |
644 | WB1.Prepare(#loading, sizeof(loading)); |
618 | } |
645 | } |
619 | else |
646 | else |
620 | WB1.Prepare(#page_not_found, sizeof(page_not_found)); |
647 | WB1.Prepare(#page_not_found, sizeof(page_not_found)); |
621 | } |
648 | } |
622 | else |
649 | else |
623 | WB1.Parse(); |
650 | WB1.Parse(); |
624 | 651 | ||
625 | if (!header) strcpy(#header, #version); |
652 | if (!header) strcpy(#header, #version); |
626 | if (!strcmp(#version, #header)) DrawTitle(#header); |
653 | if (!strcmp(#version, #header)) DrawTitle(#header); |
627 | } |
654 | } |
628 | 655 | ||
629 | 656 | ||
630 | 657 | ||
631 | 658 | ||
632 | stop:>>>=>>>>>280)>120)>=5) |
659 | stop:>>>=>>>>>280)>120)>=5) |
633 | >>8;><8;>>>>>0)>=scroll_wv.start_x+scroll_wv.size_x)> |
660 | >>8;><8;>>>>>0)>=scroll_wv.start_x+scroll_wv.size_x)> |