Rev 6058 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6043 | leency | 1 | |
2 | { |
||
3 | list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, label.size.pt+2); |
||
6053 | leency | 4 | strcpy(#title, history.current()+strrchr(history.current(),'/')); |
5 | //get font chars width, need to increase performance |
||
6043 | leency | 6 | get_label_symbols_size(); |
6053 | leency | 7 | ChangeCharset(charsets[encoding], "CP866", io.buffer_data); |
8 | link.clear(); |
||
6058 | leency | 9 | if (strstri(io.buffer_data, " |
6053 | leency | 10 | debugln("no found"); |
6043 | leency | 11 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT); ParceTxt(false); //get page height to calculate buffer size |
6053 | leency | 12 | DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceTxt(true); //draw text in buffer |
13 | } else { |
||
14 | debugln(" tag found"); |
||
6043 | leency | 15 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT); ParceHtml(false); //get page height to calculate buffer size |
6053 | leency | 16 | DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceHtml(true); //draw text in buffer |
17 | } |
||
18 | strcat(#title, " - Aelia"); |
||
19 | DrawTitle(#title); |
||
20 | DrawProgress(STEP_4_SMOOTH_FONT); label.apply_smooth(); |
||
21 | DrawProgress(STEP_5_STOP); DrawPage(); |
||
22 | } |
||
6043 | leency | 23 | |
24 | |||
25 | { |
||
26 | byte ch, zeroch=0; |
||
27 | dword bufoff, buflen, line_start, srch_pos; |
||
28 | int stroka_y=5, line_length=0; |
||
29 | |||
30 | |||
31 | buflen = strlen(io.buffer_data) + io.buffer_data; |
||
32 | for (bufoff=io.buffer_data; bufoff |
||
33 | { |
||
34 | ch = ESBYTE[bufoff]; |
||
35 | line_length += char_width[ch]; |
||
36 | if (line_length>=list.w-30) || (ch==10) { |
||
37 | srch_pos = bufoff; |
||
38 | loop() |
||
39 | { |
||
40 | if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break |
||
41 | if (srch_pos == line_start) break; //no white space found in whole line |
||
42 | srch_pos--; |
||
43 | } |
||
44 | if (draw==true) { |
||
45 | ESBYTE[bufoff] >< zeroch; //set line end |
||
46 | WriteTextIntoBuf(8, stroka_y, 0x000000, line_start); |
||
6053 | leency | 47 | ESBYTE[bufoff] >< zeroch; //restore line |
6043 | leency | 48 | } |
49 | stroka_y += list.item_h; |
||
50 | line_start = bufoff; |
||
51 | line_length = 0; |
||
52 | } |
||
53 | } |
||
54 | if (draw==false) { |
||
55 | list.count = stroka_y/list.item_h+3; |
||
6059 | leency | 56 | if (list.count < list.visible) list.count = list.visible; |
6043 | leency | 57 | label.size.height = list.count+5*list.item_h; |
6059 | leency | 58 | label.raw_size = 0; |
6043 | leency | 59 | } |
60 | if (draw==true) WriteTextIntoBuf(8, stroka_y, 0x000000, line_start); |
||
6053 | leency | 61 | } |
6043 | leency | 62 | |
63 | |||
64 | |||
65 | = = |
||
66 | = HTML = |
||
67 | = = |
||
68 | ========================================================*/ |
||
69 | |||
70 | |||
6053 | leency | 71 | |
6043 | leency | 72 | |
73 | dword start; |
||
74 | dword end; |
||
75 | dword len; |
||
76 | }; |
||
77 | |||
78 | |||
79 | bool b, u, i, s; |
||
80 | bool h1, h2, h3, h4, h5, h6; |
||
81 | bool a; |
||
82 | bool pre; |
||
83 | bool ignore; |
||
6053 | leency | 84 | dword color; |
85 | void clear(); |
||
6058 | leency | 86 | } style; |
6043 | leency | 87 | |
88 | |||
6058 | leency | 89 | { |
90 | b=u=i=s=0; |
||
91 | h1=h2=h3=h4=h5=h6=0; |
||
92 | a=0; |
||
93 | pre=0; |
||
94 | ignore=0; |
||
95 | color=0; |
||
96 | } |
||
97 | |||
98 | |||
6053 | leency | 99 | dword start; |
100 | int x, y; |
||
101 | }; |
||
102 | |||
103 | |||
6043 | leency | 104 | dword start; |
105 | dword name; |
||
106 | dword param[10]; |
||
107 | dword value[10]; |
||
108 | void parce(); |
||
109 | int nameis(); |
||
6053 | leency | 110 | void clear(); |
6058 | leency | 111 | }; |
6043 | leency | 112 | |
113 | |||
114 | { |
||
115 | dword o = name = start; |
||
6053 | leency | 116 | while (ESBYTE[o]!=' ') && (ESBYTE[o]) o++; //searching for a space after tag name |
117 | ESBYTE[o] = '\0'; |
||
118 | strlwr(name); |
||
119 | } |
||
6043 | leency | 120 | |
121 | |||
6053 | leency | 122 | { |
6043 | leency | 123 | if (name) && (strcmp(_in_tag_name, name)==0) return true; |
6058 | leency | 124 | return false; |
6053 | leency | 125 | } |
6043 | leency | 126 | |
127 | |||
6058 | leency | 128 | { |
129 | start=name=0; |
||
130 | } |
||
131 | |||
132 | |||
6053 | leency | 133 | #define HTML_PADDING_Y 5; |
134 | |||
6043 | leency | 135 | |
6053 | leency | 136 | |
6043 | leency | 137 | { |
138 | int stroka_x = HTML_PADDING_X; |
||
6053 | leency | 139 | int stroka_y = HTML_PADDING_Y; |
140 | dword line_break; |
||
141 | byte ch, zeroch; |
||
142 | _DOM DOM; |
||
6043 | leency | 143 | _text text; |
144 | _tag tag; |
||
145 | dword DOM_pos; |
||
146 | |||
147 | |||
6058 | leency | 148 | style.clear(); |
149 | /* Create DOM */ |
||
6043 | leency | 150 | debugln("creating DOM"); |
6053 | leency | 151 | DOM.len = strlen(io.buffer_data); |
6043 | leency | 152 | DOM.start = malloc(DOM.len); |
153 | DOM.end = DOM.start + DOM.len; |
||
154 | strlcpy(DOM.start, io.buffer_data, DOM.len); |
||
155 | //RemoveSpecialSymbols(DOM.start, DOM.len); |
||
6058 | leency | 156 | //DOM.len = strlen(DOM.start); |
157 | |||
6043 | leency | 158 | |
159 | debugln("starting DOM parce..."); |
||
6053 | leency | 160 | text.start = DOM.start; |
6058 | leency | 161 | for (DOM_pos=DOM.start; DOM_pos |
6043 | leency | 162 | { |
163 | if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' '; |
||
6053 | leency | 164 | ch = ESBYTE[DOM_pos]; |
6043 | leency | 165 | if (ch=='<') { |
166 | ESBYTE[DOM_pos] = '\0'; |
||
6053 | leency | 167 | tag.start = DOM_pos + 1; |
6043 | leency | 168 | if (style.ignore) continue; |
6053 | leency | 169 | if (tag.nameis("title")) { |
170 | strcpy(#title, text.start); |
||
171 | continue; |
||
172 | } |
||
173 | strtrim(text.start); |
||
6059 | leency | 174 | while (get_label_len(text.start) + stroka_x + 30 > list.w) |
6053 | leency | 175 | { |
176 | zeroch = 0; |
||
177 | for (line_break=tag.start-1; line_break>text.start; line_break--;) |
||
178 | { |
||
179 | ESBYTE[line_break] >< zeroch; //set line end |
||
180 | if (get_label_len(text.start) + stroka_x + 30 <= list.w) break; |
||
181 | ESBYTE[line_break] >< zeroch; //restore line |
||
182 | } |
||
183 | if (draw==true) { |
||
184 | if (style.a) { |
||
6058 | leency | 185 | link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," "); |
186 | label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color); |
||
187 | } |
||
188 | WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start); |
||
6053 | leency | 189 | stroka_x+=char_width[' ']; |
6059 | leency | 190 | } |
6053 | leency | 191 | ESBYTE[line_break] >< zeroch; //restore line |
192 | text.start = line_break; |
||
193 | stroka_x = HTML_PADDING_X; |
||
194 | stroka_y += list.item_h; |
||
195 | } |
||
196 | if (draw==true) { |
||
197 | if (style.a) { |
||
6058 | leency | 198 | link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," "); |
199 | label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color); |
||
200 | } |
||
201 | WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start); |
||
6053 | leency | 202 | stroka_x+=char_width[' ']; |
6059 | leency | 203 | } |
6053 | leency | 204 | stroka_x += get_label_len(text.start); |
205 | } |
||
6043 | leency | 206 | if (ch=='>') { |
207 | ESBYTE[DOM_pos] = '\0'; |
||
6053 | leency | 208 | text.start = DOM_pos + 1; |
6043 | leency | 209 | tag.parce(); |
210 | if (tag.nameis("br")) |
||
6059 | leency | 211 | || (tag.nameis("p")) |
212 | || (tag.nameis("div")) |
||
213 | || (tag.nameis("tr")) { |
||
214 | stroka_y+= list.item_h; |
||
6053 | leency | 215 | stroka_x = HTML_PADDING_X; |
216 | continue; |
||
217 | } |
||
218 | if (tag.nameis("h1")) || (tag.nameis("/h1")) |
||
6059 | leency | 219 | || (tag.nameis("h2")) || (tag.nameis("/h2")) { |
220 | stroka_y+= list.item_h; |
||
221 | stroka_x = HTML_PADDING_X; |
||
222 | continue; |
||
223 | } |
||
224 | if (tag.nameis("script")) || (tag.nameis("style")) style.ignore = true; |
||
6053 | leency | 225 | if (tag.nameis("/script")) || (tag.nameis("/style")) style.ignore = false; |
226 | if (tag.nameis("a")) { style.a = true; style.color=0x0000FF; } |
||
227 | if (tag.nameis("/a")) { style.a = false; style.color=0x000000; } |
||
228 | } |
||
6043 | leency | 229 | } |
230 | if (draw==false) { |
||
6053 | leency | 231 | list.count = stroka_y/list.item_h+3; |
6059 | leency | 232 | if (list.count < list.visible) list.count = list.visible; |
6053 | leency | 233 | label.size.height = list.count+5*list.item_h; |
6059 | leency | 234 | label.raw_size = 0; |
6053 | leency | 235 | } |
236 | free(DOM.start); |
||
6043 | leency | 237 | }>>>=>>')>>>> |
238 |