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