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