Rev 7748 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4411 | leency | 1 | |
4677 | leency | 2 | |
4416 | leency | 3 | |
5746 | leency | 4 | |
4416 | leency | 5 | |
5746 | leency | 6 | bool |
7742 | leency | 7 | b, u, s, h, |
6794 | leency | 8 | pre, |
5746 | leency | 9 | blq, |
10 | li, |
||
11 | li_tab, |
||
12 | button, |
||
7742 | leency | 13 | image, |
14 | align; |
||
5746 | leency | 15 | dword |
7743 | leency | 16 | bg_color; |
17 | }; |
||
5746 | leency | 18 | |
19 | |||
4411 | leency | 20 | llist list; |
4540 | leency | 21 | _style style; |
5746 | leency | 22 | DrawBufer DrawBuf; |
4475 | leency | 23 | int zoom; |
6803 | leency | 24 | bool opened; //is this a "start tag" or "end tag" |
7746 | leency | 25 | void SetPageDefaults(); |
26 | void Prepare(); |
||
5766 | leency | 27 | void SetStyle(); |
28 | void DrawStyle(); |
||
29 | void DrawPage(); |
||
4411 | leency | 30 | void DrawScroller(); |
31 | void LoadInternalPage(); |
||
5747 | leency | 32 | void NewLine(); |
4650 | leency | 33 | void Perenos(); |
4718 | leency | 34 | void BufEncode(); |
5749 | leency | 35 | } WB1; |
4686 | leency | 36 | |
4486 | leency | 37 | |
5746 | leency | 38 | |
7742 | leency | 39 | link, |
5746 | leency | 40 | cur_encoding, |
41 | t_html, |
||
42 | t_body; |
||
43 | |||
44 | |||
5781 | leency | 45 | dword o_bufpointer=0; |
46 | dword bufsize=0; |
||
47 | |||
4411 | leency | 48 | |
4417 | leency | 49 | dword text_color_index; |
50 | dword link_color_inactive; |
||
4491 | leency | 51 | dword link_color_active; |
52 | dword page_bg; |
||
7743 | leency | 53 | |
4411 | leency | 54 | |
6794 | leency | 55 | int stolbec; |
4417 | leency | 56 | int tab_len; |
57 | |||
4636 | leency | 58 | |
6794 | leency | 59 | int basic_line_h=22; |
60 | |||
61 | |||
5746 | leency | 62 | char header[2048]; |
63 | char line[500]; |
||
4417 | leency | 64 | char tagparam[10000]; |
5746 | leency | 65 | char tag[100]; |
4417 | leency | 66 | char oldtag[100]; |
5768 | leency | 67 | char attr[1200]; |
5746 | leency | 68 | char val[4096]; |
69 | |||
4411 | leency | 70 | |
5990 | leency | 71 | #include "..\TWB\links.h" |
4686 | leency | 72 | #include "..\TWB\anchors.h" |
7738 | leency | 73 | #include "..\TWB\colors.h" |
4411 | leency | 74 | #include "..\TWB\unicode_tags.h" |
75 | #include "..\TWB\img_cache.h" |
||
76 | #include "..\TWB\parce_tag.h" |
||
77 | |||
78 | |||
4475 | leency | 79 | |
5747 | leency | 80 | void TWebBrowser::DrawStyle() |
5766 | leency | 81 | { |
4411 | leency | 82 | dword start_x, line_length, stolbec_len; |
6803 | leency | 83 | |
4411 | leency | 84 | |
85 | { |
||
86 | strcpy(#header, #line); |
||
7032 | leency | 87 | line = 0; |
4411 | leency | 88 | return; |
89 | } |
||
90 | if (t_html) && (!t_body) return; |
||
4637 | leency | 91 | |
4411 | leency | 92 | |
6803 | leency | 93 | { |
4411 | leency | 94 | start_x = stolbec * list.font_w + body_magrin + list.x; |
6794 | leency | 95 | stolbec_len = strlen(#line) * zoom; |
6803 | leency | 96 | line_length = stolbec_len * list.font_w; |
5768 | leency | 97 | |
4411 | leency | 98 | |
7749 | leency | 99 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xDDDddd); |
100 | } |
||
101 | |||
102 | |||
7743 | leency | 103 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color); |
104 | } |
||
105 | |||
106 | |||
7742 | leency | 107 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB); |
7743 | leency | 108 | } |
7742 | leency | 109 | if (style.button) { |
110 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
||
111 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
||
112 | } |
||
113 | |||
114 | |||
7738 | leency | 115 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
116 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
||
6803 | leency | 117 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
118 | if (link) { |
||
5519 | leency | 119 | if (line[0]==' ') && (line[1]==NULL) {} else { |
7747 | leency | 120 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]); |
7746 | leency | 121 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); |
122 | } |
||
123 | } |
||
4411 | leency | 124 | stolbec += stolbec_len; |
4718 | leency | 125 | } |
4411 | leency | 126 | } |
127 | //============================================================================================ |
||
5747 | leency | 128 | void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){ |
129 | bufsize = in_filesize; |
||
130 | bufpointer = bufpos; |
||
131 | Prepare(); |
||
5766 | leency | 132 | } |
5747 | leency | 133 | //============================================================================================ |
134 | void TWebBrowser::SetPageDefaults() |
||
7746 | leency | 135 | { |
136 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = |
||
137 | style.li = link = text_color_index = text_colors[0] = style.li_tab = false; |
||
138 | style.align = ALIGN_LEFT; |
||
5746 | leency | 139 | link_color_inactive = 0x0000FF; |
4491 | leency | 140 | link_color_active = 0xFF0000; |
141 | page_bg = 0xFFFFFF; |
||
7743 | leency | 142 | style.bg_color = page_bg; |
143 | DrawBuf.Fill(0, page_bg); |
||
144 | PageLinks.Clear(); |
||
4504 | leency | 145 | strcpy(#header, #version); |
4411 | leency | 146 | cur_encoding = CH_NULL; |
7746 | leency | 147 | draw_y = body_magrin; |
6794 | leency | 148 | stolbec = 0; |
4411 | leency | 149 | line = 0; |
150 | zoom = 1; |
||
7746 | leency | 151 | } |
152 | //============================================================================================ |
||
153 | void TWebBrowser::Prepare(){ |
||
154 | word bukva[2]; |
||
155 | dword j; |
||
156 | bool ignor_param; |
||
157 | dword bufpos; |
||
158 | dword line_len; |
||
159 | SetPageDefaults(); |
||
160 | if (strstri(bufpointer, " |
||
7749 | leency | 161 | t_body = true; |
162 | if (strstri(bufpointer, " |
||
163 | } |
||
164 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
||
5773 | leency | 165 | { |
4411 | leency | 166 | bukva = ESBYTE[bufpos]; |
4508 | leency | 167 | switch (bukva) |
4411 | leency | 168 | { |
169 | case 0x0a: |
||
170 | if (style.pre) |
||
5746 | leency | 171 | { |
4411 | leency | 172 | DrawStyle(); |
5781 | leency | 173 | line = NULL; |
6783 | leency | 174 | NewLine(); |
5781 | leency | 175 | break; |
4726 | leency | 176 | } |
4411 | leency | 177 | goto DEFAULT_MARK; |
6783 | leency | 178 | case '\9': |
4411 | leency | 179 | if (style.pre) //otherwise go to 0x0d |
6735 | leency | 180 | { |
4411 | leency | 181 | tab_len = strlen(#line) % 4; |
4725 | leency | 182 | if (!tab_len) tab_len = 4; |
183 | for (j=0; j |
||
4411 | leency | 184 | break; |
185 | } |
||
186 | goto DEFAULT_MARK; |
||
6783 | leency | 187 | case '&': // and so on |
4411 | leency | 188 | for (j=1, tag=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) |
7749 | leency | 189 | { |
4411 | leency | 190 | bukva = ESBYTE[bufpos+j]; |
7749 | leency | 191 | chrcat(#tag, bukva); |
4411 | leency | 192 | } |
193 | if (bukva = GetUnicodeSymbol(#tag)) { |
||
7749 | leency | 194 | bufpos += j; |
195 | } else { |
||
196 | bukva = '&'; |
||
197 | } |
||
198 | goto DEFAULT_MARK; |
||
199 | break; |
||
4411 | leency | 200 | case '<': |
201 | bufpos++; |
||
5749 | leency | 202 | if (!strncmp(bufpos,"!--",3)) |
5768 | leency | 203 | { |
4411 | leency | 204 | bufpos+=3; |
6986 | leency | 205 | while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize) |
206 | { |
||
207 | bufpos++; |
||
208 | } |
||
209 | bufpos+=2; |
||
7746 | leency | 210 | break; |
6986 | leency | 211 | } |
4411 | leency | 212 | tag = attr = tagparam = ignor_param = NULL; |
5768 | leency | 213 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷à åì òåã è åãî ïà ðà ìåòðû |
6735 | leency | 214 | { |
4411 | leency | 215 | bukva = ESBYTE[bufpos]; |
4508 | leency | 216 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
4411 | leency | 217 | if (!ignor_param) && (bukva <>' ') |
218 | { |
||
219 | if (strlen(#tag)+1 |
||
6686 | leency | 220 | } |
4411 | leency | 221 | else |
222 | { |
||
223 | ignor_param = true; |
||
224 | if (strlen(#tagparam)+1 |
||
7746 | leency | 225 | } |
4411 | leency | 226 | bufpos++; |
4508 | leency | 227 | } |
4411 | leency | 228 | strlwr(#tag); |
229 | |||
230 | |||
7746 | leency | 231 | if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { |
232 | sprintf(#tagparam, "%s>", #tag); |
||
7748 | leency | 233 | j = strstri(bufpos, #tagparam); |
234 | if (j!=-1) { |
||
7746 | leency | 235 | bufpos = j-1; |
7749 | leency | 236 | } |
7746 | leency | 237 | tag = tagparam = NULL; |
7748 | leency | 238 | break; |
7746 | leency | 239 | } |
240 | |||
241 | |||
4411 | leency | 242 | if (tagparam) GetNextParam(); |
4726 | leency | 243 | |
7746 | leency | 244 | |
245 | { |
||
246 | opened = 0; |
||
247 | strcpy(#tag, #tag+1); |
||
248 | } |
||
249 | else opened = 1; |
||
250 | |||
251 | |||
252 | Perenos(); |
||
253 | DrawStyle(); |
||
254 | line = NULL; |
||
255 | if (tag) SetStyle(); |
||
7748 | leency | 256 | } |
7746 | leency | 257 | strlcpy(#oldtag, #tag, sizeof(oldtag)); |
6686 | leency | 258 | tag = attr = tagparam = ignor_param = NULL; |
5746 | leency | 259 | break; |
4411 | leency | 260 | default: |
261 | DEFAULT_MARK: |
||
262 | if (bukva<=15) bukva=' '; |
||
263 | line_len = strlen(#line); |
||
6021 | leency | 264 | if (!style.pre) && (bukva == ' ') |
5746 | leency | 265 | { |
4411 | leency | 266 | if (line[line_len-1]==' ') break; //no double spaces |
4726 | leency | 267 | if (!stolbec) && (!line) break; //no paces at the beginning of the line |
268 | } |
||
4411 | leency | 269 | if (line_len < sizeof(line)) chrcat(#line, bukva); |
4726 | leency | 270 | Perenos(); |
5768 | leency | 271 | } |
4411 | leency | 272 | } |
273 | DrawStyle(); |
||
5766 | leency | 274 | NewLine(); |
275 | if (list.first == 0) list.count = draw_y; |
||
6794 | leency | 276 | DrawPage(); |
4692 | leency | 277 | } |
4411 | leency | 278 | //============================================================================================ |
5747 | leency | 279 | void TWebBrowser::Perenos() |
4718 | leency | 280 | { |
281 | int perenos_num; |
||
282 | char new_line_text[4096]; |
||
283 | if (strlen(#line)*zoom + stolbec < list.column_max) return; |
||
6803 | leency | 284 | perenos_num = strrchr(#line, ' '); |
4718 | leency | 285 | if (!perenos_num) && (strlen(#line)*zoom>list.column_max) { |
7742 | leency | 286 | perenos_num=list.column_max/zoom; |
287 | if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt |
||
288 | } |
||
289 | strcpy(#new_line_text, #line + perenos_num); |
||
4718 | leency | 290 | line[perenos_num] = 0x00; |
291 | DrawStyle(); |
||
5766 | leency | 292 | strcpy(#line, #new_line_text); |
4718 | leency | 293 | NewLine(); |
294 | } |
||
295 | //============================================================================================ |
||
5747 | leency | 296 | void TWebBrowser::SetStyle() { |
5773 | leency | 297 | char img_path[4096]=0; |
7749 | leency | 298 | int left1 = body_magrin + list.x; |
6794 | leency | 299 | int meta_encoding; |
7742 | leency | 300 | if (istag("html")) { |
5749 | leency | 301 | t_html = opened; |
4637 | leency | 302 | return; |
4411 | leency | 303 | } |
304 | if(istag("title")) { |
||
5749 | leency | 305 | if (opened) header=NULL; |
4491 | leency | 306 | return; |
4411 | leency | 307 | } |
308 | |||
309 | |||
5746 | leency | 310 | { |
4491 | leency | 311 | if (opened) strcat(#line, " \""); |
5746 | leency | 312 | if (!opened) strcat(#line, "\" "); |
313 | return; |
||
5749 | leency | 314 | } |
4491 | leency | 315 | if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last |
7738 | leency | 316 | anchors.add(#val, draw_y); |
317 | } |
||
318 | if (istag("body")) { |
||
5749 | leency | 319 | t_body = opened; |
4637 | leency | 320 | do{ |
4411 | leency | 321 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
5746 | leency | 322 | if (isattr("alink=")) link_color_active = GetColor(#val); |
323 | if (isattr("text=")) text_colors[0]=GetColor(#val); |
||
324 | if (isattr("bgcolor=")) |
||
325 | { |
||
4411 | leency | 326 | style.bg_color = page_bg = GetColor(#val); |
7743 | leency | 327 | DrawBuf.Fill(0, page_bg); |
328 | } |
||
4411 | leency | 329 | } while(GetNextParam()); |
330 | if (opened) && (cur_encoding==CH_NULL) { |
||
7032 | leency | 331 | cur_encoding = CH_CP866; |
7742 | leency | 332 | //BufEncode(CH_UTF8); |
333 | debugln("Document has no information about encoding!"); |
||
334 | } |
||
7032 | leency | 335 | if (opened) { |
336 | if (strcmp(#header, #version) != 0) { |
||
7208 | leency | 337 | ChangeCharset(charsets[cur_encoding], "CP866", #header); |
7056 | leency | 338 | sprintf(#header, "%s - %s", #header, #version); |
339 | } |
||
340 | DrawTitle(#header); |
||
7032 | leency | 341 | } |
342 | return; |
||
4411 | leency | 343 | } |
344 | if (istag("a")) { |
||
5749 | leency | 345 | if (opened) |
4491 | leency | 346 | { |
4411 | leency | 347 | if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à ÃÃ¥ áûë çà êðûò |
6735 | leency | 348 | do{ |
4411 | leency | 349 | if (isattr("href=")) && (!strstr(#val,"javascript:")) |
6001 | leency | 350 | { |
4411 | leency | 351 | text_color_index++; |
352 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
353 | link = 1; |
||
354 | text_colors[text_color_index] = link_color_inactive; |
||
4491 | leency | 355 | PageLinks.AddLink(#val); |
6795 | leency | 356 | } |
4411 | leency | 357 | } while(GetNextParam()); |
358 | } |
||
359 | else { |
||
360 | link = 0; |
||
361 | IF(text_color_index > 0) text_color_index--; |
||
362 | } |
||
363 | return; |
||
364 | } |
||
365 | if (istag("font")) { |
||
5749 | leency | 366 | style.bg_color = page_bg; |
7743 | leency | 367 | if (opened) |
4491 | leency | 368 | { |
4411 | leency | 369 | text_color_index++; |
370 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
371 | do{ |
||
372 | if (isattr("color=")) text_colors[text_color_index] = GetColor(#val); |
||
5749 | leency | 373 | if (isattr("bg=")) style.bg_color = GetColor(#val); |
7743 | leency | 374 | } while(GetNextParam()); |
4411 | leency | 375 | } |
376 | else if (text_color_index > 0) text_color_index--; |
||
5749 | leency | 377 | return; |
4411 | leency | 378 | } |
379 | if (istag("div")) { |
||
7746 | leency | 380 | if (streq(#oldtag,"div")) && (opened) return; |
381 | NewLine(); |
||
382 | //IF (oldtag[0] != 'h') |
||
383 | return; |
||
4411 | leency | 384 | } |
385 | if (istag("header")) || (istag("article")) || (istag("footer")) || (istag("figure")) { |
||
7746 | leency | 386 | NewLine(); |
387 | return; |
||
388 | } |
||
389 | if (istag("p")) { |
||
5746 | leency | 390 | IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return; |
7746 | leency | 391 | NewLine(); |
4692 | leency | 392 | //IF(opened) NewLine(); |
7746 | leency | 393 | return; |
4411 | leency | 394 | } |
395 | if (istag("br")) { NewLine(); return; } |
||
5749 | leency | 396 | if (istag("tr")) { if (opened) NewLine(); return; } |
5990 | leency | 397 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
5749 | leency | 398 | if (istag("button")) { style.button = opened; stolbec++; return; } |
7742 | leency | 399 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
5749 | leency | 400 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
401 | if (istag("dd")) { stolbec += 5; return; } |
||
402 | if (istag("blockquote")) { style.blq = opened; return; } |
||
403 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
||
404 | if (istag("img")) { |
||
7742 | leency | 405 | do{ |
406 | if (isattr("src=")) strncpy(#img_path, #val, sizeof(img_path)-1); |
||
7748 | leency | 407 | if (isattr("title=")) && (strlen(#val) |
7749 | leency | 408 | if (isattr("alt=")) && (strlen(#val) |
409 | } while(GetNextParam()); |
||
7742 | leency | 410 | if (!img_path) return; |
7749 | leency | 411 | style.image = true; |
7742 | leency | 412 | text_color_index++; |
413 | text_colors[text_color_index] = 0x9A6F29; |
||
414 | if (!line) { |
||
415 | if (!strncmp(#img_path, "data:", 5)) img_path=0; |
||
416 | replace_char(#img_path, '?', NULL, strlen(#img_path)); |
||
7749 | leency | 417 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
7742 | leency | 418 | line[50]= NULL; |
419 | } |
||
420 | if (strlen(#line) + stolbec > list.column_max) Perenos(); |
||
421 | DrawStyle(); |
||
422 | line=0; |
||
423 | text_color_index--; |
||
424 | style.image = false; |
||
425 | //ImgCache.Images( left1, draw_y, WB1.list.w); |
||
426 | return; |
||
427 | } |
||
428 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) { |
||
7208 | leency | 429 | style.h = opened; |
5768 | leency | 430 | if (opened) |
4491 | leency | 431 | { |
4411 | leency | 432 | NewLine(); |
6794 | leency | 433 | draw_y += 10; |
434 | WB1.zoom=2; |
||
6803 | leency | 435 | WB1.list.font_type |= 10011001b; |
6045 | leency | 436 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
5746 | leency | 437 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
438 | list.item_h = basic_line_h * 2; |
||
6794 | leency | 439 | if (istag("h1")) style.b = true; |
7742 | leency | 440 | } |
4411 | leency | 441 | else |
5768 | leency | 442 | { |
4411 | leency | 443 | if (istag("h1")) style.b = false; |
7742 | leency | 444 | NewLine(); |
6794 | leency | 445 | WB1.zoom=1; |
6803 | leency | 446 | WB1.list.font_type = 10011000b; |
6045 | leency | 447 | style.align = ALIGN_LEFT; |
5746 | leency | 448 | list.item_h = basic_line_h; |
6794 | leency | 449 | } |
4411 | leency | 450 | return; |
451 | } |
||
452 | if (istag("dt")) { |
||
5749 | leency | 453 | style.li = opened; |
5746 | leency | 454 | if (opened) NewLine(); |
5749 | leency | 455 | return; |
4411 | leency | 456 | } |
457 | if (istag("li")) || (istag("dt")) |
||
5773 | leency | 458 | { |
4411 | leency | 459 | style.li = opened; |
5746 | leency | 460 | if (opened) |
4491 | leency | 461 | { |
4411 | leency | 462 | NewLine(); |
4692 | leency | 463 | stolbec = style.li_tab * 5 - 2; |
7743 | leency | 464 | strcpy(#line, "\31 "); |
7742 | leency | 465 | //stolbec-=2; |
7743 | leency | 466 | } |
4411 | leency | 467 | return; |
468 | } |
||
469 | if (istag("ul")) || (istag("ol")) { |
||
5749 | leency | 470 | if (!opened) |
471 | { |
||
472 | style.li = opened; |
||
473 | style.li_tab--; |
||
474 | NewLine(); |
||
475 | } |
||
476 | else style.li_tab++; |
||
477 | } |
||
478 | if (istag("hr")) { |
||
479 | if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999; |
||
5773 | leency | 480 | $push edi; |
481 | NewLine(); |
||
4692 | leency | 482 | $pop edi; |
5773 | leency | 483 | draw_y += 10; |
7746 | leency | 484 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
6794 | leency | 485 | NewLine(); |
4692 | leency | 486 | draw_y += 10; |
7746 | leency | 487 | return; |
5773 | leency | 488 | } |
4411 | leency | 489 | if (istag("meta")) || (istag("?xml")) { |
5749 | leency | 490 | meta_encoding = CH_NULL; |
6045 | leency | 491 | do{ |
4411 | leency | 492 | if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding=")) |
5746 | leency | 493 | { |
4411 | leency | 494 | strcpy(#val, #val[strrchr(#val, '=')]); //search in content= |
6735 | leency | 495 | strlwr(#val); |
5746 | leency | 496 | if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8; |
5749 | leency | 497 | else if (isval("koi8-r")) || (isval("koi8-u")) meta_encoding = CH_KOI8; |
5746 | leency | 498 | else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251; |
499 | else if (isval("iso-8859-5")) || (isval("iso8859-5")) meta_encoding = CH_ISO8859_5; |
||
500 | else if (isval("dos")) || (isval("cp-866")) meta_encoding = CH_CP866; |
||
501 | } |
||
4411 | leency | 502 | } while(GetNextParam()); |
503 | if (meta_encoding!=CH_NULL) BufEncode(meta_encoding); |
||
6045 | leency | 504 | return; |
4411 | leency | 505 | } |
506 | } |
||
507 | //============================================================================================ |
||
7746 | leency | 508 | void TWebBrowser::BufEncode(dword set_new_encoding) |
6803 | leency | 509 | { |
5704 | leency | 510 | if (cur_encoding == set_new_encoding) return; |
7032 | leency | 511 | if (o_bufpointer==0) |
5704 | leency | 512 | { |
513 | o_bufpointer = malloc(bufsize); |
||
514 | strcpy(o_bufpointer, bufpointer); |
||
515 | } |
||
516 | else |
||
517 | { |
||
518 | strcpy(bufpointer, o_bufpointer); |
||
519 | } |
||
520 | //debugval("cur_encoding ", cur_encoding); |
||
7742 | leency | 521 | //debugval("set_new_encoding", set_new_encoding); |
522 | cur_encoding = set_new_encoding; |
||
7032 | leency | 523 | bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); |
524 | } |
||
5704 | leency | 525 | //============================================================================================ |
5747 | leency | 526 | void TWebBrowser::DrawScroller() |
4674 | leency | 527 | { |
4411 | leency | 528 | scroll_wv.max_area = list.count; |
4416 | leency | 529 | scroll_wv.cur_area = list.visible; |
530 | scroll_wv.position = list.first; |
||
531 | scroll_wv.all_redraw = 0; |
||
5519 | leency | 532 | scroll_wv.start_x = list.x + list.w; |
4486 | leency | 533 | scroll_wv.start_y = list.y; |
4508 | leency | 534 | scroll_wv.size_y = list.h; |
5678 | leency | 535 | scrollbar_v_draw(#scroll_wv); |
4416 | leency | 536 | } |
4411 | leency | 537 | //============================================================================================ |
5747 | leency | 538 | void TWebBrowser::NewLine() |
4692 | leency | 539 | { |
4475 | leency | 540 | dword onleft, ontop; |
6803 | leency | 541 | static int empty_line=0; |
7742 | leency | 542 | |
4692 | leency | 543 | |
6794 | leency | 544 | |
7742 | leency | 545 | |
7749 | leency | 546 | if (empty_line<1) empty_line++; |
7742 | leency | 547 | else return; |
548 | } else if (!stolbec) { |
||
7749 | leency | 549 | if (empty_line<1) empty_line++; |
550 | else return; |
||
551 | } else { |
||
7742 | leency | 552 | empty_line=0; |
553 | } |
||
554 | |||
6794 | leency | 555 | |
556 | ontop = draw_y + list.y; |
||
557 | if (t_html) && (!t_body) return; |
||
4637 | leency | 558 | draw_y += list.item_h; |
6794 | leency | 559 | if (style.blq) stolbec = 6; else stolbec = 0; |
5746 | leency | 560 | if (style.li) stolbec = style.li_tab * 5; |
561 | } |
||
4488 | leency | 562 | //============================================================================================ |
5747 | leency | 563 | bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } |
6803 | leency | 564 | bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } |
565 | bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } |
||
566 | //============================================================================================ |
||
5766 | leency | 567 | void TWebBrowser::DrawPage() |
568 | { |
||
569 | PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
||
6794 | leency | 570 | DrawScroller(); |
5766 | leency | 571 | }1)>1)>>>=15)>>>>': |
572 | >8);>>> |