Rev 7798 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7798 | Rev 7818 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | void ParseAndPaint() |
|
1 | enum { |
2 | { |
- | 3 | dword start_time = GetStartTime(); |
|
2 | COUNT_BUF_HEIGHT, |
4 | search.clear(); |
- | 5 | Parse(); |
|
3 | DRAW_BUF |
6 | Paint(); |
- | 7 | debugln("\nTextRead statistics in miliseconds..."); |
|
- | 8 | debugval("Page generate time", GetStartTime() - start_time); |
|
- | 9 | if (list.count > list.visible * 10) DrawPage(); |
|
- | 10 | start_time = GetStartTime(); |
|
- | 11 | kfont.ApplySmooth(); |
|
- | 12 | debugval("Smooth", GetStartTime() - start_time); |
|
- | 13 | DrawPage(); |
|
4 | }; |
14 | } |
- | 15 | ||
Line 5... | Line 16... | ||
5 | 16 | ||
Line 6... | Line 17... | ||
6 | #define DRAW_PADDING 12 |
17 | #define DRAW_PADDING 12 |
7 | 18 | ||
8 | void Parse(byte mode) |
19 | void Parse() |
9 | { |
20 | { |
10 | dword bufoff, buflen; |
21 | dword bufoff, buflen; |
11 | byte ch; |
22 | byte ch; |
12 | char line[4096]=0; |
23 | char line[4096]=0; |
13 | int srch_pos; |
24 | int srch_pos; |
14 | dword stroka_y=DRAW_PADDING-3; |
25 | dword stroka_y=DRAW_PADDING-3; |
Line -... | Line 26... | ||
- | 26 | dword line_length=30; |
|
15 | dword line_length=30; |
27 | dword line_start=io.buffer_data; |
16 | dword line_start=io.buffer_data; |
28 | |
17 | 29 | list.count=0; |
|
18 | buflen = strlen(io.buffer_data) + io.buffer_data; |
30 | buflen = strlen(io.buffer_data) + io.buffer_data; |
19 | for (bufoff=io.buffer_data; bufoff |
31 | for (bufoff=io.buffer_data; bufoff |
Line 26... | Line 38... | ||
26 | { |
38 | { |
27 | if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break |
39 | 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 |
40 | if (srch_pos == line_start) break; //no white space found in whole line |
29 | srch_pos--; |
41 | srch_pos--; |
30 | } |
42 | } |
31 | if (mode==COUNT_BUF_HEIGHT) { |
- | |
32 | line_start = bufoff; |
- | |
33 | line_length = 30; |
- | |
34 | list.count++; |
43 | list.count++; |
35 | } |
- | |
36 | if (mode==DRAW_BUF) { |
- | |
37 | strlcpy(#line, line_start, bufoff-line_start); |
44 | strlcpy(#line, line_start, bufoff-line_start); |
38 | kfont.WriteIntoBuffer(DRAW_PADDING,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, #line); |
45 | search.add(stroka_y, #line); |
39 | stroka_y += list.item_h; |
46 | stroka_y += list.item_h; |
40 | line_start = bufoff; |
47 | line_start = bufoff; |
41 | line_length = 30; |
48 | line_length = 30; |
42 | } |
49 | } |
43 | } |
50 | } |
44 | } |
- | |
45 | if (mode==COUNT_BUF_HEIGHT) list.count+=2; |
- | |
46 | if (mode==DRAW_BUF) kfont.WriteIntoBuffer(DRAW_PADDING,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, line_start); |
- | |
47 | } |
- | |
48 | - | ||
49 | void PreparePage() |
- | |
50 | { |
- | |
51 | list.w = Form.cwidth-scroll.size_x-1; |
- | |
52 | list.count=0; |
51 | list.count+=2; |
53 | Parse(COUNT_BUF_HEIGHT); |
- | |
54 | - | ||
55 | //draw text in buffer |
- | |
56 | list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+8); |
52 | list.visible = list.h / list.item_h; |
57 | if (list.count < list.visible) list.count = list.visible; |
53 | if (list.count < list.visible) list.count = list.visible; |
58 | kfont.size.height = list.count+1*list.item_h; |
54 | kfont.size.height = list.count+1*list.item_h; |
59 | kfont.raw_size = 0; |
55 | kfont.raw_size = 0; |
60 | Parse(DRAW_BUF); |
56 | search.add(stroka_y, line_start); |
- | 57 | } |
|
Line -... | Line 58... | ||
- | 58 | ||
- | 59 | void Paint() |
|
- | 60 | { |
|
- | 61 | int i; |
|
- | 62 | int cur_pos; |
|
61 | 63 | dword cur_line; |
|
- | 64 | for ( i=0; i < search.lines.count; i++) |
|
- | 65 | { |
|
- | 66 | cur_pos = atoi(search.pos.get(i)); |
|
- | 67 | cur_line = search.lines.get(i); |
|
- | 68 | kfont.WriteIntoBuffer(DRAW_PADDING, cur_pos, list.w, |
|
- | 69 | kfont.size.height, bg_color, text_color, kfont.size.pt, cur_line); |
|
- | 70 | } |
|
- | 71 | } |
|
- | 72 | ||
- | 73 | :void PaintVisible() |
|
- | 74 | { |
|
62 | if (list.count > list.visible * 10) DrawPage(); |
75 | int i; |
- | 76 | dword cur_pos; |
|
- | 77 | dword cur_line; |
|
- | 78 | for ( i=0; i < list.visible; i++) |
|
- | 79 | { |
|
- | 80 | cur_pos = atoi(search.pos.get(i + list.first)); |
|
- | 81 | cur_line = search.lines.get(i + list.first); |
|
- | 82 | kfont.WriteIntoBuffer(DRAW_PADDING, cur_pos, list.w, |
|
- | 83 | kfont.size.height, bg_color, text_color, kfont.size.pt, cur_line); |
|
63 | //draw result |
84 | } |
64 | kfont.ApplySmooth(); |
- | |
65 | DrawPage(); |
85 | kfont.ApplySmooth(); |