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