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