Rev 2818 | 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.94d"; |
||
2823 | 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 | |||
42 | tag[100], |
||
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 | |
321 | |||
322 | |||
2823 | leency | 323 | bukva = ESBYTE[bword]; |
2413 | leency | 324 | switch (bukva) { |
325 | case 0x0a: |
||
326 | if (pre_text) |
||
2818 | leency | 327 | { |
328 | bukva = ''; |
||
2413 | leency | 329 | temp = ''; |
330 | goto NEXT_MARK; |
||
331 | } |
||
332 | case '\9': |
||
2605 | leency | 333 | if (pre_text) //иначе идём на 0x0d |
2818 | leency | 334 | { |
2413 | leency | 335 | tab_len=strlen(#line)/8; |
336 | tab_len=tab_len*8; |
||
337 | tab_len=8+tab_len-strlen(#line); |
||
338 | for (i=0; i |
||
2810 | leency | 339 | break; |
2413 | leency | 340 | } |
341 | case 0x0d: |
||
342 | bukva = ' '; |
||
343 | goto DEFAULT_MARK; |
||
344 | case '<': |
||
345 | bword++; //промотаем символ < |
||
346 | if (ESBYTE[bword] == '!') //фильтрация внутри , дерзко |
||
2810 | leency | 347 | { |
2413 | leency | 348 | bword++; |
349 | if (ESBYTE[bword] == '-') { |
||
2810 | leency | 350 | HH_: |
2818 | leency | 351 | do |
352 | { |
||
353 | bword++; |
||
2413 | leency | 354 | if (bword >= buf + filesize) break 1; |
2823 | leency | 355 | } |
2818 | leency | 356 | while (ESBYTE[bword] <>'-'); |
357 | |||
358 | |||
2413 | leency | 359 | if (ESBYTE[bword] <>'-') goto HH_; |
2810 | leency | 360 | } |
2413 | leency | 361 | } |
362 | while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //получаем тег и его параметры |
||
2823 | leency | 363 | { |
2413 | leency | 364 | bukva = ESBYTE[bword]; |
365 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
||
2810 | leency | 366 | if (!ignor_param) && (bukva <>' ') strcat(#tag, #bukva); |
367 | else |
||
368 | { |
||
369 | ignor_param = true; |
||
2413 | leency | 370 | strcat(#tagparam, #bukva); |
2810 | leency | 371 | } |
2413 | leency | 372 | bword++; |
373 | } |
||
374 | lowcase(#tag); |
||
375 | lowcase(#tagparam); |
||
376 | |||
2418 | leency | 377 | |
2810 | leency | 378 | if (strlen(#tagparam) > 0) && (strlen(#tagparam) < 4000) GetNextParam(); |
379 | //while (tagparam) |
||
2823 | leency | 380 | //{ |
381 | // GetNextParam(); |
||
382 | WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //обработка тегов |
||
383 | //} |
||
384 | |||
2413 | leency | 385 | |
386 | |||
2793 | leency | 387 | |
2413 | leency | 388 | case '=': //поддержка шайтанской кодировки страниц, сохранённых через ИЕ7 |
389 | if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; |
||
2810 | leency | 390 | |
2413 | leency | 391 | |
392 | bukva=ESBYTE[bword]; |
||
393 | strcpy(#temp,#bukva); |
||
2810 | leency | 394 | bword++; |
2413 | leency | 395 | bukva=ESBYTE[bword]; |
396 | strcat(#temp,#bukva); |
||
2810 | leency | 397 | |
2413 | leency | 398 | |
399 | if (bukva) goto DEFAULT_MARK; |
||
2810 | leency | 400 | break; |
2413 | leency | 401 | |
402 | |||
403 | if (ignor_text) break; |
||
2810 | leency | 404 | bword++; |
2413 | leency | 405 | tag=''; |
406 | for (j=0; (ESBYTE[bword] <>';') && (j < 7); j++, bword++;) |
||
2810 | leency | 407 | { |
2413 | leency | 408 | bukva = ESBYTE[bword]; |
409 | strcat(#tag, #bukva); |
||
2810 | leency | 410 | } |
2413 | leency | 411 | |
412 | |||
2810 | leency | 413 | { |
2413 | leency | 414 | if (!strcmp(#tag, unicode_tags[j])) |
2810 | leency | 415 | { |
2413 | leency | 416 | strcat(#line, unicode_tags[j+1]); |
2810 | leency | 417 | break 1; |
2413 | leency | 418 | } |
419 | } |
||
420 | |||
421 | |||
422 | if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5) |
||
2810 | leency | 423 | { |
2413 | leency | 424 | bukva = unicode_chars[rez]; |
425 | GOTO DEFAULT_MARK; //обрабатываем букву |
||
426 | } |
||
427 | |||
428 | |||
2810 | leency | 429 | strcat(#line,#tag); //выводим на экран необработанный тег, так браузеры зачем-то делают |
430 | break; |
||
2413 | leency | 431 | default: |
432 | DEFAULT_MARK: |
||
433 | if (ignor_text) break; |
||
2818 | leency | 434 | if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break; |
435 | // |
||
2413 | leency | 436 | if (stolbec + strlen(#line) > lines.column_max) |
2818 | leency | 437 | { |
2413 | leency | 438 | perenos_num = find_symbol(#line, ' '); |
2818 | leency | 439 | strcpy(#temp, #line + perenos_num); //перенос по словам |
440 | line[perenos_num] = 0x00; |
||
441 | NEXT_MARK: |
||
2810 | leency | 442 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //уходим... |
2818 | leency | 443 | WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //вывод строки |
2413 | leency | 444 | TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //закрашиваем следущую строку |
445 | strcpy(#line, #temp); |
||
2810 | leency | 446 | } |
2413 | leency | 447 | if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break; |
2818 | leency | 448 | strcat(#line, #bukva); |
2810 | leency | 449 | } |
2413 | leency | 450 | } |
451 | |||
2420 | leency | 452 | |
2811 | leency | 453 | DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color); |
454 | if (stroka * 10 + 15 <= height) |
||
2420 | leency | 455 | DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //закрашиваем всё до конца |
456 | if (lines.first == 0) lines.all = stroka; |
||
2811 | leency | 457 | |
2793 | leency | 458 | |
459 | { |
||
460 | anchor=''; |
||
2810 | leency | 461 | lines.first=anchor_line_num; |
2811 | leency | 462 | ParseHTML(buf); |
2823 | leency | 463 | } |
2793 | leency | 464 | |
2818 | leency | 465 | |
466 | DrawScroller(); //рисуем скролл |
||
2413 | leency | 467 | } |
468 | |||
469 | |||
470 | |||
471 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
||
472 | dword hr_color; |
||
473 | |||
474 | |||
475 | char temp[4096]; |
||
476 | int w, h, img_lines_first=0; |
||
2810 | leency | 477 | |
2413 | leency | 478 | |
479 | IF(tag[0] == '/') |
||
480 | { |
||
481 | rez = 0; |
||
482 | strcpy(#tag, #tag+1); |
||
2810 | leency | 483 | } |
2413 | leency | 484 | ELSE |
485 | rez = 1; |
||
486 | |||
487 | |||
488 | IF(!chTag("html")) { |
||
489 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
||
490 | return; |
||
491 | } |
||
492 | IF(!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez; |
||
2660 | leency | 493 | |
2413 | leency | 494 | |
2418 | leency | 495 | { |
2413 | leency | 496 | strcpy(#header, #line); |
2810 | leency | 497 | strcat(#header, " -"); |
498 | strcat(#header, #version); |
||
499 | if (stroka==0) DrawTitle(#header); |
||
2418 | leency | 500 | return; |
2413 | leency | 501 | } |
502 | |||
503 | |||
2418 | leency | 504 | |
2793 | leency | 505 | |
2810 | leency | 506 | |
2413 | leency | 507 | |
508 | if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor) |
||
2811 | leency | 509 | { |
2413 | leency | 510 | if (stroka==0) && (stolbec==0) |
2818 | leency | 511 | { |
512 | DrawBar(left, top, width-15, 15, bg_color); //закрашиваем первую строку |
||
513 | first_line_drawed=1; |
||
514 | } |
||
515 | WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //может тут рисовать белую строку? |
||
2444 | leency | 516 | //text_out stdcall (#line, -1, 16, text_colors[text_color_index], stolbec * 6 + left1, top1); |
2818 | leency | 517 | IF (b_text) { $add ebx, 1<<16 $int 0x40 } |
2696 | leency | 518 | IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //наклонный текст |
2413 | leency | 519 | IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, strlen(#line) * 6, 1, text_colors[text_color_index]); //зачёркнутый |
520 | IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); //подчёркнутый |
||
521 | IF (link) { |
||
522 | DefineButton(stolbec * 6 + left1 - 2, top1, strlen(#line) * 6 + 3, 9, blink + BT_HIDE, 0xB5BFC9); // |
||
523 | DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); |
||
524 | } |
||
525 | } |
||
526 | |||
2823 | leency | 527 | |
2413 | leency | 528 | stolbec += strlen(#line); |
529 | |||
2420 | leency | 530 | |
2793 | leency | 531 | { |
532 | if (!strcmp(#anchor, #options)) |
||
533 | { |
||
534 | anchor_line_num=lines.first+stroka; |
||
2811 | leency | 535 | } |
2793 | leency | 536 | } |
537 | |||
538 | |||
2413 | leency | 539 | { |
540 | BODY_MARK: |
||
541 | |||
542 | |||
2823 | leency | 543 | link_color = GetColor(#options); |
2413 | leency | 544 | |
545 | |||
2823 | leency | 546 | text_colors[0]=GetColor(#options); |
2413 | leency | 547 | |
548 | |||
2823 | leency | 549 | bg_color=GetColor(#options); |
2420 | leency | 550 | |
2413 | leency | 551 | |
2823 | leency | 552 | { |
553 | GetNextParam(); |
||
2413 | leency | 554 | GOTO BODY_MARK; |
555 | } |
||
2420 | leency | 556 | |
557 | |||
558 | } |
||
2413 | leency | 559 | ////////////////////////// |
560 | if (!chTag("a")) |
||
2793 | leency | 561 | { |
562 | if (rez) |
||
563 | { |
||
564 | _A_MARK: |
||
565 | if (!strcmp(#parametr, "href=")) |
||
566 | { |
||
567 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
||
2811 | leency | 568 | if (link == 1) text_color_index--; //если какой-то долбоёб не закрыл тэг |
2793 | leency | 569 | link = 1; |
2413 | leency | 570 | blink++; |
571 | text_color_index++; |
||
572 | text_colors[text_color_index] = link_color; |
||
573 | strcat(#page_links, #options); |
||
2810 | leency | 574 | strcat(#page_links, "|"); |
575 | } |
||
2413 | leency | 576 | if (anchor) && (!strcmp(#parametr, "name=")) |
2793 | leency | 577 | { |
578 | if (!strcmp(#anchor, #options)) |
||
579 | { |
||
580 | anchor_line_num=lines.first+stroka; |
||
2811 | leency | 581 | } |
2793 | leency | 582 | } |
583 | if (tagparam) |
||
584 | { |
||
585 | GetNextParam(); |
||
2413 | leency | 586 | GOTO _A_MARK; |
2793 | leency | 587 | } |
2413 | leency | 588 | } |
589 | ELSE { |
||
590 | link = 0; |
||
591 | IF(text_color_index > 0) text_color_index--; |
||
592 | } |
||
593 | return; |
||
594 | } |
||
595 | ///////////////////////// |
||
596 | if (!chTag("font")) |
||
597 | { |
||
598 | IF (stroka - 1 > lines.visible) return; |
||
2811 | leency | 599 | COL_MARK: |
2413 | leency | 600 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
601 | { |
||
602 | text_color_index++; |
||
603 | text_colors[text_color_index] = GetColor(#options); |
||
604 | } |
||
605 | IF(tagparam) { |
||
606 | GetNextParam(); |
||
607 | GOTO COL_MARK; |
||
608 | } |
||
609 | IF(!rez) && (text_color_index > 0) text_color_index--; |
||
610 | return; |
||
611 | } |
||
612 | ////////////////////////// |
||
613 | if(!chTag("tr")) || (!chTag("br")) { |
||
2810 | leency | 614 | TextGoDown(left1, top1, width1); |
2413 | leency | 615 | return; |
616 | } |
||
617 | if (!chTag("div")) { |
||
2810 | leency | 618 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
2413 | leency | 619 | return; |
620 | } |
||
621 | if (!chTag("p")) { |
||
2810 | leency | 622 | IF(oldtag[0] == 'h') return; |
2413 | leency | 623 | TextGoDown(left1, top1, width1); |
624 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
||
625 | return; |
||
626 | } |
||
627 | //////////////////////////// |
||
628 | if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { |
||
2810 | leency | 629 | TextGoDown(left1, top1, width1); |
2413 | leency | 630 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
631 | b_text = rez; |
||
632 | strcpy(#oldtag, #tag); |
||
2810 | leency | 633 | return; |
2413 | leency | 634 | } |
2810 | leency | 635 | else |
636 | oldtag=''; |
||
637 | |||
638 | |||
639 | b_text = rez; |
||
2413 | leency | 640 | return; |
641 | } |
||
642 | //////////////////////////// |
||
643 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
||
2810 | leency | 644 | i_text = rez; |
2413 | leency | 645 | return; |
646 | } |
||
647 | //////////////////////////// |
||
648 | if (!chTag("dt")) |
||
2696 | leency | 649 | { |
2413 | leency | 650 | li_text = rez; |
651 | IF(rez == 0) return; |
||
652 | TextGoDown(left1, top1, width1); |
||
653 | return; |
||
654 | } |
||
655 | ///////////////////////////// |
||
2696 | leency | 656 | if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки |
2823 | leency | 657 | { |
2696 | leency | 658 | li_text = rez; |
659 | IF(rez == 0) return; |
||
660 | TextGoDown(left1, top1, width1); |
||
661 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
||
2811 | leency | 662 | return; |
2696 | leency | 663 | } |
664 | //////////////////////////// |
||
2413 | leency | 665 | IF(!chTag("u")) || (!chTag("ins")) u_text = rez; |
666 | IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
||
667 | IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) { |
||
668 | li_text = rez; |
||
669 | li_tab--; |
||
670 | TextGoDown(left1, top1, width1); |
||
671 | } ELSE li_tab++; |
||
672 | IF(!chTag("dd")) stolbec += 5; |
||
673 | IF(!chTag("blockquote")) blq_text = rez; |
||
674 | IF(!chTag("pre")) pre_text = rez; |
||
675 | IF(!chTag("hr")) { |
||
676 | TextGoDown(left1, top1, width1); |
||
677 | TextGoDown(left1, top1 + 10, width1); |
||
678 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
||
679 | ELSE hr_color = 0x999999; |
||
680 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
||
681 | } |
||
682 | |||
683 | |||
684 | { |
||
685 | //if (GetFileInfo(#libimg)<>0) return; //если библиотеки нет |
||
2823 | leency | 686 | IMG_TAG: |
2413 | leency | 687 | if (!strcmp(#parametr,"src=")) //надо объединить с GetNewUrl() |
2823 | leency | 688 | { |
689 | strcpy(#temp, BrowserHistory.CurrentUrl()); //достаём адрес текущей страницы |
||
2810 | leency | 690 | temp[find_symbol(#temp, '/')] = 0x00; //обрезаем её урл до последнего / |
2413 | leency | 691 | strcat(#temp, #options); |
2810 | leency | 692 | image=load_image(#temp); |
2413 | leency | 693 | w=DSWORD[image+4]; |
2823 | leency | 694 | h=DSWORD[image+8]; |
695 | } |
||
696 | if (!strcmp(#parametr,"alt=")) |
||
697 | { |
||
698 | strcpy(#tag, "[Image: "); |
||
699 | strcat(#tag, #options); |
||
700 | strcat(#tag, "]"); |
||
701 | } |
||
702 | |||
703 | |||
704 | { |
||
705 | GetNextParam(); |
||
2413 | leency | 706 | GOTO IMG_TAG; |
707 | } |
||
708 | |||
2823 | leency | 709 | |
710 | { |
||
711 | //debug(#tag); |
||
712 | return; |
||
713 | } |
||
714 | |||
2413 | leency | 715 | |
716 | |||
2823 | leency | 717 | |
718 | |||
2413 | leency | 719 | |
2823 | leency | 720 | |
721 | |||
722 | return; |
||
723 | |||
2413 | leency | 724 | |
2823 | leency | 725 | { |
726 | DrawBar(left, top, width-15, 10, bg_color); //закрашиваем первую строку |
||
727 | img_lines_first=WB1.top-top1; |
||
728 | h=h-img_lines_first; |
||
729 | top1=WB1.top; |
||
730 | } |
||
731 | |||
732 | |||
733 | { |
||
734 | h=WB1.top+WB1.height-top1-15; |
||
735 | } |
||
736 | |||
2413 | leency | 737 | |
2823 | leency | 738 | |
739 | |||
740 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
||
741 | IF (link) |
||
742 | { |
||
743 | DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
||
744 | } |
||
745 | |||
2433 | leency | 746 | |
2413 | leency | 747 | } |
748 | |||
749 | |||
2605 | leency | 750 | { |
2413 | leency | 751 | META: |
752 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
||
2605 | leency | 753 | { |
2413 | leency | 754 | strcpy(#options, #options[find_symbol(#options, '=')]); //поиск в content= |
2810 | leency | 755 | |
2413 | leency | 756 | |
2811 | leency | 757 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
758 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
||
759 | } |
||
2413 | leency | 760 | if (tagparam) |
2810 | leency | 761 | { |
2413 | leency | 762 | GetNextParam(); |
763 | goto META; |
||
764 | } |
||
765 | return; |
||
766 | } |
||
767 | } |
||
768 | |||
769 | |||
770 | |||
2739 | leency | 771 | { |
772 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
||
2818 | leency | 773 | { |
774 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //закрашиваем первую строку |
||
775 | first_line_drawed=1; |
||
776 | } |
||
777 | stroka++; |
||
2413 | leency | 778 | if (blq_text) stolbec = 8; |
2818 | leency | 779 | ELSE stolbec = 0; |
2413 | leency | 780 | if (li_text) stolbec = li_tab * 5; |
2818 | leency | 781 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
2811 | leency | 782 | } |
2413 | leency | 783 | |
784 | |||
785 | |||
786 | void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте |
||
2739 | leency | 787 | { |
788 | scroll1.max_area = lines.all; |
||
2811 | leency | 789 | scroll1.cur_area = lines.visible; |
790 | scroll1.position = lines.first; |
||
791 | |||
2413 | leency | 792 | |
2739 | leency | 793 | scroll1.start_x=Form.width-28; //left + width - 15 |
794 | scroll1.size_y=WB1.height; |
||
795 | |||
2413 | leency | 796 | |
2739 | leency | 797 | }>=0)>>>>>>16><16>>=>=>>=72)>>>>>>>>>>!--> |
2413 | leency | 798 | >': |