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