Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6003 | leency | 1 | char char_width[255]; |
2 | |||
3 | enum { |
||
4 | COUNT_BUF_HEIGHT, |
||
5 | DRAW_BUF |
||
6 | }; |
||
7 | |||
8 | void Parcer(byte mode) |
||
5980 | leency | 9 | { |
6003 | leency | 10 | dword bufoff, buflen; |
11 | byte ch; |
||
12 | char line[4096]=0; |
||
13 | int srch_pos; |
||
14 | dword stroka_y=5; |
||
15 | dword line_length=30; |
||
16 | dword line_start=io.buffer_data; |
||
5995 | leency | 17 | |
18 | buflen = strlen(io.buffer_data) + io.buffer_data; |
||
19 | for (bufoff=io.buffer_data; bufoff |
||
5980 | leency | 20 | { |
21 | ch = ESBYTE[bufoff]; |
||
22 | line_length += char_width[ch]; |
||
23 | if (line_length>=list.w) || (ch==10) { |
||
24 | srch_pos = bufoff; |
||
25 | loop() |
||
26 | { |
||
27 | if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break |
||
28 | if (srch_pos == line_start) break; //no white space found in whole line |
||
29 | srch_pos--; |
||
30 | } |
||
6003 | leency | 31 | if (mode==COUNT_BUF_HEIGHT) { |
32 | line_start = bufoff; |
||
33 | line_length = 30; |
||
34 | list.count++; |
||
35 | } |
||
36 | if (mode==DRAW_BUF) { |
||
37 | EBX = bufoff-line_start; |
||
38 | strlcpy(#line, line_start, EBX); |
||
6806 | leency | 39 | kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, 0xFFFFFF, 0, kfont.size.pt, #line); |
6003 | leency | 40 | stroka_y += list.item_h; |
41 | line_start = bufoff; |
||
42 | line_length = 30; |
||
43 | } |
||
5980 | leency | 44 | } |
45 | } |
||
6753 | leency | 46 | if (mode==COUNT_BUF_HEIGHT) list.count+=2; |
6806 | leency | 47 | if (mode==DRAW_BUF) kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, 0xFFFFFF, 0, kfont.size.pt, line_start); |
6003 | leency | 48 | } |
49 | |||
50 | void PreparePage() |
||
51 | { |
||
52 | //get font chars width, need to increase performance |
||
53 | int i; |
||
6806 | leency | 54 | kfont.changeSIZE(); |
55 | for (i=0; i<256; i++) char_width[i] = kfont.symbol_size(i); |
||
6003 | leency | 56 | |
57 | //get font buffer height |
||
58 | list.w = Form.cwidth-scroll.size_x-1; |
||
59 | list.count=0; |
||
60 | Parcer(COUNT_BUF_HEIGHT); |
||
61 | |||
5980 | leency | 62 | //draw text in buffer |
6806 | leency | 63 | list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+4); |
5980 | leency | 64 | if (list.count < list.visible) list.count = list.visible; |
6806 | leency | 65 | kfont.size.height = list.count+1*list.item_h; |
66 | kfont.raw_size = 0; |
||
6003 | leency | 67 | Parcer(DRAW_BUF); |
5980 | leency | 68 | |
6808 | leency | 69 | if (list.count > list.visible * 10) DrawPage(); |
6003 | leency | 70 | //draw result |
6806 | leency | 71 | kfont.ApplySmooth(); |
5980 | leency | 72 | DrawPage(); |
73 | }>256;> |