Rev 7462 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6003 | leency | 1 | enum { |
2 | COUNT_BUF_HEIGHT, |
||
3 | DRAW_BUF |
||
4 | }; |
||
5 | |||
7525 | leency | 6 | #define DRAW_PADDING 12 |
7 | |||
6003 | leency | 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; |
||
7525 | leency | 14 | dword stroka_y=DRAW_PADDING-3; |
6003 | leency | 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]; |
||
7286 | leency | 22 | line_length += kfont_char_width[ch]; |
5980 | leency | 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); |
||
7525 | leency | 39 | kfont.WriteIntoBuffer(DRAW_PADDING,stroka_y,list.w,kfont.size.height, bg_color, text_color, 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; |
7525 | leency | 47 | if (mode==DRAW_BUF) kfont.WriteIntoBuffer(DRAW_PADDING,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, line_start); |
6003 | leency | 48 | } |
49 | |||
50 | void PreparePage() |
||
51 | { |
||
52 | list.w = Form.cwidth-scroll.size_x-1; |
||
53 | list.count=0; |
||
54 | Parcer(COUNT_BUF_HEIGHT); |
||
55 | |||
5980 | leency | 56 | //draw text in buffer |
7525 | leency | 57 | list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+6); |
5980 | leency | 58 | if (list.count < list.visible) list.count = list.visible; |
6806 | leency | 59 | kfont.size.height = list.count+1*list.item_h; |
60 | kfont.raw_size = 0; |
||
6003 | leency | 61 | Parcer(DRAW_BUF); |
5980 | leency | 62 | |
6808 | leency | 63 | if (list.count > list.visible * 10) DrawPage(); |
6003 | leency | 64 | //draw result |
6806 | leency | 65 | kfont.ApplySmooth(); |
5980 | leency | 66 | DrawPage(); |
67 | }> |