Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5768 → Rev 5767

/programs/cmm/TWB/TWB.c
6,7 → 6,7
 
struct _style {
byte
b, i, u, s, h,
b, i, u, s,
pre,
blq,
li,
17,6 → 17,7
struct TWebBrowser {
llist list;
_style style;
dword draw_line_width;
DrawBufer DrawBuf;
void Prepare();
void SetStyle();
58,10 → 59,9
char line[500];
char tagparam[10000];
char tag[100];
char oldtag[100];
char attr[1200];
char val[4096];
char anchor[256]=0;
char anchor[256];
 
#include "..\TWB\history.h"
#include "..\TWB\links.h"
91,10 → 91,9
{
start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x;
start_y = stroka * list.line_h + body_magrin;
stolbec_len = utf8_strlen(#line) * DrawBuf.zoom;
line_length = stolbec_len * list.font_w;
stolbec_len = utf8_strlen(#line);
line_length = stolbec_len * list.font_w * DrawBuf.zoom;
 
if (style.h) stroka++;
WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.line_h); } // bug with zoom>1
123,7 → 122,7
dword bufpos = bufpointer;
int line_len;
style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body =
style.b = style.i = style.u = style.s = style.blq = t_html = t_body =
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
style.align = ALIGN_LEFT;
link_color_inactive = 0x0000FF;
136,16 → 135,22
stolbec = 0;
line = 0;
 
draw_line_width = list.w * DrawBuf.zoom;
 
//for plaint text use CP866 for other UTF
if (strstri(bufpointer, "html"))
{
style.pre = 0;
cur_encoding = CH_CP866;
//WB1.list.SetFont(8, 14, 10111000b);
//list.line_h = list.font_h + 4;
}
else
{
style.pre = 1;
cur_encoding = CH_UTF8;
//WB1.list.SetFont(8, 14, 10001000b);
//list.line_h = list.font_h + 4;
}
 
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
184,12 → 189,24
break;
case '<':
bufpos++;
if (!strncmp(bufpos,"!--",3))
tag = attr = tagparam = ignor_param = NULL;
if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
{
if (!strncmp(bufpos,"-->",3)) || (bufpointer + bufsize <= bufpos) break;
bufpos++;
if (ESBYTE[bufpos] == '-')
{
HH_:
do
{
bufpos++;
if (bufpointer + bufsize <= bufpos) break 2;
}
tag = attr = tagparam = ignor_param = NULL;
while (ESBYTE[bufpos] <>'-');
bufpos++;
if (ESBYTE[bufpos] <>'-') goto HH_;
}
}
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
{
bukva = ESBYTE[bufpos];
210,11 → 227,10
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
if (tagparam) GetNextParam();
 
Perenos();
if (stolbec + utf8_strlen(#line) > list.column_max) Perenos();
DrawStyle();
line = NULL;
if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
strcpy(#oldtag, #tag);
tag = attr = tagparam = ignor_param = NULL;
break;
default:
227,7 → 243,7
if (!stolbec) && (!line) break; //no paces at the beginning of the line
}
if (line_len < sizeof(line)) chrcat(#line, bukva);
Perenos();
if (stolbec + line_len > list.column_max) Perenos();
}
}
DrawStyle();
246,7 → 262,6
{
int perenos_num;
char new_line_text[4096];
if (stolbec + utf8_strlen(#line) < list.column_max) return;
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max;
strcpy(#new_line_text, #line + perenos_num);
256,6 → 271,7
NewLine();
}
//============================================================================================
char oldtag[100];
void TWebBrowser::SetStyle(int left1, top1) {
dword hr_color;
byte opened;
372,25 → 388,47
if (istag("blockquote")) { style.blq = opened; return; }
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; }
/*
if (istag("center"))
{
if (opened) style.align = ALIGN_CENTER;
if (!opened)
{
NewLine();
style.align = ALIGN_LEFT;
}
return;
}
if (istag("right"))
{
if (opened) style.align = ALIGN_RIGHT;
if (!opened)
{
NewLine();
style.align = ALIGN_LEFT;
}
return;
}
*/
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
style.h = opened;
NewLine();
if (opened) && (stroka>1) NewLine();
strcpy(#oldtag, #tag);
if (opened)
{
WB1.DrawBuf.zoom=2;
WB1.list.SetFont(8, 14, 10111001b);
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
if (stroka>1) NewLine();
style.b = 1;
}
else
if (!opened)
{
WB1.DrawBuf.zoom=1;
WB1.list.SetFont(8, 14, 10111000b);
style.align = ALIGN_LEFT;
style.b = 0;
}
return;
}
else
oldtag=NULL;
if (istag("dt")) {
style.li = opened;
if (opened) NewLine();