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