Rev 2884 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2884 | Rev 2895 | ||
---|---|---|---|
1 | int downloader_id; |
1 | int downloader_id; |
2 | 2 | ||
3 | dword |
3 | dword |
4 | buf, |
4 | buf, |
5 | filesize, |
5 | filesize, |
6 | blink; |
6 | blink; |
7 | 7 | ||
8 | char download_path[]="/rd/1/.download"; |
8 | char download_path[]="/rd/1/.download"; |
9 | char search_path[]="http://nigma.ru/index.php?s="; |
9 | char search_path[]="http://nigma.ru/index.php?s="; |
10 | char version[]=" Text-based Browser 0.96d"; |
10 | char version[]=" Text-based Browser 0.97"; |
11 | 11 | ||
12 | 12 | ||
13 | struct TWebBrowser { |
13 | struct TWebBrowser { |
14 | int left, top, width, height; |
14 | int left, top, width, height; |
15 | void Scan(int); |
15 | void Scan(int); |
16 | void GetNewUrl(); |
16 | void GetNewUrl(); |
17 | void OpenPage(); |
17 | void OpenPage(); |
18 | void ReadHtml(byte); |
18 | void ReadHtml(byte); |
19 | void ShowPage(); |
19 | void ShowPage(); |
20 | void ParseHTML(dword); |
20 | void ParseHTML(dword); |
21 | void WhatTextStyle(int left1, top1, width1); |
21 | void WhatTextStyle(int left1, top1, width1); |
22 | void DrawPage(); |
22 | void DrawPage(); |
23 | void DrawScroller(); |
23 | void DrawScroller(); |
24 | }; |
24 | }; |
25 | 25 | ||
26 | TWebBrowser WB1; |
26 | TWebBrowser WB1; |
27 | 27 | ||
28 | byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, |
28 | byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, |
29 | link, ignor_text, li_tab, first_line_drawed; |
29 | link, ignor_text, li_tab, first_line_drawed; |
30 | 30 | ||
31 | 31 | ||
32 | dword text_colors[300], |
32 | dword text_colors[300], |
33 | text_color_index, |
33 | text_color_index, |
34 | link_color, |
34 | link_color, |
35 | bg_color; |
35 | bg_color; |
36 | 36 | ||
37 | int stroka, |
37 | int stroka, |
38 | stolbec, |
38 | stolbec, |
39 | tab_len; |
39 | tab_len; |
40 | 40 | ||
41 | char anchor[256]; |
41 | char anchor[256]; |
42 | int anchor_line_num; |
42 | int anchor_line_num; |
43 | 43 | ||
44 | char line[500], |
44 | char line[500], |
45 | tag[100], |
45 | tag[100], |
46 | tagparam[10000], |
46 | tagparam[10000], |
47 | parametr[1200], |
47 | parametr[1200], |
48 | options[4096]; |
48 | options[4096]; |
49 | 49 | ||
50 | #include "include\history.h" |
50 | #include "include\history.h" |
51 | #include "include\colors.h" |
51 | #include "include\colors.h" |
52 | #include "include\unicode_tags.h" |
52 | #include "include\unicode_tags.h" |
53 | #include "include\some_code.h" |
53 | #include "include\some_code.h" |
54 | #include "include\parce_tag.h" |
54 | #include "include\parce_tag.h" |
55 | 55 | ||
56 | 56 | ||
57 | void TWebBrowser::Scan(int id) |
57 | void TWebBrowser::Scan(int id) |
58 | { |
58 | { |
59 | if (id >= 400) |
59 | if (id >= 400) |
60 | { |
60 | { |
61 | GetURLfromPageLinks(id); |
61 | GetURLfromPageLinks(id); |
62 | 62 | ||
63 | //#1 |
63 | //#1 |
64 | if (URL[0] == '#') |
64 | if (URL[0] == '#') |
65 | { |
65 | { |
66 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
66 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
67 | 67 | ||
68 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
68 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
69 | 69 | ||
70 | lines.first=lines.all-lines.visible; |
70 | lines.first=lines.all-lines.visible; |
71 | ShowPage(); |
71 | ShowPage(); |
72 | return; |
72 | return; |
73 | } |
73 | } |
74 | //liner.ru#1 |
74 | //liner.ru#1 |
75 | if (strrchr(#URL, '#')<>-1) |
75 | if (strrchr(#URL, '#')<>-1) |
76 | { |
76 | { |
77 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
77 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
78 | URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà |
78 | URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà |
79 | } |
79 | } |
80 | 80 | ||
81 | GetNewUrl(); |
81 | GetNewUrl(); |
82 | 82 | ||
83 | if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) |
83 | if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) |
84 | { |
84 | { |
85 | //if (strstr(#URL,"http:")) |
85 | //if (strstr(#URL,"http:")) |
86 | RunProgram("/sys/media/kiv", #URL); |
86 | RunProgram("/sys/media/kiv", #URL); |
87 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
87 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
88 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
88 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
89 | return; |
89 | return; |
90 | } |
90 | } |
91 | if (!strcmpn(#URL,"mailto:", 7)) |
91 | if (!strcmpn(#URL,"mailto:", 7)) |
92 | { |
92 | { |
93 | RunProgram("@notify", #URL); |
93 | RunProgram("@notify", #URL); |
94 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
94 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
95 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
95 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
96 | return; |
96 | return; |
97 | } |
97 | } |
98 | 98 | ||
99 | OpenPage(); |
99 | OpenPage(); |
100 | return; |
100 | return; |
101 | } |
101 | } |
102 | 102 | ||
103 | IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè |
103 | IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè |
104 | { CASE 183: CASE 184: CASE 180: CASE 181: return; } |
104 | { CASE 183: CASE 184: CASE 180: CASE 181: return; } |
105 | 105 | ||
106 | switch (id) |
106 | switch (id) |
107 | { |
107 | { |
108 | case 011: //Ctrk+K |
108 | case 011: //Ctrk+K |
109 | ReadHtml(_KOI); |
109 | ReadHtml(_KOI); |
110 | break; |
110 | break; |
111 | case 021: //Ctrl+U |
111 | case 021: //Ctrl+U |
112 | ReadHtml(_UTF); |
112 | ReadHtml(_UTF); |
113 | break; |
113 | break; |
114 | case 004: //Ctrl+D |
114 | case 004: //Ctrl+D |
115 | ReadHtml(_DOS); |
115 | ReadHtml(_DOS); |
116 | break; |
116 | break; |
117 | case 001: |
117 | case 001: |
118 | if (!pre_text) pre_text=2; |
118 | if (!pre_text) pre_text=2; |
119 | else pre_text=0; |
119 | else pre_text=0; |
120 | break; |
120 | break; |
121 | case BACK: |
121 | case BACK: |
122 | if (!BrowserHistory.GoBack()) return; |
122 | if (!BrowserHistory.GoBack()) return; |
123 | OpenPage(); |
123 | OpenPage(); |
124 | return; |
124 | return; |
125 | case FORWARD: |
125 | case FORWARD: |
126 | if (!BrowserHistory.GoForward()) return; |
126 | if (!BrowserHistory.GoForward()) return; |
127 | OpenPage(); |
127 | OpenPage(); |
128 | return; |
128 | return; |
129 | case 052: //Íàæàòà F3 |
129 | case 052: //Íàæàòà F3 |
130 | if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path); |
130 | if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path); |
131 | return; |
131 | return; |
132 | case 053: //Íàæàòà F4 |
132 | case 053: //Íàæàòà F4 |
133 | if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/develop/t_edit", #URL); else RunProgram("/rd/1/develop/t_edit", #download_path); |
133 | if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/develop/t_edit", #URL); else RunProgram("/rd/1/develop/t_edit", #download_path); |
134 | return; |
134 | return; |
135 | case 054: //F5 |
135 | case 054: //F5 |
136 | IF(edit1.flags == 66) break; |
136 | IF(edit1.flags == 66) break; |
137 | case REFRESH: |
137 | case REFRESH: |
138 | if (GetProcessSlot(downloader_id)<>0) |
138 | if (GetProcessSlot(downloader_id)<>0) |
139 | { |
139 | { |
140 | KillProcess(downloader_id); |
140 | KillProcess(downloader_id); |
141 | Pause(20); |
141 | Pause(20); |
142 | Draw_Window(); |
142 | Draw_Window(); |
143 | return; |
143 | return; |
144 | } |
144 | } |
145 | anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð |
145 | anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð |
146 | anchor[0]='|'; |
146 | anchor[0]='|'; |
147 | OpenPage(); |
147 | OpenPage(); |
148 | return; |
148 | return; |
149 | case 014: //Ctrl+N íîâîå îêíî |
149 | case 014: //Ctrl+N íîâîå îêíî |
150 | case 020: //Ctrl+T íîâàÿ âêëàäêà |
150 | case 020: //Ctrl+T íîâàÿ âêëàäêà |
151 | case NEWTAB: |
151 | case NEWTAB: |
152 | MoveSize(190,80,OLD,OLD); |
152 | MoveSize(190,80,OLD,OLD); |
153 | RunProgram(#program_path, #URL); |
153 | RunProgram(#program_path, #URL); |
154 | return; |
154 | return; |
155 | 155 | ||
156 | case HOME: |
156 | case HOME: |
157 | strcpy(#editURL, "http://kolibri-os.narod.ru"); |
157 | strcpy(#editURL, "http://kolibri-os.narod.ru"); |
158 | case GOTOURL: |
158 | case GOTOURL: |
159 | case 0x0D: //enter |
159 | case 0x0D: //enter |
160 | strcpy(#URL, #editURL); |
160 | strcpy(#URL, #editURL); |
161 | OpenPage(); |
161 | OpenPage(); |
162 | return; |
162 | return; |
163 | case 173: //ctrl+enter |
163 | case 173: //ctrl+enter |
164 | case SEARCHWEB: |
164 | case SEARCHWEB: |
165 | strcpy(#URL, #search_path); |
165 | strcpy(#URL, #search_path); |
166 | strcat(#URL, #editURL); |
166 | strcat(#URL, #editURL); |
167 | OpenPage(); |
167 | OpenPage(); |
168 | return; |
168 | return; |
169 | 169 | ||
170 | case ID1: //ìîòàåì ââåðõ |
170 | case ID1: //ìîòàåì ââåðõ |
171 | IF(lines.first <= 0) return; |
171 | IF(lines.first <= 0) return; |
172 | lines.first--; |
172 | lines.first--; |
173 | break; |
173 | break; |
174 | case ID2: //ìîòàåì âíèç |
174 | case ID2: //ìîòàåì âíèç |
175 | IF(lines.visible + lines.first >= lines.all) return; |
175 | IF(lines.visible + lines.first >= lines.all) return; |
176 | lines.first++; |
176 | lines.first++; |
177 | break; |
177 | break; |
178 | case 183: //PgDown |
178 | case 183: //PgDown |
179 | IF(lines.first == lines.all - lines.visible) return; |
179 | IF(lines.first == lines.all - lines.visible) return; |
180 | lines.first += lines.visible + 2; |
180 | lines.first += lines.visible + 2; |
181 | IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible; |
181 | IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible; |
182 | BREAK; |
182 | BREAK; |
183 | case 184: //PgUp |
183 | case 184: //PgUp |
184 | IF(lines.first == 0) RETURN; |
184 | IF(lines.first == 0) RETURN; |
185 | lines.first -= lines.visible - 2; |
185 | lines.first -= lines.visible - 2; |
186 | IF(lines.first < 0) lines.first = 0; |
186 | IF(lines.first < 0) lines.first = 0; |
187 | BREAK; |
187 | BREAK; |
188 | case 180: //home |
188 | case 180: //home |
189 | IF(lines.first == 0) RETURN; |
189 | IF(lines.first == 0) RETURN; |
190 | lines.first = 0; |
190 | lines.first = 0; |
191 | BREAK; |
191 | BREAK; |
192 | case 181: //end |
192 | case 181: //end |
193 | IF (lines.first == lines.all - lines.visible) RETURN; |
193 | IF (lines.first == lines.all - lines.visible) RETURN; |
194 | lines.first = lines.all - lines.visible; |
194 | lines.first = lines.all - lines.visible; |
195 | BREAK; |
195 | BREAK; |
196 | default: |
196 | default: |
197 | RETURN; |
197 | RETURN; |
198 | } |
198 | } |
199 | ParseHTML(buf); |
199 | ParseHTML(buf); |
200 | } |
200 | } |
201 | 201 | ||
202 | 202 | ||
203 | char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/rd/", "/fd/", "/bd/", "/hd/", "/cd/", "/tmp/", 0}; |
203 | char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/rd/", "/fd/", "/bd/", "/hd/", "/cd/", "/tmp/", 0}; |
204 | 204 | ||
205 | //dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){ |
205 | //dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){ |
206 | void TWebBrowser::GetNewUrl(){ |
206 | void TWebBrowser::GetNewUrl(){ |
207 | int i; |
207 | int i, len; |
208 | 208 | ||
209 | for (i=0; ABSOLUTE_LINKS[i]; i++) |
209 | for (i=0; ABSOLUTE_LINKS[i]; i++) |
- | 210 | { |
|
- | 211 | len=strlen(ABSOLUTE_LINKS[i]); |
|
210 | if (!strcmpn(#URL, ABSOLUTE_LINKS[i], strlen(ABSOLUTE_LINKS[i]))) return; |
212 | if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return; |
- | 213 | } |
|
211 | 214 | ||
212 | IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :) |
215 | IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :) |
213 | if (URL[0] == '/') strcpy(#URL, #URL+1); |
216 | if (URL[0] == '/') strcpy(#URL, #URL+1); |
214 | 217 | ||
215 | strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû |
218 | strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû |
216 | 219 | ||
217 | _CUT_ST_LEVEL_MARK: |
220 | _CUT_ST_LEVEL_MARK: |
218 | 221 | ||
219 | if (editURL[strrchr(#editURL, '/')-2]<>'/') // åñëè íå http:// |
222 | if (editURL[strrchr(#editURL, '/')-2]<>'/') // åñëè íå http:// |
220 | { |
223 | { |
221 | editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
224 | editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
222 | } |
225 | } |
223 | 226 | ||
224 | IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ |
227 | IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ |
225 | { |
228 | { |
226 | strcpy(#URL,#URL+3); |
229 | strcpy(#URL,#URL+3); |
227 | editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
230 | editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
228 | goto _CUT_ST_LEVEL_MARK; |
231 | goto _CUT_ST_LEVEL_MARK; |
229 | } |
232 | } |
230 | 233 | ||
231 | if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); |
234 | if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); |
232 | 235 | ||
233 | strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ |
236 | strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ |
234 | strcpy(#URL, #editURL); |
237 | strcpy(#URL, #editURL); |
235 | } |
238 | } |
236 | 239 | ||
237 | 240 | ||
238 | 241 | ||
239 | void TWebBrowser::ReadHtml(byte encoding) |
242 | void TWebBrowser::ReadHtml(byte encoding) |
240 | { |
243 | { |
241 | if (!strcmp(get_URL_part(5),"http:"))) |
244 | if (!strcmp(get_URL_part(5),"http:"))) |
242 | file_size stdcall (#download_path); |
245 | file_size stdcall (#download_path); |
243 | else |
246 | else |
244 | file_size stdcall (#URL); |
247 | file_size stdcall (#URL); |
245 | 248 | ||
246 | filesize = EBX; |
249 | filesize = EBX; |
247 | if (!filesize) return; |
250 | if (!filesize) return; |
248 | 251 | ||
249 | mem_Free(buf); |
252 | mem_Free(buf); |
250 | buf = mem_Alloc(filesize); |
253 | buf = mem_Alloc(filesize); |
251 | if (!strcmp(get_URL_part(5),"http:"))) |
254 | if (!strcmp(get_URL_part(5),"http:"))) |
252 | ReadFile(0, filesize, buf, #download_path); |
255 | ReadFile(0, filesize, buf, #download_path); |
253 | else |
256 | else |
254 | ReadFile(0, filesize, buf, #URL); |
257 | ReadFile(0, filesize, buf, #URL); |
255 | 258 | ||
256 | if (encoding==_WIN) wintodos(buf); |
259 | if (encoding==_WIN) wintodos(buf); |
257 | if (encoding==_UTF) utf8rutodos(buf); |
260 | if (encoding==_UTF) utf8rutodos(buf); |
258 | if (encoding==_KOI) koitodos(buf); |
261 | if (encoding==_KOI) koitodos(buf); |
259 | } |
262 | } |
260 | 263 | ||
261 | 264 | ||
262 | void TWebBrowser::OpenPage() |
265 | void TWebBrowser::OpenPage() |
263 | { |
266 | { |
264 | if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
267 | if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
265 | KillProcess(downloader_id); |
268 | KillProcess(downloader_id); |
266 | strcpy(#editURL, #URL); |
269 | strcpy(#editURL, #URL); |
267 | BrowserHistory.AddUrl(); |
270 | BrowserHistory.AddUrl(); |
268 | strcpy(#header, #version); |
271 | strcpy(#header, #version); |
269 | pre_text =0; |
272 | pre_text =0; |
270 | if (!strcmp(get_URL_part(5),"http:"))) |
273 | if (!strcmp(get_URL_part(5),"http:"))) |
271 | { |
274 | { |
272 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
275 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
273 | DeleteFile(#download_path); |
276 | DeleteFile(#download_path); |
274 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=''; |
277 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=''; |
275 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
278 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
276 | //ýòî ãåíèàëüíî è ýòî ïèçäåö!!! |
279 | //ýòî ãåíèàëüíî è ýòî ïèçäåö!!! |
277 | Pause(60); |
280 | Pause(60); |
278 | if (GetProcessSlot(downloader_id)<>0) |
281 | if (GetProcessSlot(downloader_id)<>0) |
279 | { |
282 | { |
280 | debug("Browser Hack v2.0: Killing downloader and trying to run it one more!"); |
283 | debug("Browser Hack v2.0: Killing downloader and trying to run it one more!"); |
281 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
284 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
282 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
285 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
283 | } |
286 | } |
284 | // |
287 | // |
285 | IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable."); |
288 | IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable."); |
286 | Draw_Window(); |
289 | Draw_Window(); |
287 | return; |
290 | return; |
288 | } |
291 | } |
289 | lines.first = lines.all =0; |
292 | lines.first = lines.all =0; |
290 | ReadHtml(_WIN); |
293 | ReadHtml(_WIN); |
291 | WB1.ShowPage(); |
294 | WB1.ShowPage(); |
292 | } |
295 | } |
293 | 296 | ||
294 | 297 | ||
295 | void TWebBrowser::ShowPage() |
298 | void TWebBrowser::ShowPage() |
296 | { |
299 | { |
297 | edit1.size = edit1.pos = strlen(#editURL); |
300 | edit1.size = edit1.pos = strlen(#editURL); |
298 | edit1.offset=0; |
301 | edit1.offset=0; |
299 | edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà |
302 | edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà |
300 | 303 | ||
301 | if (!filesize) |
304 | if (!filesize) |
302 | { |
305 | { |
303 | DrawBar(left, top, width+4, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó |
306 | DrawBar(left, top, width+4, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó |
304 | if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0); |
307 | if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0); |
305 | else |
308 | else |
306 | { |
309 | { |
307 | WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0); |
310 | WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0); |
308 | if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.", 0); |
311 | if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.", 0); |
309 | } |
312 | } |
310 | //return; |
313 | //return; |
311 | } |
314 | } |
312 | else |
315 | else |
313 | ParseHTML(buf); |
316 | ParseHTML(buf); |
314 | 317 | ||
315 | if (!header) strcpy(#header, #version); |
318 | if (!header) strcpy(#header, #version); |
316 | if (!strcmp(#version, #header)) DrawTitle(#header); |
319 | if (!strcmp(#version, #header)) DrawTitle(#header); |
317 | } |
320 | } |
318 | 321 | ||
319 | 322 | ||
320 | 323 | ||
321 | void TWebBrowser::ParseHTML(dword bword){ |
324 | void TWebBrowser::ParseHTML(dword bword){ |
322 | word bukva[2]; |
325 | word bukva[2]; |
323 | int j, perenos_num; |
326 | int j, perenos_num; |
324 | byte ignor_param; |
327 | byte ignor_param; |
325 | char temp[768]; |
328 | char temp[768]; |
326 | 329 | ||
327 | stroka = -lines.first; |
330 | stroka = -lines.first; |
328 | stolbec = 0; |
331 | stolbec = 0; |
329 | 332 | ||
330 | for (j = 400; j < blink + 1; j++;) DeleteButton(j); |
333 | for (j = 400; j < blink + 1; j++;) DeleteButton(j); |
331 | blink = 400; |
334 | blink = 400; |
332 | 335 | ||
333 | b_text = i_text = u_text = s_text = blq_text = first_line_drawed = |
336 | b_text = i_text = u_text = s_text = blq_text = first_line_drawed = |
334 | li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè |
337 | li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè |
335 | link_color = 0x0000FF; |
338 | link_color = 0x0000FF; |
336 | bg_color = 0xFFFFFF; |
339 | bg_color = 0xFFFFFF; |
337 | line = ''; |
340 | line = ''; |
338 | strcpy(#page_links,"|"); |
341 | strcpy(#page_links,"|"); |
339 | strcpy(#header, #version); |
342 | strcpy(#header, #version); |
340 | 343 | ||
341 | if (pre_text<>2) |
344 | if (pre_text<>2) |
342 | { |
345 | { |
343 | pre_text=0; |
346 | pre_text=0; |
344 | if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; |
347 | if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; |
345 | if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; |
348 | if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; |
346 | } |
349 | } |
347 | 350 | ||
348 | for ( ; buf+filesize > bword; bword++;) |
351 | for ( ; buf+filesize > bword; bword++;) |
349 | { |
352 | { |
350 | bukva = ESBYTE[bword]; |
353 | bukva = ESBYTE[bword]; |
351 | if (ignor_text) && (bukva<>'<') continue; |
354 | if (ignor_text) && (bukva<>'<') continue; |
352 | switch (bukva) |
355 | switch (bukva) |
353 | { |
356 | { |
354 | case 0x0a: |
357 | case 0x0a: |
355 | if (pre_text) |
358 | if (pre_text) |
356 | { |
359 | { |
357 | bukva = temp = ''; |
360 | bukva = temp = ''; |
358 | goto NEXT_MARK; |
361 | goto NEXT_MARK; |
359 | } |
362 | } |
360 | case '\9': |
363 | case '\9': |
361 | if (pre_text) //èíà÷å èä¸ì íà 0x0d |
364 | if (pre_text) //èíà÷å èä¸ì íà 0x0d |
362 | { |
365 | { |
363 | tab_len=strlen(#line)/8; |
366 | tab_len=strlen(#line)/8; |
364 | tab_len=tab_len*8; |
367 | tab_len=tab_len*8; |
365 | tab_len=8+tab_len-strlen(#line); |
368 | tab_len=8+tab_len-strlen(#line); |
366 | for (j=0; j |
369 | for (j=0; j |
367 | break; |
370 | break; |
368 | } |
371 | } |
369 | case 0x0d: |
372 | case 0x0d: |
370 | bukva = ' '; |
373 | bukva = ' '; |
371 | goto DEFAULT_MARK; |
374 | goto DEFAULT_MARK; |
372 | case '<': |
375 | case '<': |
373 | bword++; //ïðîìîòàåì ñèìâîë < |
376 | bword++; //ïðîìîòàåì ñèìâîë < |
374 | tag = parametr = tagparam = ignor_param = 0; |
377 | tag = parametr = tagparam = ignor_param = 0; |
375 | if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî |
378 | if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî |
376 | { |
379 | { |
377 | bword++; |
380 | bword++; |
378 | if (ESBYTE[bword] == '-') |
381 | if (ESBYTE[bword] == '-') |
379 | { |
382 | { |
380 | HH_: |
383 | HH_: |
381 | do |
384 | do |
382 | { |
385 | { |
383 | bword++; |
386 | bword++; |
384 | if (buf + filesize <= bword) break 2; |
387 | if (buf + filesize <= bword) break 2; |
385 | } |
388 | } |
386 | while (ESBYTE[bword] <>'-'); |
389 | while (ESBYTE[bword] <>'-'); |
387 | 390 | ||
388 | bword++; |
391 | bword++; |
389 | if (ESBYTE[bword] <>'-') goto HH_; |
392 | if (ESBYTE[bword] <>'-') goto HH_; |
390 | } |
393 | } |
391 | } |
394 | } |
392 | while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
395 | while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
393 | { |
396 | { |
394 | bukva = ESBYTE[bword]; |
397 | bukva = ESBYTE[bword]; |
395 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
398 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
396 | if (!ignor_param) && (bukva <>' ') |
399 | if (!ignor_param) && (bukva <>' ') |
397 | { |
400 | { |
398 | if (strlen(#tag) |
401 | if (strlen(#tag) |
399 | } |
402 | } |
400 | else |
403 | else |
401 | { |
404 | { |
402 | ignor_param = true; |
405 | ignor_param = true; |
403 | if (!ignor_text) && (strlen(#tagparam)+1 |
406 | if (!ignor_text) && (strlen(#tagparam)+1 |
404 | } |
407 | } |
405 | bword++; |
408 | bword++; |
406 | } |
409 | } |
407 | strlwr(#tag); |
410 | strlwr(#tag); |
408 | strlwr(#tagparam); |
411 | strlwr(#tagparam); |
409 | 412 | ||
410 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //for br/ |
413 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //for br/ |
411 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
414 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
412 | 415 | ||
413 | DrawPage(); |
416 | DrawPage(); |
414 | line=0; |
417 | line=0; |
415 | 418 | ||
416 | if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ |
419 | if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ |
417 | 420 | ||
418 | tag = parametr = tagparam = ignor_param = '\0'; |
421 | tag = parametr = tagparam = ignor_param = '\0'; |
419 | break; |
422 | break; |
420 | case '=': //ïîääåðæêà øàéòàíñêîé êîäèðîâêè ñòðàíèö, ñîõðàí¸ííûõ ÷åðåç ÈÅ7 |
423 | case '=': //ïîääåðæêà øàéòàíñêîé êîäèðîâêè ñòðàíèö, ñîõðàí¸ííûõ ÷åðåç ÈÅ7 |
421 | if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; |
424 | if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; |
422 | 425 | ||
423 | bword++; |
426 | bword++; |
424 | bukva=ESBYTE[bword]; |
427 | bukva=ESBYTE[bword]; |
425 | strcpy(#temp,#bukva); |
428 | strcpy(#temp,#bukva); |
426 | bword++; |
429 | bword++; |
427 | bukva=ESBYTE[bword]; |
430 | bukva=ESBYTE[bword]; |
428 | strcat(#temp,#bukva); |
431 | strcat(#temp,#bukva); |
429 | 432 | ||
430 | bukva=Hex2Symb(#temp); |
433 | bukva=Hex2Symb(#temp); |
431 | if (bukva) goto DEFAULT_MARK; |
434 | if (bukva) goto DEFAULT_MARK; |
432 | break; |
435 | break; |
433 | 436 | ||
434 | case '&': // and so on |
437 | case '&': // and so on |
435 | bword++; |
438 | bword++; |
436 | tag=0; |
439 | tag=0; |
437 | for (j=0; (ESBYTE[bword]<>';') && (j<7); j++, bword++;) |
440 | for (j=0; (ESBYTE[bword]<>';') && (j<7); j++, bword++;) |
438 | { |
441 | { |
439 | bukva = ESBYTE[bword]; |
442 | bukva = ESBYTE[bword]; |
440 | strcat(#tag, #bukva); |
443 | strcat(#tag, #bukva); |
441 | } |
444 | } |
442 | 445 | ||
443 | for (j=0; unicode_tags[j]!=0; j+=2;) |
446 | for (j=0; unicode_tags[j]!=0; j+=2;) |
444 | { |
447 | { |
445 | if (!strcmp(#tag, unicode_tags[j])) |
448 | if (!strcmp(#tag, unicode_tags[j])) |
446 | { |
449 | { |
447 | strcat(#line, unicode_tags[j+1]); |
450 | strcat(#line, unicode_tags[j+1]); |
448 | break 1; |
451 | break 1; |
449 | } |
452 | } |
450 | } |
453 | } |
451 | 454 | ||
452 | rez = atoi(#tag + 1) - 1040; |
455 | rez = atoi(#tag + 1) - 1040; |
453 | if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5) |
456 | if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5) |
454 | { |
457 | { |
455 | bukva = unicode_chars[rez]; |
458 | bukva = unicode_chars[rez]; |
456 | //GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó ëó÷øå íàâåðíî strcat(#line, unicode_tags[j+1]); è break 1; |
459 | //GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó ëó÷øå íàâåðíî strcat(#line, unicode_tags[j+1]); è break 1; |
457 | strcat(#line, #bukva); |
460 | strcat(#line, #bukva); |
458 | break; |
461 | break; |
459 | } |
462 | } |
460 | 463 | ||
461 | strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò |
464 | strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò |
462 | break; |
465 | break; |
463 | default: |
466 | default: |
464 | DEFAULT_MARK: |
467 | DEFAULT_MARK: |
465 | if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break; |
468 | if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break; |
466 | // |
469 | // |
467 | if (stolbec + strlen(#line) > lines.column_max) |
470 | if (stolbec + strlen(#line) > lines.column_max) |
468 | { |
471 | { |
469 | perenos_num = strrchr(#line, ' '); |
472 | perenos_num = strrchr(#line, ' '); |
470 | strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì |
473 | strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì |
471 | line[perenos_num] = 0x00; |
474 | line[perenos_num] = 0x00; |
472 | NEXT_MARK: |
475 | NEXT_MARK: |
473 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì... |
476 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì... |
474 | DrawPage(); |
477 | DrawPage(); |
475 | TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
478 | TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
476 | strcpy(#line, #temp); |
479 | strcpy(#line, #temp); |
477 | } |
480 | } |
478 | if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break; |
481 | if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break; |
479 | if (strlen(#line) |
482 | if (strlen(#line) |
480 | } |
483 | } |
481 | } |
484 | } |
482 | 485 | ||
483 | if (lines.visible * 10 + 25 <= height) |
486 | if (lines.visible * 10 + 25 <= height) |
484 | DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color); |
487 | DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color); |
485 | if (stroka * 10 + 15 <= height) |
488 | if (stroka * 10 + 15 <= height) |
486 | DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà |
489 | DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà |
487 | if (lines.first == 0) lines.all = stroka; |
490 | if (lines.first == 0) lines.all = stroka; |
488 | if (anchor) |
491 | if (anchor) |
489 | { |
492 | { |
490 | //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
493 | //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
491 | anchor=''; |
494 | anchor=''; |
492 | lines.first=anchor_line_num; |
495 | lines.first=anchor_line_num; |
493 | ParseHTML(buf); |
496 | ParseHTML(buf); |
494 | } |
497 | } |
495 | 498 | ||
496 | DrawScroller(); |
499 | DrawScroller(); |
497 | } |
500 | } |
498 | 501 | ||
499 | void TWebBrowser::DrawPage() //ðåçàòü çäåñü!!1! |
502 | void TWebBrowser::DrawPage() //ðåçàòü çäåñü!!1! |
500 | { |
503 | { |
501 | int start_x, start_y, line_length; |
504 | int start_x, start_y, line_length; |
502 | char temp[sizeof(line)]; |
505 | char temp[sizeof(line)]; |
503 | 506 | ||
504 | if (!header) //&& (tag) |
507 | if (!header) //&& (tag) |
505 | { |
508 | { |
506 | if (strlen(#version)+strlen(#line)+2>sizeof(header)) |
509 | if (strlen(#version)+strlen(#line)+2>sizeof(header)) |
507 | { |
510 | { |
508 | //line = 123456789 |
511 | //line = 123456789 |
509 | //header = 1234 |
512 | //header = 1234 |
510 | //line = 56789 |
513 | //line = 56789 |
511 | strcpy(#temp, #line); |
514 | strcpy(#temp, #line); |
512 | temp[sizeof(header)-strlen(#version)-2]=0; |
515 | temp[sizeof(header)-strlen(#version)-2]=0; |
513 | strcpy(#header, #temp); |
516 | strcpy(#header, #temp); |
514 | strcpy(#line, #line+strlen(#temp)); |
517 | strcpy(#line, #line+strlen(#temp)); |
515 | } |
518 | } |
516 | else |
519 | else |
517 | { |
520 | { |
518 | strcpy(#header, #line); |
521 | strcpy(#header, #line); |
519 | line=0; |
522 | line=0; |
520 | } |
523 | } |
521 | 524 | ||
522 | strcat(#header, " -"); |
525 | strcat(#header, " -"); |
523 | strcat(#header, #version); |
526 | strcat(#header, #version); |
524 | return; |
527 | return; |
525 | } |
528 | } |
526 | 529 | ||
527 | if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor) |
530 | if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor) |
528 | { |
531 | { |
529 | if (!stroka) && (!stolbec) |
532 | if (!stroka) && (!stolbec) |
530 | { |
533 | { |
531 | DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
534 | DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
532 | first_line_drawed=1; |
535 | first_line_drawed=1; |
533 | } |
536 | } |
534 | 537 | ||
535 | start_x=stolbec * 6 + left+5; |
538 | start_x=stolbec * 6 + left+5; |
536 | start_y=stroka * 10 + top + 5; |
539 | start_y=stroka * 10 + top + 5; |
537 | line_length=strlen(#line)*6; |
540 | line_length=strlen(#line)*6; |
538 | 541 | ||
539 | WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line, 0); |
542 | WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line, 0); |
540 | //line_length = get_length stdcall (#line,-1,16,line_length); |
543 | //line_length = get_length stdcall (#line,-1,16,line_length); |
541 | //text_out stdcall (#line, -1, 17, text_colors[text_color_index], start_x, start_y-2); |
544 | //text_out stdcall (#line, -1, 17, text_colors[text_color_index], start_x, start_y-2); |
542 | IF (b_text) { $add ebx, 1<<16 $int 0x40 } |
545 | IF (b_text) { $add ebx, 1<<16 $int 0x40 } |
543 | IF (i_text) Skew(start_x, start_y, line_length+6, 10); |
546 | IF (i_text) Skew(start_x, start_y, line_length+6, 10); |
544 | IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]); |
547 | IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]); |
545 | IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
548 | IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
546 | IF (link) { |
549 | IF (link) { |
547 | DefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); |
550 | DefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); |
548 | DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
551 | DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
549 | } |
552 | } |
550 | stolbec += strlen(#line); |
553 | stolbec += strlen(#line); |
551 | } |
554 | } |
552 | } |
555 | } |
553 | 556 | ||
554 | 557 | ||
555 | char oldtag[100]; |
558 | char oldtag[100]; |
556 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
559 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
557 | dword hr_color; |
560 | dword hr_color; |
558 | 561 | ||
559 | dword image; |
562 | dword image; |
560 | char temp[4096]; |
563 | char temp[4096]; |
561 | int w=0, h=0, img_lines_first=0; |
564 | int w=0, h=0, img_lines_first=0; |
562 | 565 | ||
563 | //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ |
566 | //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ |
564 | if (tag[0] == '/') |
567 | if (tag[0] == '/') |
565 | { |
568 | { |
566 | rez = 0; |
569 | rez = 0; |
567 | strcpy(#tag, #tag+1); |
570 | strcpy(#tag, #tag+1); |
568 | } |
571 | } |
569 | else |
572 | else |
570 | rez = 1; |
573 | rez = 1; |
571 | 574 | ||
572 | if (!chTag("html")) { |
575 | if (!chTag("html")) { |
573 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
576 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
574 | return; |
577 | return; |
575 | } |
578 | } |
576 | 579 | ||
577 | if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez; |
580 | if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez; |
578 | 581 | ||
579 | if(!chTag("title")) |
582 | if(!chTag("title")) |
580 | { |
583 | { |
581 | if (rez) |
584 | if (rez) |
582 | { |
585 | { |
583 | header=0; |
586 | header=0; |
584 | } |
587 | } |
585 | else //òåã çàêðûëñÿ - âûâåëè ñòðîêó |
588 | else //òåã çàêðûëñÿ - âûâåëè ñòðîêó |
586 | { |
589 | { |
587 | if (stroka==0) DrawTitle(#header); |
590 | if (stroka==0) DrawTitle(#header); |
588 | } |
591 | } |
589 | return; |
592 | return; |
590 | } |
593 | } |
591 | 594 | ||
592 | if (ignor_text) return; |
595 | if (ignor_text) return; |
593 | 596 | ||
594 | 597 | ||
595 | 598 | ||
596 | 599 | ||
597 | IF(!chTag("q")) strcat(#line, "\""); |
600 | IF(!chTag("q")) strcat(#line, "\""); |
598 | 601 | ||
599 | 602 | ||
600 | if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò |
603 | if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò |
601 | { |
604 | { |
602 | if (!strcmp(#anchor, #options)) |
605 | if (!strcmp(#anchor, #options)) |
603 | { |
606 | { |
604 | anchor_line_num=lines.first+stroka; |
607 | anchor_line_num=lines.first+stroka; |
605 | } |
608 | } |
606 | } |
609 | } |
607 | 610 | ||
608 | if (!chTag("body")) |
611 | if (!chTag("body")) |
609 | { |
612 | { |
610 | BODY_MARK: |
613 | BODY_MARK: |
611 | 614 | ||
612 | if (!strcmp(#parametr, "link=")) |
615 | if (!strcmp(#parametr, "link=")) |
613 | link_color = GetColor(#options); |
616 | link_color = GetColor(#options); |
614 | 617 | ||
615 | if (!strcmp(#parametr, "text=")) |
618 | if (!strcmp(#parametr, "text=")) |
616 | text_colors[0]=GetColor(#options); |
619 | text_colors[0]=GetColor(#options); |
617 | 620 | ||
618 | if (!strcmp(#parametr, "bgcolor=")) |
621 | if (!strcmp(#parametr, "bgcolor=")) |
619 | bg_color=GetColor(#options); |
622 | bg_color=GetColor(#options); |
620 | 623 | ||
621 | IF(tagparam) |
624 | IF(tagparam) |
622 | { |
625 | { |
623 | GetNextParam(); |
626 | GetNextParam(); |
624 | GOTO BODY_MARK; |
627 | GOTO BODY_MARK; |
625 | } |
628 | } |
626 | 629 | ||
627 | return; |
630 | return; |
628 | } |
631 | } |
629 | 632 | ||
630 | if (!chTag("a")) |
633 | if (!chTag("a")) |
631 | { |
634 | { |
632 | if (rez) |
635 | if (rez) |
633 | { |
636 | { |
634 | 637 | ||
635 | if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò |
638 | if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò |
636 | 639 | ||
637 | _A_MARK: |
640 | _A_MARK: |
638 | if (!strcmp(#parametr, "href=")) |
641 | if (!strcmp(#parametr, "href=")) |
639 | { |
642 | { |
640 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
643 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
641 | 644 | ||
642 | text_color_index++; |
645 | text_color_index++; |
643 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
646 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
644 | 647 | ||
645 | link = 1; |
648 | link = 1; |
646 | blink++; |
649 | blink++; |
647 | text_colors[text_color_index] = link_color; |
650 | text_colors[text_color_index] = link_color; |
648 | strcat(#page_links, #options); |
651 | strcat(#page_links, #options); |
649 | strcat(#page_links, "|"); |
652 | strcat(#page_links, "|"); |
650 | } |
653 | } |
651 | if (anchor) && (!strcmp(#parametr, "name=")) |
654 | if (anchor) && (!strcmp(#parametr, "name=")) |
652 | { |
655 | { |
653 | if (!strcmp(#anchor, #options)) |
656 | if (!strcmp(#anchor, #options)) |
654 | { |
657 | { |
655 | anchor_line_num=lines.first+stroka; |
658 | anchor_line_num=lines.first+stroka; |
656 | } |
659 | } |
657 | } |
660 | } |
658 | if (tagparam) |
661 | if (tagparam) |
659 | { |
662 | { |
660 | GetNextParam(); |
663 | GetNextParam(); |
661 | GOTO _A_MARK; |
664 | GOTO _A_MARK; |
662 | } |
665 | } |
663 | } |
666 | } |
664 | else { |
667 | else { |
665 | link = 0; |
668 | link = 0; |
666 | IF(text_color_index > 0) text_color_index--; |
669 | IF(text_color_index > 0) text_color_index--; |
667 | } |
670 | } |
668 | return; |
671 | return; |
669 | } |
672 | } |
670 | 673 | ||
671 | 674 | ||
672 | if (!chTag("font")) |
675 | if (!chTag("font")) |
673 | { |
676 | { |
674 | if (rez) |
677 | if (rez) |
675 | { |
678 | { |
676 | text_color_index++; |
679 | text_color_index++; |
677 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
680 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
678 | 681 | ||
679 | COL_MARK: |
682 | COL_MARK: |
680 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
683 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
681 | { |
684 | { |
682 | text_colors[text_color_index] = GetColor(#options); |
685 | text_colors[text_color_index] = GetColor(#options); |
683 | } |
686 | } |
684 | IF(tagparam) { |
687 | IF(tagparam) { |
685 | GetNextParam(); |
688 | GetNextParam(); |
686 | GOTO COL_MARK; |
689 | GOTO COL_MARK; |
687 | } |
690 | } |
688 | } |
691 | } |
689 | else |
692 | else |
690 | if (text_color_index > 0) text_color_index--; |
693 | if (text_color_index > 0) text_color_index--; |
691 | return; |
694 | return; |
692 | } |
695 | } |
693 | 696 | ||
694 | if(!chTag("tr")) || (!chTag("br")) { |
697 | if(!chTag("tr")) || (!chTag("br")) { |
695 | TextGoDown(left1, top1, width1); |
698 | TextGoDown(left1, top1, width1); |
696 | return; |
699 | return; |
697 | } |
700 | } |
698 | if (!chTag("div")) { |
701 | if (!chTag("div")) { |
699 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
702 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
700 | return; |
703 | return; |
701 | } |
704 | } |
702 | if (!chTag("p")) { |
705 | if (!chTag("p")) { |
703 | IF(oldtag[0] == 'h') return; |
706 | IF(oldtag[0] == 'h') return; |
704 | TextGoDown(left1, top1, width1); |
707 | TextGoDown(left1, top1, width1); |
705 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
708 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
706 | return; |
709 | return; |
707 | } |
710 | } |
708 | 711 | ||
709 | if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { |
712 | if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { |
710 | TextGoDown(left1, top1, width1); |
713 | TextGoDown(left1, top1, width1); |
711 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
714 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
712 | b_text = rez; |
715 | b_text = rez; |
713 | strcpy(#oldtag, #tag); |
716 | strcpy(#oldtag, #tag); |
714 | return; |
717 | return; |
715 | } |
718 | } |
716 | else |
719 | else |
717 | oldtag=''; |
720 | oldtag=''; |
718 | 721 | ||
719 | if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) { |
722 | if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) { |
720 | b_text = rez; |
723 | b_text = rez; |
721 | return; |
724 | return; |
722 | } |
725 | } |
723 | //////////////////////////// |
726 | //////////////////////////// |
724 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
727 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
725 | i_text = rez; |
728 | i_text = rez; |
726 | return; |
729 | return; |
727 | } |
730 | } |
728 | //////////////////////////// |
731 | //////////////////////////// |
729 | if (!chTag("dt")) |
732 | if (!chTag("dt")) |
730 | { |
733 | { |
731 | li_text = rez; |
734 | li_text = rez; |
732 | IF(rez == 0) return; |
735 | IF(rez == 0) return; |
733 | TextGoDown(left1, top1, width1); |
736 | TextGoDown(left1, top1, width1); |
734 | return; |
737 | return; |
735 | } |
738 | } |
736 | ///////////////////////////// |
739 | ///////////////////////////// |
737 | if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè |
740 | if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè |
738 | { |
741 | { |
739 | li_text = rez; |
742 | li_text = rez; |
740 | IF(rez == 0) return; |
743 | IF(rez == 0) return; |
741 | TextGoDown(left1, top1, width1); |
744 | TextGoDown(left1, top1, width1); |
742 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
745 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
743 | return; |
746 | return; |
744 | } |
747 | } |
745 | //////////////////////////// |
748 | //////////////////////////// |
746 | IF(!chTag("u")) || (!chTag("ins")) u_text = rez; |
749 | IF(!chTag("u")) || (!chTag("ins")) u_text = rez; |
747 | IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
750 | IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
748 | IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) { |
751 | IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) { |
749 | li_text = rez; |
752 | li_text = rez; |
750 | li_tab--; |
753 | li_tab--; |
751 | TextGoDown(left1, top1, width1); |
754 | TextGoDown(left1, top1, width1); |
752 | } ELSE li_tab++; |
755 | } ELSE li_tab++; |
753 | IF(!chTag("dd")) stolbec += 5; |
756 | IF(!chTag("dd")) stolbec += 5; |
754 | IF(!chTag("blockquote")) blq_text = rez; |
757 | IF(!chTag("blockquote")) blq_text = rez; |
755 | IF(!chTag("pre")) pre_text = rez; |
758 | IF(!chTag("pre")) pre_text = rez; |
756 | IF(!chTag("hr")) { |
759 | IF(!chTag("hr")) { |
757 | TextGoDown(left1, top1, width1); |
760 | TextGoDown(left1, top1, width1); |
758 | TextGoDown(left1, top1 + 10, width1); |
761 | TextGoDown(left1, top1 + 10, width1); |
759 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
762 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
760 | ELSE hr_color = 0x999999; |
763 | ELSE hr_color = 0x999999; |
761 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
764 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
762 | } |
765 | } |
763 | 766 | ||
764 | if (!chTag("img")) |
767 | if (!chTag("img")) |
765 | { |
768 | { |
766 | //if (GetFileInfo(#libimg)<>0) return; //åñëè áèáëèîòåêè íåò |
769 | //if (GetFileInfo(#libimg)<>0) return; //åñëè áèáëèîòåêè íåò |
767 | IMG_TAG: |
770 | IMG_TAG: |
768 | if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl() |
771 | if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl() |
769 | { |
772 | { |
770 | if (!strcmpn(#URL, "http:", 5)) || (!strcmpn(#options, "http:", 5)) return; |
773 | if (downloader_id!=0) strcpy(#temp, #history_list[history_current-1].Item); |
771 | strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû |
774 | else strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû |
772 | temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
775 | if (!strcmpn(#temp, "http:", 5)) || (!strcmpn(#options, "http:", 5)) return; |
- | 776 | temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
|
773 | strcat(#temp, #options); |
777 | strcat(#temp, #options); |
774 | image=load_image(#temp); |
778 | image=load_image(#temp); |
775 | w=DSWORD[image+4]; |
779 | w=DSWORD[image+4]; |
776 | h=DSWORD[image+8]; |
780 | h=DSWORD[image+8]; |
777 | } |
781 | } |
778 | /*if (!strcmp(#parametr,"alt=")) |
782 | /*if (!strcmp(#parametr,"alt=")) |
779 | { |
783 | { |
780 | strcpy(#tag, "[Image: "); |
784 | strcpy(#tag, "[Image: "); |
781 | strcat(#tag, #options); |
785 | strcat(#tag, #options); |
782 | strcat(#tag, "]"); |
786 | strcat(#tag, "]"); |
783 | }*/ |
787 | }*/ |
784 | 788 | ||
785 | IF(tagparam) |
789 | IF(tagparam) |
786 | { |
790 | { |
787 | GetNextParam(); |
791 | GetNextParam(); |
788 | GOTO IMG_TAG; |
792 | GOTO IMG_TAG; |
789 | } |
793 | } |
790 | 794 | ||
791 | if (!image) |
795 | if (!image) |
792 | { |
796 | { |
793 | //debug(#tag); |
797 | //debug(#tag); |
794 | return; |
798 | return; |
795 | } |
799 | } |
796 | 800 | ||
797 | if (w>width1) w=width1; |
801 | if (w>width1) w=width1; |
798 | 802 | ||
799 | if (stroka==0) DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
803 | if (stroka==0) DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
800 | 804 | ||
801 | stroka+=h/10; |
805 | stroka+=h/10; |
802 | 806 | ||
803 | if (top1+h |
807 | if (top1+h |
804 | return; |
808 | return; |
805 | 809 | ||
806 | if (top1 |
810 | if (top1 |
807 | { |
811 | { |
808 | DrawBar(left, top, width-15, 10, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
812 | DrawBar(left, top, width-15, 10, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
809 | img_lines_first=WB1.top-top1; |
813 | img_lines_first=WB1.top-top1; |
810 | h=h-img_lines_first; |
814 | h=h-img_lines_first; |
811 | top1=WB1.top; |
815 | top1=WB1.top; |
812 | } |
816 | } |
813 | 817 | ||
814 | if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < lines.visible) |
818 | if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < lines.visible) |
815 | { |
819 | { |
816 | h=WB1.top+WB1.height-top1-15; |
820 | h=WB1.top+WB1.height-top1-15; |
817 | } |
821 | } |
818 | 822 | ||
819 | if (h<=0) return; |
823 | if (h<=0) return; |
820 | if (anchor) return; |
824 | if (anchor) return; |
821 | 825 | ||
822 | img_draw stdcall (image,left1-5,top1+10,w, h,0,img_lines_first); |
826 | img_draw stdcall (image,left1-5,top1+10,w, h,0,img_lines_first); |
823 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
827 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
824 | IF (link) |
828 | IF (link) |
825 | { |
829 | { |
826 | DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
830 | DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
827 | } |
831 | } |
828 | 832 | ||
829 | return; |
833 | return; |
830 | } |
834 | } |
831 | 835 | ||
832 | if (!chTag("meta")) || (!chTag("?xml")) |
836 | if (!chTag("meta")) || (!chTag("?xml")) |
833 | { |
837 | { |
834 | META: |
838 | META: |
835 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
839 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
836 | { |
840 | { |
837 | strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content= |
841 | strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content= |
838 | 842 | ||
839 | if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF); |
843 | if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF); |
840 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
844 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
841 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
845 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
842 | } |
846 | } |
843 | if (tagparam) |
847 | if (tagparam) |
844 | { |
848 | { |
845 | GetNextParam(); |
849 | GetNextParam(); |
846 | goto META; |
850 | goto META; |
847 | } |
851 | } |
848 | return; |
852 | return; |
849 | } |
853 | } |
850 | } |
854 | } |
851 | 855 | ||
852 | 856 | ||
853 | void TextGoDown(int left1, top1, width1) |
857 | void TextGoDown(int left1, top1, width1) |
854 | { |
858 | { |
855 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
859 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
856 | { |
860 | { |
857 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
861 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
858 | first_line_drawed=1; |
862 | first_line_drawed=1; |
859 | } |
863 | } |
860 | stroka++; |
864 | stroka++; |
861 | if (blq_text) stolbec = 8; |
865 | if (blq_text) stolbec = 8; |
862 | ELSE stolbec = 0; |
866 | ELSE stolbec = 0; |
863 | if (li_text) stolbec = li_tab * 5; |
867 | if (li_text) stolbec = li_tab * 5; |
864 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
868 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
865 | } |
869 | } |
866 | 870 | ||
867 | 871 | ||
868 | //ñêðîëë |
872 | //ñêðîëë |
869 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
873 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
870 | { |
874 | { |
871 | scroll1.max_area = lines.all; |
875 | scroll1.max_area = lines.all; |
872 | scroll1.cur_area = lines.visible; |
876 | scroll1.cur_area = lines.visible; |
873 | scroll1.position = lines.first; |
877 | scroll1.position = lines.first; |
874 | 878 | ||
875 | scroll1.all_redraw=1; |
879 | scroll1.all_redraw=1; |
876 | scroll1.start_x=Form.width-28; //left + width - 15 |
880 | scroll1.start_x=Form.width-28; //left + width - 15 |
877 | scroll1.size_y=WB1.height; |
881 | scroll1.size_y=WB1.height; |
878 | 882 | ||
879 | scrollbar_v_draw(#scroll1); |
883 | scrollbar_v_draw(#scroll1); |
880 | }>=0)>>>>>>16><16>>=>=>>=72)>7);>>>>>>>>>=>!--> |
884 | }>=0)>>>>>>16><16>>=>=>>=72)>7);>>>>>>>>>=>!--> |
881 | >': |
885 | >': |
882 | >')>>>>>0)>>>>>>=>>>>>> |
886 | >')>>>>>0)>>>>>>=>>>>>> |