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