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