Rev 5766 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5766 | Rev 5768 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | 4 | ||
Line 5... | Line 5... | ||
5 | struct _style { |
5 | struct _style { |
6 | byte |
6 | byte |
7 | b, i, u, s, |
7 | b, i, u, s, h, |
8 | pre, |
8 | pre, |
9 | blq, |
9 | blq, |
10 | li, |
10 | li, |
11 | li_tab, |
11 | li_tab, |
12 | align; |
12 | align; |
13 | }; |
13 | }; |
Line 14... | Line 14... | ||
14 | 14 | ||
15 | struct TWebBrowser { |
15 | struct TWebBrowser { |
16 | llist list; |
16 | llist list; |
17 | _style style; |
- | |
18 | dword draw_line_width; |
17 | _style style; |
19 | DrawBufer DrawBuf; |
18 | DrawBufer DrawBuf; |
20 | void Prepare(); |
19 | void Prepare(); |
21 | void SetStyle(); |
20 | void SetStyle(); |
22 | void DrawStyle(); |
21 | void DrawStyle(); |
Line 57... | Line 56... | ||
57 | char line[500]; |
56 | char line[500]; |
58 | char tagparam[10000]; |
57 | char tagparam[10000]; |
59 | char tag[100]; |
58 | char tag[100]; |
60 | char attr[1200]; |
59 | char oldtag[100]; |
61 | char val[4096]; |
60 | char attr[1200]; |
- | 61 | char val[4096]; |
|
62 | char anchor[256]; |
62 | char anchor[256]=0; |
63 | 63 | ||
64 | #include "..\TWB\history.h" |
64 | #include "..\TWB\history.h" |
Line 65... | Line 65... | ||
65 | #include "..\TWB\links.h" |
65 | #include "..\TWB\links.h" |
66 | #include "..\TWB\colors.h" |
66 | #include "..\TWB\colors.h" |
67 | #include "..\TWB\unicode_tags.h" |
67 | #include "..\TWB\unicode_tags.h" |
68 | #include "..\TWB\img_cache.h" |
68 | #include "..\TWB\img_cache.h" |
Line 89... | Line 89... | ||
89 | { |
89 | { |
90 | start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x; |
90 | start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x; |
91 | start_y = stroka * list.line_h + body_magrin; |
91 | start_y = stroka * list.line_h + body_magrin; |
92 | stolbec_len = utf8_strlen(#line); |
92 | stolbec_len = utf8_strlen(#line) * DrawBuf.zoom; |
93 | line_length = stolbec_len * list.font_w * DrawBuf.zoom; |
93 | line_length = stolbec_len * list.font_w; |
94 | 94 | ||
Line -... | Line 95... | ||
- | 95 | if (style.h) stroka++; |
|
95 | WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
96 | WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
96 | if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
97 | if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
97 | if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.line_h); } // bug with zoom>1 |
98 | if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.line_h); } // bug with zoom>1 |
98 | if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
99 | if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
99 | if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
100 | if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
Line 120... | Line 121... | ||
120 | dword bufpos = bufpointer; |
121 | dword bufpos = bufpointer; |
121 | int line_len; |
122 | int line_len; |
122 | 123 | ||
123 | style.b = style.i = style.u = style.s = style.blq = t_html = t_body = |
124 | style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body = |
Line 124... | Line 125... | ||
124 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
125 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
125 | style.align = ALIGN_LEFT; |
126 | style.align = ALIGN_LEFT; |
126 | link_color_inactive = 0x0000FF; |
127 | link_color_inactive = 0x0000FF; |
127 | link_color_active = 0xFF0000; |
128 | link_color_active = 0xFF0000; |
128 | bg_color = 0xFFFFFF; |
129 | bg_color = 0xFFFFFF; |
129 | DrawBuf.Fill(bg_color); |
130 | DrawBuf.Fill(bg_color); |
Line 133... | Line 134... | ||
133 | stolbec = 0; |
134 | stolbec = 0; |
134 | line = 0; |
135 | line = 0; |
135 | 136 | ||
136 | draw_line_width = list.w * DrawBuf.zoom; |
137 | //for plaint text use CP866 for other UTF |
Line 137... | Line -... | ||
137 | - | ||
138 | //for plaint text use CP866 for other UTF |
- | |
139 | if (strstri(bufpointer, "html")) |
138 | if (strstri(bufpointer, "html")) |
140 | { |
139 | { |
141 | style.pre = 0; |
140 | style.pre = 0; |
142 | cur_encoding = CH_CP866; |
141 | cur_encoding = CH_CP866; |
143 | //WB1.list.SetFont(8, 14, 10111000b); |
142 | } |
144 | //list.line_h = list.font_h + 4; |
- | |
145 | } |
- | |
146 | else |
143 | else |
147 | { |
144 | { |
148 | style.pre = 1; |
145 | style.pre = 1; |
149 | cur_encoding = CH_UTF8; |
146 | cur_encoding = CH_UTF8; |
150 | //WB1.list.SetFont(8, 14, 10001000b); |
147 | } |
151 | //list.line_h = list.font_h + 4; |
- | |
152 | } |
- | |
153 | 148 | ||
Line 154... | Line 149... | ||
154 | for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;) |
149 | for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;) |
155 | { |
150 | { |
156 | bukva = ESBYTE[bufpos]; |
151 | bukva = ESBYTE[bufpos]; |
Line 187... | Line 182... | ||
187 | break; |
182 | break; |
188 | case '<': |
183 | case '<': |
189 | bufpos++; |
184 | bufpos++; |
190 | tag = attr = tagparam = ignor_param = NULL; |
185 | if (!strncmp(bufpos,"!--",3)) |
191 | if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî |
186 | { |
192 | { |
- | |
193 | bufpos++; |
- | |
194 | if (ESBYTE[bufpos] == '-') |
- | |
195 | { |
- | |
196 | HH_: |
187 | if (!strncmp(bufpos,"-->",3)) || (bufpointer + bufsize <= bufpos) break; |
197 | do |
- | |
198 | { |
- | |
199 | bufpos++; |
- | |
200 | if (bufpointer + bufsize <= bufpos) break 2; |
188 | bufpos++; |
- | 189 | } |
|
201 | } |
190 | tag = attr = tagparam = ignor_param = NULL; |
202 | while (ESBYTE[bufpos] <>'-'); |
- | |
203 | - | ||
204 | bufpos++; |
- | |
205 | if (ESBYTE[bufpos] <>'-') goto HH_; |
- | |
206 | } |
- | |
207 | } |
- | |
208 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
- | |
209 | { |
191 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
- | 192 | { |
|
210 | bukva = ESBYTE[bufpos]; |
193 | bukva = ESBYTE[bufpos]; |
211 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
194 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
212 | if (!ignor_param) && (bukva <>' ') |
195 | if (!ignor_param) && (bukva <>' ') |
213 | { |
196 | { |
214 | if (strlen(#tag) |
197 | if (strlen(#tag) |
Line 225... | Line 208... | ||
225 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
208 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
Line 226... | Line 209... | ||
226 | if (tagparam) GetNextParam(); |
209 | if (tagparam) GetNextParam(); |
227 | 210 | ||
Line 228... | Line 211... | ||
228 | if (stolbec + utf8_strlen(#line) > list.column_max) Perenos(); |
211 | Perenos(); |
229 | DrawStyle(); |
212 | DrawStyle(); |
230 | line = NULL; |
213 | line = NULL; |
231 | if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ |
214 | if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ |
- | 215 | strcpy(#oldtag, #tag); |
|
232 | tag = attr = tagparam = ignor_param = NULL; |
216 | tag = attr = tagparam = ignor_param = NULL; |
233 | break; |
217 | break; |
234 | default: |
218 | default: |
235 | DEFAULT_MARK: |
219 | DEFAULT_MARK: |
236 | if (bukva<=15) bukva=' '; |
220 | if (bukva<=15) bukva=' '; |
Line 241... | Line 225... | ||
241 | if (!stolbec) && (!line) break; //no paces at the beginning of the line |
225 | if (!stolbec) && (!line) break; //no paces at the beginning of the line |
242 | } |
226 | } |
243 | if (line_len < sizeof(line)) chrcat(#line, bukva); |
227 | if (line_len < sizeof(line)) chrcat(#line, bukva); |
244 | if (stolbec + line_len > list.column_max) Perenos(); |
228 | Perenos(); |
245 | } |
229 | } |
246 | } |
230 | } |
247 | DrawStyle(); |
231 | DrawStyle(); |
248 | NewLine(); |
232 | NewLine(); |
249 | DrawPage(); |
233 | DrawPage(); |
250 | if (list.first == 0) list.count = stroka; |
234 | if (list.first == 0) list.count = stroka; |
251 | if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
235 | if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
Line 260... | Line 244... | ||
260 | { |
244 | { |
261 | int perenos_num; |
245 | int perenos_num; |
262 | char new_line_text[4096]; |
246 | char new_line_text[4096]; |
263 | perenos_num = strrchr(#line, ' '); |
247 | if (stolbec + utf8_strlen(#line) < list.column_max) return; |
264 | if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max; |
248 | perenos_num = strrchr(#line, ' '); |
- | 249 | if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max; |
|
265 | strcpy(#new_line_text, #line + perenos_num); |
250 | strcpy(#new_line_text, #line + perenos_num); |
266 | line[perenos_num] = 0x00; |
251 | line[perenos_num] = 0x00; |
267 | DrawStyle(); |
252 | DrawStyle(); |
268 | strcpy(#line, #new_line_text); |
253 | strcpy(#line, #new_line_text); |
269 | NewLine(); |
254 | NewLine(); |
270 | } |
255 | } |
271 | //============================================================================================ |
256 | //============================================================================================ |
272 | char oldtag[100]; |
257 | void TWebBrowser::SetStyle(int left1, top1) { |
273 | void TWebBrowser::SetStyle(int left1, top1) { |
258 | dword hr_color; |
274 | dword hr_color; |
- | |
275 | byte opened; |
259 | byte opened; |
276 | byte meta_encoding; |
260 | byte meta_encoding; |
277 | //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ |
261 | //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ |
278 | if (tag[0] == '/') |
262 | if (tag[0] == '/') |
279 | { |
263 | { |
Line 386... | Line 370... | ||
386 | if (istag("blockquote")) { style.blq = opened; return; } |
370 | if (istag("blockquote")) { style.blq = opened; return; } |
387 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
371 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
388 | if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; } |
372 | if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; } |
389 | /* |
373 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) { |
390 | if (istag("center")) |
374 | style.h = opened; |
391 | { |
- | |
392 | if (opened) style.align = ALIGN_CENTER; |
- | |
393 | if (!opened) |
- | |
394 | { |
- | |
395 | NewLine(); |
- | |
396 | style.align = ALIGN_LEFT; |
- | |
397 | } |
- | |
398 | return; |
- | |
399 | } |
- | |
400 | if (istag("right")) |
- | |
401 | { |
- | |
402 | if (opened) style.align = ALIGN_RIGHT; |
- | |
403 | if (!opened) |
- | |
404 | { |
- | |
405 | NewLine(); |
- | |
406 | style.align = ALIGN_LEFT; |
- | |
407 | } |
- | |
408 | return; |
- | |
409 | } |
- | |
410 | */ |
- | |
411 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) { |
- | |
412 | NewLine(); |
- | |
413 | if (opened) && (stroka>1) NewLine(); |
375 | NewLine(); |
- | 376 | if (opened) |
|
414 | strcpy(#oldtag, #tag); |
377 | { |
415 | if (opened) |
- | |
416 | { |
- | |
417 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
378 | WB1.DrawBuf.zoom=2; |
418 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
379 | WB1.list.SetFont(8, 14, 10111001b); |
- | 380 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
|
- | 381 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
|
419 | style.b = 1; |
382 | if (stroka>1) NewLine(); |
420 | } |
383 | } |
421 | if (!opened) |
384 | else |
422 | { |
385 | { |
423 | style.align = ALIGN_LEFT; |
386 | WB1.DrawBuf.zoom=1; |
424 | style.b = 0; |
387 | WB1.list.SetFont(8, 14, 10111000b); |
- | 388 | style.align = ALIGN_LEFT; |
|
- | 389 | } |
|
425 | } |
390 | return; |
426 | return; |
- | |
427 | } |
391 | } |
428 | else |
392 | if (istag("dt")) { |
429 | oldtag=NULL; |
393 | style.li = opened; |
430 | if (istag("dt")) { |
- | |
431 | style.li = opened; |
- | |
432 | if (opened) NewLine(); |
394 | if (opened) NewLine(); |
433 | return; |
395 | return; |
434 | } |
396 | } |
435 | if (istag("li")) || (istag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè |
397 | if (istag("li")) || (istag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè |
436 | { |
398 | { |