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