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