Rev 3060 | 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]=NULL; |
||
3061 | leency | 284 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
2764 | leency | 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 = NULL; |
3061 | 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 = NULL; |
||
3061 | 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 | |||
3061 | leency | 405 | if (bukva) goto DEFAULT_MARK; |
406 | break; |
||
3058 | leency | 407 | case '<': |
2413 | leency | 408 | bword++; //промотаем символ < |
409 | tag = parametr = tagparam = ignor_param = NULL; |
||
3058 | leency | 410 | if (ESBYTE[bword] == '!') //фильтрация внутри , дерзко |
2810 | leency | 411 | { |
2413 | leency | 412 | bword++; |
413 | if (ESBYTE[bword] == '-') |
||
2844 | leency | 414 | { |
415 | HH_: |
||
416 | do |
||
2818 | leency | 417 | { |
418 | bword++; |
||
2413 | leency | 419 | if (buf + filesize <= bword) break 2; |
2844 | leency | 420 | } |
2818 | leency | 421 | while (ESBYTE[bword] <>'-'); |
422 | |||
423 | |||
2413 | leency | 424 | if (ESBYTE[bword] <>'-') goto HH_; |
2810 | leency | 425 | } |
2413 | leency | 426 | } |
427 | while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //получаем тег и его параметры |
||
2823 | leency | 428 | { |
2413 | leency | 429 | bukva = ESBYTE[bword]; |
430 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
||
2810 | leency | 431 | if (!ignor_param) && (bukva <>' ') |
2840 | leency | 432 | { |
433 | if (strlen(#tag) |
||
434 | } |
||
435 | else |
||
2810 | leency | 436 | { |
437 | ignor_param = true; |
||
2413 | leency | 438 | if (!ignor_text) && (strlen(#tagparam)+1 |
2840 | leency | 439 | } |
2413 | leency | 440 | bword++; |
441 | } |
||
442 | strlwr(#tag); |
||
2844 | leency | 443 | strlwr(#tagparam); |
444 | |||
2418 | leency | 445 | |
3058 | leency | 446 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
2844 | leency | 447 | |
2413 | leency | 448 | |
3060 | leency | 449 | { |
450 | perenos_num = strrchr(#line, ' '); |
||
451 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
||
452 | strcpy(#temp, #line + perenos_num); //перенос по словам |
||
453 | line[perenos_num] = 0x00; |
||
454 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //уходим... |
||
455 | DrawPage(); |
||
456 | strcpy(#line, #temp); |
||
457 | |||
458 | |||
459 | } |
||
460 | DrawPage(); |
||
2844 | leency | 461 | line=NULL; |
3058 | leency | 462 | |
2844 | leency | 463 | |
464 | |||
465 | |||
3058 | leency | 466 | break; |
2413 | leency | 467 | default: |
468 | DEFAULT_MARK: |
||
469 | if (!pre_text) && (bukva == ' ') |
||
3059 | leency | 470 | { |
471 | if (line[strlen(#line)-1]==' ') break; //убрать 2 пробела подряд |
||
472 | if (!stolbec) && (!line) break; //строка не может начинаться с пробела |
||
473 | } |
||
474 | if (strlen(#line) |
||
475 | |||
476 | |||
2818 | leency | 477 | { |
2413 | leency | 478 | NEXT_MARK: |
3059 | leency | 479 | perenos_num = strrchr(#line, ' '); |
2839 | leency | 480 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
3059 | leency | 481 | strcpy(#temp, #line + perenos_num); //перенос по словам |
2818 | leency | 482 | line[perenos_num] = 0x00; |
483 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //уходим... |
||
484 | DrawPage(); |
||
2844 | leency | 485 | strcpy(#line, #temp); |
3060 | leency | 486 | |
487 | |||
2413 | leency | 488 | } |
489 | } |
||
2844 | leency | 490 | } |
2413 | leency | 491 | |
2420 | leency | 492 | |
3059 | leency | 493 | if (lines.visible * 10 + 25 <= height) |
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=NULL; |
3061 | 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; |
3061 | leency | 580 | strcpy(#tag, #tag+1); |
581 | } |
||
2413 | leency | 582 | else rez = 1; |
3061 | leency | 583 | |
2844 | leency | 584 | |
3061 | 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) header=NULL; |
3061 | leency | 595 | else if (!stroka) DrawTitle(#header); //тег закрылся - вывели строку |
596 | return; |
||
2844 | leency | 597 | } |
2413 | leency | 598 | |
2823 | leency | 599 | |
2844 | leency | 600 | |
2420 | leency | 601 | |
2844 | leency | 602 | |
603 | |||
604 | |||
605 | |||
606 | |||
607 | |||
2793 | leency | 608 | { |
609 | if (!strcmp(#anchor, #options)) anchor_line_num=lines.first+stroka; |
||
3061 | leency | 610 | } |
2793 | leency | 611 | |
2844 | leency | 612 | |
2413 | leency | 613 | { |
614 | do{ |
||
3061 | leency | 615 | if (!strcmp(#parametr, "link=")) link_color = GetColor(#options); |
616 | if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options); |
||
617 | if (!strcmp(#parametr, "bgcolor=")) bg_color=GetColor(#options); |
||
618 | } while(GetNextParam()); |
||
619 | |||
2413 | leency | 620 | |
2420 | leency | 621 | } |
2413 | leency | 622 | |
2840 | leency | 623 | |
2793 | leency | 624 | { |
625 | if (rez) |
||
626 | { |
||
627 | if (link) IF(text_color_index > 0) text_color_index--; //если предыдущий тег а не был закрыт |
||
2874 | leency | 628 | |
2839 | leency | 629 | |
3061 | leency | 630 | if (!strcmp(#parametr, "href=")) |
631 | { |
||
2793 | leency | 632 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
3061 | leency | 633 | |
634 | |||
635 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
636 | |||
637 | |||
638 | blink++; |
||
639 | text_colors[text_color_index] = link_color; |
||
640 | strcat(#page_links, #options); |
||
641 | strcat(#page_links, "|"); |
||
642 | } |
||
2793 | leency | 643 | if (anchor) && (!strcmp(#parametr, "name=")) |
3061 | leency | 644 | { |
645 | if (!strcmp(#anchor, #options)) |
||
646 | { |
||
647 | anchor_line_num=lines.first+stroka; |
||
648 | } |
||
649 | } |
||
650 | } while(GetNextParam()); |
||
651 | } |
||
2413 | leency | 652 | else { |
2844 | leency | 653 | link = 0; |
2413 | leency | 654 | IF(text_color_index > 0) text_color_index--; |
655 | } |
||
656 | return; |
||
657 | } |
||
658 | |||
2840 | leency | 659 | |
2844 | leency | 660 | |
2413 | leency | 661 | { |
662 | if (rez) |
||
2839 | leency | 663 | { |
2413 | leency | 664 | text_color_index++; |
665 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
2839 | leency | 666 | |
667 | |||
3061 | leency | 668 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
669 | { |
||
670 | text_colors[text_color_index] = GetColor(#options); |
||
671 | } |
||
672 | } while(GetNextParam()); |
||
673 | } |
||
2413 | leency | 674 | else |
2839 | leency | 675 | if (text_color_index > 0) text_color_index--; |
676 | return; |
||
2413 | leency | 677 | } |
678 | |||
2840 | leency | 679 | |
2810 | leency | 680 | TextGoDown(left1, top1, width1); |
2413 | leency | 681 | return; |
682 | } |
||
683 | if (!chTag("div")) { |
||
2810 | leency | 684 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
2413 | leency | 685 | return; |
686 | } |
||
687 | if (!chTag("p")) { |
||
2810 | leency | 688 | IF(oldtag[0] == 'h') return; |
2413 | leency | 689 | TextGoDown(left1, top1, width1); |
690 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
||
691 | return; |
||
692 | } |
||
693 | |||
2840 | leency | 694 | |
2810 | leency | 695 | TextGoDown(left1, top1, width1); |
2413 | leency | 696 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
697 | b_text = rez; |
||
698 | strcpy(#oldtag, #tag); |
||
2810 | leency | 699 | return; |
2413 | leency | 700 | } |
2810 | leency | 701 | else |
702 | oldtag=NULL; |
||
3061 | leency | 703 | |
2810 | leency | 704 | |
705 | b_text = rez; |
||
2413 | leency | 706 | return; |
707 | } |
||
708 | //////////////////////////// |
||
709 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
||
2810 | leency | 710 | i_text = rez; |
2413 | leency | 711 | return; |
712 | } |
||
713 | //////////////////////////// |
||
714 | if (!chTag("dt")) |
||
2696 | leency | 715 | { |
2413 | leency | 716 | li_text = rez; |
717 | IF(rez == 0) return; |
||
718 | TextGoDown(left1, top1, width1); |
||
719 | return; |
||
720 | } |
||
721 | ///////////////////////////// |
||
2696 | leency | 722 | if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки |
2823 | leency | 723 | { |
2696 | leency | 724 | li_text = rez; |
725 | IF(rez == 0) return; |
||
726 | TextGoDown(left1, top1, width1); |
||
727 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
||
2811 | leency | 728 | return; |
2696 | leency | 729 | } |
730 | //////////////////////////// |
||
2413 | leency | 731 | IF(!chTag("u")) || (!chTag("ins")) u_text = rez; |
732 | IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
||
733 | IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) { |
||
734 | li_text = rez; |
||
735 | li_tab--; |
||
736 | TextGoDown(left1, top1, width1); |
||
737 | } ELSE li_tab++; |
||
738 | IF(!chTag("dd")) stolbec += 5; |
||
739 | IF(!chTag("blockquote")) blq_text = rez; |
||
740 | IF(!chTag("pre")) pre_text = rez; |
||
741 | IF(!chTag("hr")) { |
||
742 | TextGoDown(left1, top1, width1); |
||
743 | TextGoDown(left1, top1 + 10, width1); |
||
744 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
||
745 | ELSE hr_color = 0x999999; |
||
746 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
||
747 | } |
||
748 | |||
749 | |||
750 | { |
||
751 | if (GetFileInfo(libimg)<>0) return; //если библиотеки нет |
||
3020 | leency | 752 | do{ |
3061 | leency | 753 | if (!strcmp(#parametr,"src=")) //надо объединить с GetNewUrl() |
2823 | leency | 754 | { |
755 | if (downloader_id) strcpy(#temp, #history_list[history_current-1].Item); |
||
3058 | leency | 756 | else strcpy(#temp, BrowserHistory.CurrentUrl()); //достаём адрес текущей страницы |
2895 | leency | 757 | if (strcmpn(#temp, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0) |
3058 | leency | 758 | { |
759 | temp[strrchr(#temp, '/')] = 0x00; //обрезаем её урл до последнего / |
||
760 | strcat(#temp, #options); |
||
761 | image=load_image(#temp); |
||
762 | w=DSWORD[image+4]; |
||
763 | h=DSWORD[image+8]; |
||
764 | } |
||
765 | } |
||
2823 | leency | 766 | if (!strcmp(#parametr,"alt=")) |
3058 | leency | 767 | { |
2823 | leency | 768 | strcpy(#alt, "["); |
3058 | leency | 769 | strcat(#alt, #options); |
770 | strcat(#alt, "]"); |
||
771 | } |
||
772 | |||
2823 | leency | 773 | |
3061 | leency | 774 | |
2823 | leency | 775 | |
3058 | leency | 776 | { |
777 | if (alt) && (link) strcat(#line, #alt); |
||
778 | return; |
||
779 | } |
||
780 | |||
3020 | leency | 781 | |
2413 | leency | 782 | |
3020 | leency | 783 | |
2823 | leency | 784 | stroka+=h/10; |
785 | if (top1+h |
||
3020 | leency | 786 | if (top1 |
2823 | leency | 787 | { |
788 | DrawBar(left, top, width-15, 10, bg_color); //закрашиваем первую строку |
||
789 | img_lines_first=WB1.top-top1; |
||
790 | h=h-img_lines_first; |
||
791 | top1=WB1.top; |
||
792 | } |
||
793 | if (top1>WB1.top+WB1.height-h-15) //если часть изображения снизу |
||
3020 | leency | 794 | { |
2823 | leency | 795 | h=WB1.top+WB1.height-top1-15; |
796 | } |
||
797 | if (h<=0) return; |
||
2844 | leency | 798 | if (anchor) return; |
799 | |||
2823 | leency | 800 | |
801 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
||
802 | IF (link) DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
||
3020 | leency | 803 | return; |
2413 | leency | 804 | } |
805 | |||
806 | |||
2605 | leency | 807 | { |
2413 | leency | 808 | do{ |
3061 | leency | 809 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
810 | { |
||
811 | strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content= |
||
812 | |||
2413 | leency | 813 | |
3061 | leency | 814 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
815 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
||
816 | } |
||
817 | } while(GetNextParam()); |
||
818 | return; |
||
2413 | leency | 819 | } |
820 | } |
||
821 | |||
822 | |||
823 | |||
2739 | leency | 824 | { |
825 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
||
2818 | leency | 826 | { |
827 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //закрашиваем первую строку |
||
828 | first_line_drawed=1; |
||
829 | } |
||
830 | stroka++; |
||
2413 | leency | 831 | if (blq_text) stolbec = 8; |
2818 | leency | 832 | ELSE stolbec = 0; |
2413 | leency | 833 | if (li_text) stolbec = li_tab * 5; |
2818 | leency | 834 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
2811 | leency | 835 | } |
2413 | leency | 836 | |
837 | |||
838 | |||
839 | void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте |
||
2739 | leency | 840 | { |
841 | scroll1.max_area = lines.all; |
||
2811 | leency | 842 | scroll1.cur_area = lines.visible; |
843 | scroll1.position = lines.first; |
||
844 | |||
2413 | leency | 845 | |
2739 | leency | 846 | scroll1.start_x=Form.width-28; //left + width - 15 |
847 | scroll1.size_y=WB1.height; |
||
848 | |||
2413 | leency | 849 | |
2739 | leency | 850 | }>=0)>>>>>16><16>>=>=>>>>>>>>>=>!--> |
3028 | leency | 851 | >': |