Rev 8572 | Rev 9263 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8572 | Rev 9103 | ||
---|---|---|---|
Line 47... | Line 47... | ||
47 | collection img_url; |
47 | collection img_url; |
48 | char header[150]; |
48 | char header[150]; |
49 | char linebuf[500]; |
49 | char linebuf[500]; |
50 | char redirect[URL_SIZE]; |
50 | char redirect[URL_SIZE]; |
Line -... | Line 51... | ||
- | 51 | ||
- | 52 | bool secondrun; |
|
51 | 53 | ||
52 | void SetStyle(); |
54 | void SetStyle(); |
53 | void RenderTextbuf(); |
55 | void RenderTextbuf(); |
54 | void RenderLine(); |
56 | void RenderLine(); |
Line 107... | Line 109... | ||
107 | draw_w = list.w - BODY_MARGIN; |
109 | draw_w = list.w - BODY_MARGIN; |
108 | linebuf = 0; |
110 | linebuf = 0; |
109 | redirect = '\0'; |
111 | redirect = '\0'; |
110 | list.SetFont(8, 14, 10011000b); |
112 | list.SetFont(8, 14, 10011000b); |
111 | tag_table_reset(); |
113 | tag_table_reset(); |
- | 114 | is_html = true; |
|
- | 115 | if (!strstri(bufpointer, " |
|
- | 116 | t_body = true; |
|
- | 117 | if (!strstri(bufpointer, " |
|
- | 118 | && (!strstr(bufpointer, " |
|
- | 119 | style.pre = true; //show linebreaks for a plaint text |
|
- | 120 | is_html = false; |
|
- | 121 | } |
|
- | 122 | } |
|
112 | } |
123 | } |
113 | //============================================================================================ |
124 | //============================================================================================ |
114 | void TWebBrowser::Reparse() |
125 | void TWebBrowser::Reparse() |
115 | { |
126 | { |
116 | ParseHtml(bufpointer, bufsize); |
127 | ParseHtml(bufpointer, bufsize); |
Line 140... | Line 151... | ||
140 | bufsize = strlen(bufpointer); |
151 | bufsize = strlen(bufpointer); |
141 | } |
152 | } |
142 | } |
153 | } |
Line -... | Line 154... | ||
- | 154 | ||
- | 155 | ||
- | 156 | tr_col_count.drop(); |
|
- | 157 | secondrun = false; |
|
- | 158 | ||
143 | 159 | _PARSE_START_: |
|
144 | - | ||
145 | SetPageDefaults(); |
- | |
146 | is_html = true; |
- | |
147 | if (!strstri(bufpointer, " |
- | |
148 | t_body = true; |
- | |
149 | if (!strstri(bufpointer, " |
- | |
150 | && (!strstr(bufpointer, " |
- | |
151 | style.pre = true; //show linebreaks for a plaint text |
- | |
152 | is_html = false; |
- | |
153 | } |
160 | |
154 | } |
- | |
155 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
- | |
156 | { |
161 | SetPageDefaults(); |
157 | switch (ESBYTE[bufpos]) |
- | |
158 | { |
162 | for (bufpos=bufpointer; bufpos < bufpointer+bufsize; bufpos++;) |
- | 163 | { |
|
159 | case 0x0a: |
164 | if (style.pre) { |
160 | if (style.pre) { |
165 | if (ESBYTE[bufpos] == 0x0a) { |
161 | RenderTextbuf(); |
- | |
162 | NewLine(); |
166 | RenderTextbuf(); |
163 | } else { |
167 | NewLine(); |
164 | goto _DEFAULT; |
- | |
165 | } |
- | |
166 | break; |
168 | continue; |
167 | case 0x09: |
169 | } |
168 | if (style.pre) { |
170 | if (ESBYTE[bufpos] == 0x09) { |
169 | tab_len = draw_x - left_gap / list.font_w + strlen(#linebuf) % 4; |
171 | tab_len = draw_x - left_gap / list.font_w + strlen(#linebuf) % 4; |
170 | if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len; |
172 | if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len; |
171 | while (tab_len) {chrcat(#linebuf,' '); tab_len--;} |
173 | while (tab_len) {chrcat(#linebuf,' '); tab_len--;} |
172 | } else { |
174 | continue; |
173 | goto _DEFAULT; |
- | |
174 | } |
175 | } |
175 | break; |
176 | } |
176 | case '&': // and so on |
177 | if (ESBYTE[bufpos] == '&') { |
177 | bufpos = GetUnicodeSymbol(#linebuf, sizeof(TWebBrowser.linebuf), bufpos+1, bufpointer+bufsize); |
178 | bufpos = GetUnicodeSymbol(#linebuf, sizeof(TWebBrowser.linebuf), bufpos+1, bufpointer+bufsize); |
178 | break; |
179 | continue; |
179 | case '<': |
180 | } |
180 | if (!is_html) goto _DEFAULT; |
181 | if (ESBYTE[bufpos] == '<') && (is_html) { |
181 | if (!strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) goto _DEFAULT; |
182 | if (strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) { |
- | 183 | bufpos++; |
|
- | 184 | if (tag.parse(#bufpos, bufpointer + bufsize)) { |
|
- | 185 | ||
- | 186 | /* |
|
- | 187 | if (secondrun) |
|
- | 188 | { |
|
- | 189 | if (streq(#tag.name, "tr")) debugln(" "); |
|
- | 190 | if (!tag.opened) { |
|
- | 191 | debugch('/'); |
|
- | 192 | } else { |
|
- | 193 | debugch(' '); |
|
- | 194 | } |
|
- | 195 | debugln(sprintf(#param, "%s x%i y%i %s", |
|
- | 196 | #tag.name, draw_x, draw_y, #linebuf)); |
|
- | 197 | } |
|
182 | bufpos++; |
198 | //*/ |
183 | if (tag.parse(#bufpos, bufpointer + bufsize)) { |
199 | |
184 | RenderTextbuf(); |
200 | RenderTextbuf(); |
185 | $push cur_encoding |
201 | $push cur_encoding |
186 | SetStyle(); |
202 | SetStyle(); |
Line 191... | Line 207... | ||
191 | if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) { |
207 | if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) { |
192 | ParseHtml(bufpointer, strlen(bufpointer)); |
208 | ParseHtml(bufpointer, strlen(bufpointer)); |
193 | return; |
209 | return; |
194 | } |
210 | } |
195 | } |
211 | } |
196 | break; |
212 | continue; |
197 | default: |
213 | } |
198 | _DEFAULT: |
214 | } |
199 | AddCharToTheLine(ESBYTE[bufpos]); |
215 | AddCharToTheLine(ESBYTE[bufpos]); |
200 | } |
216 | } |
- | 217 | ||
- | 218 | if (!secondrun) { |
|
- | 219 | secondrun = true; |
|
- | 220 | goto _PARSE_START_; |
|
201 | } |
221 | } |
- | 222 | ||
202 | RenderTextbuf(); |
223 | RenderTextbuf(); |
203 | list.count = draw_y + style.cur_line_h; |
224 | list.count = draw_y + style.cur_line_h; |
Line 204... | Line 225... | ||
204 | 225 | ||
205 | canvas.bufh = math.max(list.visible, list.count); |
226 | canvas.bufh = math.max(list.visible, list.count); |