Rev 2825 | 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.94u"; |
||
2839 | 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 | |||
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[1000]; |
||
49 | |||
50 | |||
51 | |||
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+strrchr(#URL, '#')); |
||
2839 | 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 (strrchr(#URL, '#')<>-1) |
2839 | leency | 77 | { |
2793 | leency | 78 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
2839 | leency | 79 | URL[strrchr(#URL, '#')-1] = 0x00; //заглушка |
80 | } |
||
2793 | leency | 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 | |||
2839 | leency | 200 | { |
2413 | leency | 201 | editURL[strrchr(#editURL, '/')] = 0x00; //обрезаем её урл до последнего / |
2839 | leency | 202 | } |
2413 | leency | 203 | |
2428 | leency | 204 | |
205 | { |
||
206 | strcpy(#URL,#URL+3); |
||
2810 | leency | 207 | editURL[strrchr(#editURL, '/')-1] = 0x00; //обрезаем её урл до последнего / |
2839 | leency | 208 | goto _CUT_ST_LEVEL_MARK; |
2428 | leency | 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 | |
2839 | leency | 321 | |
2818 | leency | 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 = strrchr(#line, ' '); |
2839 | leency | 439 | strcpy(#temp, #line + perenos_num); //перенос по словам |
2818 | leency | 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 | |
2825 | leency | 465 | |
2839 | leency | 466 | DrawScroller(); //рисуем скролл |
2413 | leency | 467 | } |
468 | |||
469 | |||
470 | |||
471 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
||
472 | dword hr_color; |
||
473 | |||
474 | |||
2825 | leency | 475 | char temp[4096]; |
2413 | leency | 476 | int w, h, img_lines_first, line_length; |
2825 | 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 | line_length=strlen(#line)*6; |
||
2825 | leency | 516 | WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //может тут рисовать белую строку? |
2444 | leency | 517 | //line_length = get_length stdcall (#line,-1,16,line_length); |
2825 | leency | 518 | //text_out stdcall (#line, -1, 17, text_colors[text_color_index], stolbec * 6 + left1, top1-2); |
519 | IF (b_text) { $add ebx, 1<<16 $int 0x40 } |
||
2696 | leency | 520 | IF (i_text) Skew(stolbec * 6 + left1, top1, line_length+6, 10); //наклонный текст |
2825 | leency | 521 | IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, line_length, 1, text_colors[text_color_index]); //зачёркнутый |
522 | IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, line_length, 1, text_colors[text_color_index]); //подчёркнутый |
||
523 | IF (link) { |
||
2413 | leency | 524 | DefineButton(stolbec * 6 + left1 - 2, top1, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); // |
2825 | leency | 525 | DrawBar(stolbec * 6 + left1, top1 + 8, line_length, 1, text_colors[text_color_index]); |
526 | } |
||
2413 | leency | 527 | } |
528 | |||
2823 | leency | 529 | |
2413 | leency | 530 | stolbec += strlen(#line); |
531 | |||
2420 | leency | 532 | |
2793 | leency | 533 | { |
534 | if (!strcmp(#anchor, #options)) |
||
535 | { |
||
536 | anchor_line_num=lines.first+stroka; |
||
2811 | leency | 537 | } |
2793 | leency | 538 | } |
539 | |||
540 | |||
2413 | leency | 541 | { |
542 | BODY_MARK: |
||
543 | |||
544 | |||
2823 | leency | 545 | link_color = GetColor(#options); |
2413 | leency | 546 | |
547 | |||
2823 | leency | 548 | text_colors[0]=GetColor(#options); |
2413 | leency | 549 | |
550 | |||
2823 | leency | 551 | bg_color=GetColor(#options); |
2420 | leency | 552 | |
2413 | leency | 553 | |
2823 | leency | 554 | { |
555 | GetNextParam(); |
||
2413 | leency | 556 | GOTO BODY_MARK; |
557 | } |
||
2420 | leency | 558 | |
559 | |||
560 | } |
||
2413 | leency | 561 | ////////////////////////// |
562 | if (!chTag("a")) |
||
2793 | leency | 563 | { |
564 | if (rez) |
||
565 | { |
||
566 | text_color_index++; |
||
2839 | leency | 567 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
568 | |||
569 | |||
2793 | leency | 570 | if (!strcmp(#parametr, "href=")) |
571 | { |
||
572 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
||
2811 | leency | 573 | if (link) && (text_color_index > 0) text_color_index--; //если не закрыт тэг |
2839 | leency | 574 | link = 1; |
2413 | leency | 575 | blink++; |
576 | text_colors[text_color_index] = link_color; |
||
577 | strcat(#page_links, #options); |
||
2810 | leency | 578 | strcat(#page_links, "|"); |
579 | } |
||
2413 | leency | 580 | if (anchor) && (!strcmp(#parametr, "name=")) |
2793 | leency | 581 | { |
582 | if (!strcmp(#anchor, #options)) |
||
583 | { |
||
584 | anchor_line_num=lines.first+stroka; |
||
2811 | leency | 585 | } |
2793 | leency | 586 | } |
587 | if (tagparam) |
||
588 | { |
||
589 | GetNextParam(); |
||
2413 | leency | 590 | GOTO _A_MARK; |
2793 | leency | 591 | } |
2413 | leency | 592 | } |
593 | ELSE { |
||
594 | link = 0; |
||
595 | IF(text_color_index > 0) text_color_index--; |
||
596 | } |
||
597 | return; |
||
598 | } |
||
599 | ///////////////////////// |
||
600 | if (!chTag("font")) |
||
601 | { |
||
602 | if (rez) |
||
2839 | leency | 603 | { |
2413 | leency | 604 | text_color_index++; |
605 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
2839 | leency | 606 | |
607 | |||
608 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
||
609 | { |
||
610 | text_colors[text_color_index] = GetColor(#options); |
||
611 | } |
||
612 | IF(tagparam) { |
||
613 | GetNextParam(); |
||
614 | GOTO COL_MARK; |
||
615 | } |
||
616 | } |
||
2413 | leency | 617 | else |
2839 | leency | 618 | if (text_color_index > 0) text_color_index--; |
619 | return; |
||
2413 | leency | 620 | } |
621 | ////////////////////////// |
||
622 | if(!chTag("tr")) || (!chTag("br")) { |
||
2810 | leency | 623 | TextGoDown(left1, top1, width1); |
2413 | leency | 624 | return; |
625 | } |
||
626 | if (!chTag("div")) { |
||
2810 | leency | 627 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
2413 | leency | 628 | return; |
629 | } |
||
630 | if (!chTag("p")) { |
||
2810 | leency | 631 | IF(oldtag[0] == 'h') return; |
2413 | leency | 632 | TextGoDown(left1, top1, width1); |
633 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
||
634 | return; |
||
635 | } |
||
636 | //////////////////////////// |
||
637 | if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { |
||
2810 | leency | 638 | TextGoDown(left1, top1, width1); |
2413 | leency | 639 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
640 | b_text = rez; |
||
641 | strcpy(#oldtag, #tag); |
||
2810 | leency | 642 | return; |
2413 | leency | 643 | } |
2810 | leency | 644 | else |
645 | oldtag=''; |
||
646 | |||
647 | |||
648 | b_text = rez; |
||
2413 | leency | 649 | return; |
650 | } |
||
651 | //////////////////////////// |
||
652 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
||
2810 | leency | 653 | i_text = rez; |
2413 | leency | 654 | return; |
655 | } |
||
656 | //////////////////////////// |
||
657 | if (!chTag("dt")) |
||
2696 | leency | 658 | { |
2413 | leency | 659 | li_text = rez; |
660 | IF(rez == 0) return; |
||
661 | TextGoDown(left1, top1, width1); |
||
662 | return; |
||
663 | } |
||
664 | ///////////////////////////// |
||
2696 | leency | 665 | if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки |
2823 | leency | 666 | { |
2696 | leency | 667 | li_text = rez; |
668 | IF(rez == 0) return; |
||
669 | TextGoDown(left1, top1, width1); |
||
670 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
||
2811 | leency | 671 | return; |
2696 | leency | 672 | } |
673 | //////////////////////////// |
||
2413 | leency | 674 | IF(!chTag("u")) || (!chTag("ins")) u_text = rez; |
675 | IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
||
676 | IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) { |
||
677 | li_text = rez; |
||
678 | li_tab--; |
||
679 | TextGoDown(left1, top1, width1); |
||
680 | } ELSE li_tab++; |
||
681 | IF(!chTag("dd")) stolbec += 5; |
||
682 | IF(!chTag("blockquote")) blq_text = rez; |
||
683 | IF(!chTag("pre")) pre_text = rez; |
||
684 | IF(!chTag("hr")) { |
||
685 | TextGoDown(left1, top1, width1); |
||
686 | TextGoDown(left1, top1 + 10, width1); |
||
687 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
||
688 | ELSE hr_color = 0x999999; |
||
689 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
||
690 | } |
||
691 | |||
692 | |||
693 | { |
||
694 | //if (GetFileInfo(#libimg)<>0) return; //если библиотеки нет |
||
2823 | leency | 695 | IMG_TAG: |
2413 | leency | 696 | if (!strcmp(#parametr,"src=")) //надо объединить с GetNewUrl() |
2823 | leency | 697 | { |
698 | strcpy(#temp, BrowserHistory.CurrentUrl()); //достаём адрес текущей страницы |
||
2810 | leency | 699 | temp[strrchr(#temp, '/')] = 0x00; //обрезаем её урл до последнего / |
2839 | leency | 700 | strcat(#temp, #options); |
2810 | leency | 701 | image=load_image(#temp); |
2413 | leency | 702 | w=DSWORD[image+4]; |
2823 | leency | 703 | h=DSWORD[image+8]; |
704 | } |
||
705 | /*if (!strcmp(#parametr,"alt=")) |
||
2839 | leency | 706 | { |
2823 | leency | 707 | strcpy(#tag, "[Image: "); |
708 | strcat(#tag, #options); |
||
709 | strcat(#tag, "]"); |
||
710 | }*/ |
||
2839 | leency | 711 | |
2823 | leency | 712 | |
713 | { |
||
714 | GetNextParam(); |
||
2413 | leency | 715 | GOTO IMG_TAG; |
716 | } |
||
717 | |||
2823 | leency | 718 | |
719 | { |
||
720 | //debug(#tag); |
||
721 | return; |
||
722 | } |
||
723 | |||
2413 | leency | 724 | |
725 | |||
2823 | leency | 726 | |
727 | |||
2413 | leency | 728 | |
2823 | leency | 729 | |
730 | |||
731 | return; |
||
732 | |||
2413 | leency | 733 | |
2823 | leency | 734 | { |
735 | DrawBar(left, top, width-15, 10, bg_color); //закрашиваем первую строку |
||
736 | img_lines_first=WB1.top-top1; |
||
737 | h=h-img_lines_first; |
||
738 | top1=WB1.top; |
||
739 | } |
||
740 | |||
741 | |||
742 | { |
||
743 | h=WB1.top+WB1.height-top1-15; |
||
744 | } |
||
745 | |||
2413 | leency | 746 | |
2823 | leency | 747 | |
748 | |||
749 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
||
750 | IF (link) |
||
751 | { |
||
752 | DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
||
753 | } |
||
754 | |||
2433 | leency | 755 | |
2413 | leency | 756 | } |
757 | |||
758 | |||
2605 | leency | 759 | { |
2413 | leency | 760 | META: |
761 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
||
2605 | leency | 762 | { |
2413 | leency | 763 | strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content= |
2839 | leency | 764 | |
2413 | leency | 765 | |
2811 | leency | 766 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
767 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
||
768 | } |
||
2413 | leency | 769 | if (tagparam) |
2810 | leency | 770 | { |
2413 | leency | 771 | GetNextParam(); |
772 | goto META; |
||
773 | } |
||
774 | return; |
||
775 | } |
||
776 | } |
||
777 | |||
778 | |||
779 | |||
2739 | leency | 780 | { |
781 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
||
2818 | leency | 782 | { |
783 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //закрашиваем первую строку |
||
784 | first_line_drawed=1; |
||
785 | } |
||
786 | stroka++; |
||
2413 | leency | 787 | if (blq_text) stolbec = 8; |
2818 | leency | 788 | ELSE stolbec = 0; |
2413 | leency | 789 | if (li_text) stolbec = li_tab * 5; |
2818 | leency | 790 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
2811 | leency | 791 | } |
2413 | leency | 792 | |
793 | |||
794 | |||
795 | void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте |
||
2739 | leency | 796 | { |
797 | scroll1.max_area = lines.all; |
||
2811 | leency | 798 | scroll1.cur_area = lines.visible; |
799 | scroll1.position = lines.first; |
||
800 | |||
2413 | leency | 801 | |
2739 | leency | 802 | scroll1.start_x=Form.width-28; //left + width - 15 |
803 | scroll1.size_y=WB1.height; |
||
804 | |||
2413 | leency | 805 | |
2739 | leency | 806 | }>=0)>>>>>>16><16>>=>=>>=72)>>>>>>>>>>!--> |
2413 | leency | 807 | >': |