Rev 7738 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7738 | Rev 7742 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
Line 3... | Line 3... | ||
3 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
3 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | struct _style { |
5 | struct _style { |
6 | byte |
6 | bool |
7 | b, u, s, h, |
7 | b, u, s, h, |
8 | pre, |
8 | pre, |
9 | blq, |
9 | blq, |
10 | li, |
10 | li, |
- | 11 | li_tab, |
|
- | 12 | button, |
|
11 | li_tab, |
13 | image, |
12 | align; |
14 | align; |
Line 13... | Line 15... | ||
13 | }; |
15 | }; |
14 | 16 | ||
Line 28... | Line 30... | ||
28 | void BufEncode(); |
30 | void BufEncode(); |
29 | } WB1; |
31 | } WB1; |
30 | 32 | ||
Line 31... | Line 33... | ||
31 | 33 | ||
32 | byte |
34 | bool |
33 | link, |
35 | link, |
34 | ignor_text, |
36 | ignor_text, |
35 | cur_encoding, |
37 | cur_encoding, |
36 | t_html, |
38 | t_html, |
Line 89... | Line 91... | ||
89 | start_x = stolbec * list.font_w + body_magrin + list.x; |
91 | start_x = stolbec * list.font_w + body_magrin + list.x; |
90 | stolbec_len = strlen(#line) * zoom; |
92 | stolbec_len = strlen(#line) * zoom; |
91 | line_length = stolbec_len * list.font_w; |
93 | line_length = stolbec_len * list.font_w; |
92 | 94 | ||
Line -... | Line 95... | ||
- | 95 | if (style.image) { |
|
- | 96 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xF9DBCB); |
|
- | 97 | } |
|
- | 98 | if (style.button) { |
|
- | 99 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
|
- | 100 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
|
- | 101 | } |
|
- | 102 | ||
93 | DrawBuf.WriteText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line); |
103 | DrawBuf.WriteText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line); |
94 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
104 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
95 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
105 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
96 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
106 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
97 | if (link) { |
107 | if (link) { |
Line 237... | Line 247... | ||
237 | int perenos_num; |
247 | int perenos_num; |
238 | char new_line_text[4096]; |
248 | char new_line_text[4096]; |
239 | if (strlen(#line)*zoom + stolbec < list.column_max) return; |
249 | if (strlen(#line)*zoom + stolbec < list.column_max) return; |
240 | perenos_num = strrchr(#line, ' '); |
250 | perenos_num = strrchr(#line, ' '); |
241 | if (!perenos_num) && (strlen(#line)*zoom>list.column_max) perenos_num=list.column_max/zoom; |
251 | if (!perenos_num) && (strlen(#line)*zoom>list.column_max) { |
242 | strcpy(#new_line_text, #line + perenos_num); |
252 | perenos_num=list.column_max/zoom; |
- | 253 | if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt |
|
- | 254 | } |
|
- | 255 | strcpy(#new_line_text, #line + perenos_num); |
|
243 | line[perenos_num] = 0x00; |
256 | line[perenos_num] = 0x00; |
244 | DrawStyle(); |
257 | DrawStyle(); |
245 | strcpy(#line, #new_line_text); |
258 | strcpy(#line, #new_line_text); |
246 | NewLine(); |
259 | NewLine(); |
247 | } |
260 | } |
248 | //============================================================================================ |
261 | //============================================================================================ |
249 | void TWebBrowser::SetStyle() { |
262 | void TWebBrowser::SetStyle() { |
250 | int left1 = body_magrin + list.x; |
263 | char img_path[4096]; |
- | 264 | int left1 = body_magrin + list.x; |
|
251 | byte opened; |
265 | bool opened; |
252 | byte meta_encoding; |
266 | int meta_encoding; |
253 | if (tag[0] == '/') |
267 | if (tag[0] == '/') |
254 | { |
268 | { |
255 | opened = 0; |
269 | opened = 0; |
256 | strcpy(#tag, #tag+1); |
270 | strcpy(#tag, #tag+1); |
257 | } |
271 | } |
258 | else opened = 1; |
272 | else opened = 1; |
Line 289... | Line 303... | ||
289 | DrawBuf.Fill(0, bg_color); |
303 | DrawBuf.Fill(0, bg_color); |
290 | } |
304 | } |
291 | } while(GetNextParam()); |
305 | } while(GetNextParam()); |
292 | if (opened) && (cur_encoding==CH_NULL) { |
306 | if (opened) && (cur_encoding==CH_NULL) { |
293 | cur_encoding = CH_UTF8; |
307 | cur_encoding = CH_CP866; |
294 | debugln("Document has no information about encoding, UTF will be used"); |
308 | //BufEncode(CH_UTF8); |
- | 309 | debugln("Document has no information about encoding!"); |
|
295 | } |
310 | } |
296 | if (opened) { |
311 | if (opened) { |
297 | if (strcmp(#header, #version) != 0) { |
312 | if (strcmp(#header, #version) != 0) { |
298 | ChangeCharset(charsets[cur_encoding], "CP866", #header); |
313 | ChangeCharset(charsets[cur_encoding], "CP866", #header); |
299 | sprintf(#header, "%s - %s", #header, #version); |
314 | sprintf(#header, "%s - %s", #header, #version); |
300 | } |
315 | } |
Line 347... | Line 362... | ||
347 | } |
362 | } |
348 | if (istag("br")) { NewLine(); return; } |
363 | if (istag("br")) { NewLine(); return; } |
349 | if (istag("tr")) { if (opened) NewLine(); return; } |
364 | if (istag("tr")) { if (opened) NewLine(); return; } |
350 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
365 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
351 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
366 | if (istag("button")) { style.button = opened; stolbec++; return; } |
- | 367 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
|
352 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
368 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
353 | if (istag("dd")) { stolbec += 5; return; } |
369 | if (istag("dd")) { stolbec += 5; return; } |
354 | if (istag("blockquote")) { style.blq = opened; return; } |
370 | if (istag("blockquote")) { style.blq = opened; return; } |
355 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
371 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
356 | if (istag("img")) { ImgCache.Images( left1, draw_y, WB1.list.w); return; } |
372 | if (istag("img")) { |
- | 373 | do{ |
|
- | 374 | if (isattr("src=")) strcpy(#img_path, #val); |
|
- | 375 | if (isattr("alt=")) sprintf(#line, "[%s]", #val); |
|
- | 376 | } while(GetNextParam()); |
|
- | 377 | style.image = true; |
|
- | 378 | text_color_index++; |
|
- | 379 | text_colors[text_color_index] = 0x9A6F29; |
|
- | 380 | if (!line) { |
|
- | 381 | if (!strncmp(#img_path, "data:", 5)) img_path=0; |
|
- | 382 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
|
- | 383 | line[50]= NULL; |
|
- | 384 | } |
|
- | 385 | if (strlen(#line) + stolbec > list.column_max) Perenos(); |
|
- | 386 | DrawStyle(); |
|
- | 387 | line=0; |
|
- | 388 | text_color_index--; |
|
- | 389 | style.image = false; |
|
- | 390 | //ImgCache.Images( left1, draw_y, WB1.list.w); |
|
357 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) { |
391 | return; |
- | 392 | } |
|
- | 393 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) { |
|
358 | style.h = opened; |
394 | style.h = opened; |
359 | if (opened) |
395 | if (opened) |
360 | { |
396 | { |
361 | NewLine(); |
397 | NewLine(); |
362 | draw_y += 10; |
398 | draw_y += 10; |
Line 364... | Line 400... | ||
364 | WB1.list.font_type |= 10011001b; |
400 | WB1.list.font_type |= 10011001b; |
365 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
401 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
366 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
402 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
367 | list.item_h = basic_line_h * 2; |
403 | list.item_h = basic_line_h * 2; |
368 | } |
404 | if (istag("h1")) style.b = true; |
- | 405 | } |
|
369 | else |
406 | else |
370 | { |
407 | { |
371 | NewLine(); |
408 | if (istag("h1")) style.b = false; |
- | 409 | NewLine(); |
|
372 | WB1.zoom=1; |
410 | WB1.zoom=1; |
373 | WB1.list.font_type = 10011000b; |
411 | WB1.list.font_type = 10011000b; |
374 | style.align = ALIGN_LEFT; |
412 | style.align = ALIGN_LEFT; |
375 | list.item_h = basic_line_h; |
413 | list.item_h = basic_line_h; |
376 | } |
414 | } |
Line 386... | Line 424... | ||
386 | style.li = opened; |
424 | style.li = opened; |
387 | if (opened) |
425 | if (opened) |
388 | { |
426 | { |
389 | NewLine(); |
427 | NewLine(); |
390 | strcpy(#line, "\31 \0"); |
428 | strcpy(#line, "\31 "); |
391 | } |
429 | stolbec-=2; |
- | 430 | } |
|
392 | return; |
431 | return; |
393 | } |
432 | } |
394 | if (istag("ul")) || (istag("ol")) { |
433 | if (istag("ul")) || (istag("ol")) { |
395 | if (!opened) |
434 | if (!opened) |
396 | { |
435 | { |
Line 439... | Line 478... | ||
439 | else |
478 | else |
440 | { |
479 | { |
441 | strcpy(bufpointer, o_bufpointer); |
480 | strcpy(bufpointer, o_bufpointer); |
442 | } |
481 | } |
443 | debugval("cur_encoding ", cur_encoding); |
482 | //debugval("cur_encoding ", cur_encoding); |
444 | debugval("set_new_encoding", set_new_encoding); |
483 | //debugval("set_new_encoding", set_new_encoding); |
445 | cur_encoding = set_new_encoding; |
484 | cur_encoding = set_new_encoding; |
446 | bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); |
485 | bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); |
447 | } |
486 | } |
448 | //============================================================================================ |
487 | //============================================================================================ |
449 | void TWebBrowser::DrawScroller() |
488 | void TWebBrowser::DrawScroller() |
450 | { |
489 | { |
Line 460... | Line 499... | ||
460 | //============================================================================================ |
499 | //============================================================================================ |
461 | void TWebBrowser::NewLine() |
500 | void TWebBrowser::NewLine() |
462 | { |
501 | { |
463 | dword onleft, ontop; |
502 | dword onleft, ontop; |
464 | 503 | static int empty_line=0; |
|
- | 504 | ||
Line 465... | Line 505... | ||
465 | if (!stolbec) && (draw_y==body_magrin) return; |
505 | if (!stolbec) && (draw_y==body_magrin) return; |
Line -... | Line 506... | ||
- | 506 | ||
- | 507 | if (!stolbec) { |
|
- | 508 | if (empty_line<1) empty_line++; |
|
- | 509 | else return; |
|
- | 510 | } else { |
|
- | 511 | empty_line=0; |
|
- | 512 | } |
|
466 | 513 | ||
467 | onleft = list.x + body_magrin; |
514 | onleft = list.x + body_magrin; |
468 | ontop = draw_y + list.y; |
515 | ontop = draw_y + list.y; |
469 | if (t_html) && (!t_body) return; |
516 | if (t_html) && (!t_body) return; |
470 | draw_y += list.item_h; |
517 | draw_y += list.item_h; |