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