Rev 3058 | 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 | bukva = ' '; |
||
380 | goto DEFAULT_MARK; |
||
381 | case '=': //поддержка шайтанской кодировки страниц, сохранённых через ИЕ7 |
||
3058 | leency | 382 | if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; |
383 | |||
384 | |||
385 | bukva=ESBYTE[bword]; |
||
386 | strcpy(#temp,#bukva); |
||
387 | bword++; |
||
388 | bukva=ESBYTE[bword]; |
||
389 | strcat(#temp,#bukva); |
||
390 | |||
391 | |||
392 | if (bukva) goto DEFAULT_MARK; |
||
393 | break; |
||
394 | |||
395 | |||
396 | bword++; |
||
397 | tag=0; |
||
398 | for (j=0; (ESBYTE[bword]<>';') && (j<7); j++, bword++;) |
||
399 | { |
||
400 | bukva = ESBYTE[bword]; |
||
401 | strcat(#tag, #bukva); |
||
402 | } |
||
403 | |||
404 | |||
405 | { |
||
406 | if (!strcmp(#tag, unicode_tags[j])) |
||
407 | { |
||
408 | strcat(#line, unicode_tags[j+1]); |
||
409 | break 1; |
||
410 | } |
||
411 | } |
||
412 | |||
413 | |||
414 | if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5) |
||
415 | { |
||
416 | bukva = unicode_chars[rez]; |
||
417 | //GOTO DEFAULT_MARK; //обрабатываем букву лучше наверно strcat(#line, unicode_tags[j+1]); и break 1; |
||
418 | strcat(#line, #bukva); |
||
419 | break; |
||
420 | } |
||
421 | |||
422 | |||
423 | break; |
||
424 | case '<': |
||
2413 | leency | 425 | bword++; //промотаем символ < |
426 | tag = parametr = tagparam = ignor_param = NULL; |
||
3058 | leency | 427 | if (ESBYTE[bword] == '!') //фильтрация внутри , дерзко |
2810 | leency | 428 | { |
2413 | leency | 429 | bword++; |
430 | if (ESBYTE[bword] == '-') |
||
2844 | leency | 431 | { |
432 | HH_: |
||
433 | do |
||
2818 | leency | 434 | { |
435 | bword++; |
||
2413 | leency | 436 | if (buf + filesize <= bword) break 2; |
2844 | leency | 437 | } |
2818 | leency | 438 | while (ESBYTE[bword] <>'-'); |
439 | |||
440 | |||
2413 | leency | 441 | if (ESBYTE[bword] <>'-') goto HH_; |
2810 | leency | 442 | } |
2413 | leency | 443 | } |
444 | while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //получаем тег и его параметры |
||
2823 | leency | 445 | { |
2413 | leency | 446 | bukva = ESBYTE[bword]; |
447 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
||
2810 | leency | 448 | if (!ignor_param) && (bukva <>' ') |
2840 | leency | 449 | { |
450 | if (strlen(#tag) |
||
451 | } |
||
452 | else |
||
2810 | leency | 453 | { |
454 | ignor_param = true; |
||
2413 | leency | 455 | if (!ignor_text) && (strlen(#tagparam)+1 |
2840 | leency | 456 | } |
2413 | leency | 457 | bword++; |
458 | } |
||
459 | strlwr(#tag); |
||
2844 | leency | 460 | strlwr(#tagparam); |
461 | |||
2418 | leency | 462 | |
3058 | leency | 463 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
2844 | leency | 464 | |
2413 | leency | 465 | |
2844 | leency | 466 | line=NULL; |
3058 | leency | 467 | |
2844 | leency | 468 | |
469 | |||
470 | |||
3058 | leency | 471 | break; |
2413 | leency | 472 | default: |
473 | DEFAULT_MARK: |
||
474 | if (!pre_text) && (bukva == ' ') |
||
3059 | leency | 475 | { |
476 | if (line[strlen(#line)-1]==' ') break; //убрать 2 пробела подряд |
||
477 | if (!stolbec) && (!line) break; //строка не может начинаться с пробела |
||
478 | } |
||
479 | if (strlen(#line) |
||
480 | |||
481 | |||
2818 | leency | 482 | { |
2413 | leency | 483 | NEXT_MARK: |
3059 | leency | 484 | perenos_num = strrchr(#line, ' '); |
2839 | leency | 485 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
3059 | leency | 486 | strcpy(#temp, #line + perenos_num); //перенос по словам |
2818 | leency | 487 | line[perenos_num] = 0x00; |
488 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //уходим... |
||
489 | DrawPage(); |
||
2844 | leency | 490 | TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //закрашиваем следущую строку |
2413 | leency | 491 | strcpy(#line, #temp); |
2810 | leency | 492 | } |
2413 | leency | 493 | } |
2844 | leency | 494 | } |
2413 | leency | 495 | |
2420 | leency | 496 | |
3059 | leency | 497 | if (lines.visible * 10 + 25 <= height) |
2811 | leency | 498 | DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color); |
499 | if (stroka * 10 + 15 <= height) |
||
2420 | leency | 500 | DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //закрашиваем всё до конца |
501 | if (lines.first == 0) lines.all = stroka; |
||
2811 | leency | 502 | if (anchor) |
2793 | leency | 503 | { |
504 | //если посреди текста появится новый якорь - будет бесконечный цикл |
||
2844 | leency | 505 | anchor=''; |
2810 | leency | 506 | lines.first=anchor_line_num; |
2811 | leency | 507 | ParseHTML(buf); |
2823 | leency | 508 | } |
2793 | leency | 509 | |
2825 | leency | 510 | |
2844 | leency | 511 | } |
2413 | leency | 512 | |
513 | |||
2844 | leency | 514 | { |
515 | int start_x, start_y, line_length; |
||
516 | char temp[sizeof(line)]; |
||
517 | |||
518 | |||
519 | { |
||
520 | if (strlen(#version)+strlen(#line)+2>sizeof(header)) |
||
521 | { |
||
522 | strcpy(#temp, #line); |
||
523 | temp[sizeof(header)-strlen(#version)-2]=0; |
||
524 | strcpy(#header, #temp); |
||
525 | strcpy(#line, #line+strlen(#temp)); |
||
526 | } |
||
527 | else |
||
528 | { |
||
529 | strcpy(#header, #line); |
||
530 | line=0; |
||
531 | } |
||
532 | |||
533 | |||
534 | strcat(#header, #version); |
||
535 | return; |
||
536 | } |
||
537 | |||
3058 | leency | 538 | |
2844 | leency | 539 | { |
540 | if (!stroka) && (!stolbec) |
||
541 | { |
||
542 | DrawBar(left, top, width-15, 15, bg_color); //закрашиваем первую строку |
||
543 | first_line_drawed=1; |
||
544 | } |
||
545 | |||
546 | |||
547 | start_y=stroka * 10 + top + 5; |
||
548 | line_length=strlen(#line)*6; |
||
549 | |||
3005 | leency | 550 | |
551 | { |
||
552 | //line_length = get_length stdcall (#line,-1,16,line_length); |
||
553 | text_out stdcall (#line, #fontlol, 17, text_colors[text_color_index], start_x, start_y-3); |
||
3028 | leency | 554 | } |
3005 | leency | 555 | else |
556 | { |
||
557 | WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line, 0); |
||
558 | IF (b_text) { $add ebx, 1<<16 $int 0x40 } |
||
559 | } |
||
560 | IF (i_text) Skew(start_x, start_y, line_length+6, 10); |
||
2844 | leency | 561 | IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]); |
562 | IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
||
563 | IF (link) { |
||
564 | DefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); |
||
565 | DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
||
566 | } |
||
567 | stolbec += strlen(#line); |
||
568 | } |
||
569 | } |
||
570 | |||
571 | |||
572 | |||
2413 | leency | 573 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
574 | dword hr_color; |
||
575 | |||
576 | |||
2825 | leency | 577 | char temp[4096], alt[4096]; |
3058 | leency | 578 | int w=0, h=0, img_lines_first=0; |
2844 | leency | 579 | |
2413 | leency | 580 | |
581 | if (tag[0] == '/') |
||
2844 | leency | 582 | { |
2413 | leency | 583 | rez = 0; |
584 | strcpy(#tag, #tag+1); |
||
2810 | leency | 585 | } |
2413 | leency | 586 | else |
2844 | leency | 587 | rez = 1; |
2413 | leency | 588 | |
2844 | leency | 589 | |
590 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
||
2413 | leency | 591 | return; |
592 | } |
||
593 | |||
594 | |||
2844 | leency | 595 | |
2793 | leency | 596 | |
2844 | leency | 597 | { |
2413 | leency | 598 | if (rez) |
2844 | leency | 599 | { |
2818 | leency | 600 | header=0; |
2844 | leency | 601 | } |
2818 | leency | 602 | else //тег закрылся - вывели строку |
2844 | leency | 603 | { |
604 | if (stroka==0) DrawTitle(#header); |
||
605 | } |
||
2413 | leency | 606 | return; |
2844 | leency | 607 | } |
2413 | leency | 608 | |
2823 | leency | 609 | |
2844 | leency | 610 | |
2420 | leency | 611 | |
2844 | leency | 612 | |
613 | |||
614 | |||
615 | |||
616 | |||
617 | |||
2793 | leency | 618 | { |
619 | if (!strcmp(#anchor, #options)) |
||
620 | { |
||
621 | anchor_line_num=lines.first+stroka; |
||
2811 | leency | 622 | } |
2793 | leency | 623 | } |
624 | |||
2844 | leency | 625 | |
2413 | leency | 626 | { |
627 | BODY_MARK: |
||
628 | |||
629 | |||
2823 | leency | 630 | link_color = GetColor(#options); |
2413 | leency | 631 | |
632 | |||
2823 | leency | 633 | text_colors[0]=GetColor(#options); |
2413 | leency | 634 | |
635 | |||
2823 | leency | 636 | bg_color=GetColor(#options); |
2420 | leency | 637 | |
2413 | leency | 638 | |
2823 | leency | 639 | { |
640 | GetNextParam(); |
||
2413 | leency | 641 | GOTO BODY_MARK; |
642 | } |
||
2420 | leency | 643 | |
644 | |||
645 | } |
||
2413 | leency | 646 | |
2840 | leency | 647 | |
2793 | leency | 648 | { |
649 | if (rez) |
||
650 | { |
||
651 | |||
2874 | leency | 652 | |
653 | |||
2839 | leency | 654 | |
2793 | leency | 655 | if (!strcmp(#parametr, "href=")) |
656 | { |
||
657 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
||
2811 | leency | 658 | |
2874 | leency | 659 | |
660 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
661 | |||
662 | |||
2413 | leency | 663 | blink++; |
664 | text_colors[text_color_index] = link_color; |
||
665 | strcat(#page_links, #options); |
||
2810 | leency | 666 | strcat(#page_links, "|"); |
667 | } |
||
2413 | leency | 668 | if (anchor) && (!strcmp(#parametr, "name=")) |
2793 | leency | 669 | { |
670 | if (!strcmp(#anchor, #options)) |
||
671 | { |
||
672 | anchor_line_num=lines.first+stroka; |
||
2811 | leency | 673 | } |
2793 | leency | 674 | } |
675 | if (tagparam) |
||
676 | { |
||
677 | GetNextParam(); |
||
2413 | leency | 678 | GOTO _A_MARK; |
2793 | leency | 679 | } |
2413 | leency | 680 | } |
681 | else { |
||
2844 | leency | 682 | link = 0; |
2413 | leency | 683 | IF(text_color_index > 0) text_color_index--; |
684 | } |
||
685 | return; |
||
686 | } |
||
687 | |||
2840 | leency | 688 | |
2844 | leency | 689 | |
2413 | leency | 690 | { |
691 | if (rez) |
||
2839 | leency | 692 | { |
2413 | leency | 693 | text_color_index++; |
694 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
2839 | leency | 695 | |
696 | |||
697 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
||
698 | { |
||
699 | text_colors[text_color_index] = GetColor(#options); |
||
700 | } |
||
701 | IF(tagparam) { |
||
702 | GetNextParam(); |
||
703 | GOTO COL_MARK; |
||
704 | } |
||
705 | } |
||
2413 | leency | 706 | else |
2839 | leency | 707 | if (text_color_index > 0) text_color_index--; |
708 | return; |
||
2413 | leency | 709 | } |
710 | |||
2840 | leency | 711 | |
2810 | leency | 712 | TextGoDown(left1, top1, width1); |
2413 | leency | 713 | return; |
714 | } |
||
715 | if (!chTag("div")) { |
||
2810 | leency | 716 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
2413 | leency | 717 | return; |
718 | } |
||
719 | if (!chTag("p")) { |
||
2810 | leency | 720 | IF(oldtag[0] == 'h') return; |
2413 | leency | 721 | TextGoDown(left1, top1, width1); |
722 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
||
723 | return; |
||
724 | } |
||
725 | |||
2840 | leency | 726 | |
2810 | leency | 727 | TextGoDown(left1, top1, width1); |
2413 | leency | 728 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
729 | b_text = rez; |
||
730 | strcpy(#oldtag, #tag); |
||
2810 | leency | 731 | return; |
2413 | leency | 732 | } |
2810 | leency | 733 | else |
734 | oldtag=''; |
||
735 | |||
736 | |||
737 | b_text = rez; |
||
2413 | leency | 738 | return; |
739 | } |
||
740 | //////////////////////////// |
||
741 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
||
2810 | leency | 742 | i_text = rez; |
2413 | leency | 743 | return; |
744 | } |
||
745 | //////////////////////////// |
||
746 | if (!chTag("dt")) |
||
2696 | leency | 747 | { |
2413 | leency | 748 | li_text = rez; |
749 | IF(rez == 0) return; |
||
750 | TextGoDown(left1, top1, width1); |
||
751 | return; |
||
752 | } |
||
753 | ///////////////////////////// |
||
2696 | leency | 754 | if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки |
2823 | leency | 755 | { |
2696 | leency | 756 | li_text = rez; |
757 | IF(rez == 0) return; |
||
758 | TextGoDown(left1, top1, width1); |
||
759 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
||
2811 | leency | 760 | return; |
2696 | leency | 761 | } |
762 | //////////////////////////// |
||
2413 | leency | 763 | IF(!chTag("u")) || (!chTag("ins")) u_text = rez; |
764 | IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
||
765 | IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) { |
||
766 | li_text = rez; |
||
767 | li_tab--; |
||
768 | TextGoDown(left1, top1, width1); |
||
769 | } ELSE li_tab++; |
||
770 | IF(!chTag("dd")) stolbec += 5; |
||
771 | IF(!chTag("blockquote")) blq_text = rez; |
||
772 | IF(!chTag("pre")) pre_text = rez; |
||
773 | IF(!chTag("hr")) { |
||
774 | TextGoDown(left1, top1, width1); |
||
775 | TextGoDown(left1, top1 + 10, width1); |
||
776 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
||
777 | ELSE hr_color = 0x999999; |
||
778 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
||
779 | } |
||
780 | |||
781 | |||
782 | { |
||
783 | if (GetFileInfo(libimg)<>0) return; //если библиотеки нет |
||
3020 | leency | 784 | IMG_TAG: |
2413 | leency | 785 | if (!strcmp(#parametr,"src=")) //надо объединить с GetNewUrl() |
2823 | leency | 786 | { |
787 | if (downloader_id) strcpy(#temp, #history_list[history_current-1].Item); |
||
3058 | leency | 788 | else strcpy(#temp, BrowserHistory.CurrentUrl()); //достаём адрес текущей страницы |
2895 | leency | 789 | if (strcmpn(#temp, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0) |
3058 | leency | 790 | { |
791 | temp[strrchr(#temp, '/')] = 0x00; //обрезаем её урл до последнего / |
||
792 | strcat(#temp, #options); |
||
793 | image=load_image(#temp); |
||
794 | w=DSWORD[image+4]; |
||
795 | h=DSWORD[image+8]; |
||
796 | } |
||
797 | } |
||
2823 | leency | 798 | if (!strcmp(#parametr,"alt=")) |
3058 | leency | 799 | { |
2823 | leency | 800 | strcpy(#alt, "["); |
3058 | leency | 801 | strcat(#alt, #options); |
802 | strcat(#alt, "]"); |
||
803 | } |
||
804 | |||
2823 | leency | 805 | |
806 | { |
||
807 | GetNextParam(); |
||
2413 | leency | 808 | GOTO IMG_TAG; |
809 | } |
||
810 | |||
2823 | leency | 811 | |
3058 | leency | 812 | { |
813 | if (alt) && (link) strcat(#line, #alt); |
||
814 | return; |
||
815 | } |
||
816 | |||
3020 | leency | 817 | |
2413 | leency | 818 | |
3020 | leency | 819 | |
2823 | leency | 820 | stroka+=h/10; |
821 | if (top1+h |
||
3020 | leency | 822 | if (top1 |
2823 | leency | 823 | { |
824 | DrawBar(left, top, width-15, 10, bg_color); //закрашиваем первую строку |
||
825 | img_lines_first=WB1.top-top1; |
||
826 | h=h-img_lines_first; |
||
827 | top1=WB1.top; |
||
828 | } |
||
829 | if (top1>WB1.top+WB1.height-h-15) //если часть изображения снизу |
||
3020 | leency | 830 | { |
2823 | leency | 831 | h=WB1.top+WB1.height-top1-15; |
832 | } |
||
833 | if (h<=0) return; |
||
2844 | leency | 834 | if (anchor) return; |
835 | |||
2823 | leency | 836 | |
837 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
||
838 | IF (link) DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
||
3020 | leency | 839 | return; |
2413 | leency | 840 | } |
841 | |||
842 | |||
2605 | leency | 843 | { |
2413 | leency | 844 | META: |
845 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
||
2605 | leency | 846 | { |
2413 | leency | 847 | strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content= |
2839 | leency | 848 | |
2413 | leency | 849 | |
3058 | leency | 850 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
851 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
||
852 | } |
||
2413 | leency | 853 | if (tagparam) |
2810 | leency | 854 | { |
2413 | leency | 855 | GetNextParam(); |
856 | goto META; |
||
857 | } |
||
858 | return; |
||
859 | } |
||
860 | } |
||
861 | |||
862 | |||
863 | |||
2739 | leency | 864 | { |
865 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
||
2818 | leency | 866 | { |
867 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //закрашиваем первую строку |
||
868 | first_line_drawed=1; |
||
869 | } |
||
870 | stroka++; |
||
2413 | leency | 871 | if (blq_text) stolbec = 8; |
2818 | leency | 872 | ELSE stolbec = 0; |
2413 | leency | 873 | if (li_text) stolbec = li_tab * 5; |
2818 | leency | 874 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
2811 | leency | 875 | } |
2413 | leency | 876 | |
877 | |||
878 | |||
879 | void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте |
||
2739 | leency | 880 | { |
881 | scroll1.max_area = lines.all; |
||
2811 | leency | 882 | scroll1.cur_area = lines.visible; |
883 | scroll1.position = lines.first; |
||
884 | |||
2413 | leency | 885 | |
2739 | leency | 886 | scroll1.start_x=Form.width-28; //left + width - 15 |
887 | scroll1.size_y=WB1.height; |
||
888 | |||
2413 | leency | 889 | |
2739 | leency | 890 | }>=0)>>>>>16><16>>=>=>>>>>>>>=>!--> |
3028 | leency | 891 | >': |