Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7749 → Rev 7750

/programs/cmm/TWB/TWB.c
29,9 → 29,8
void DrawStyle();
void DrawPage();
void DrawScroller();
void LoadInternalPage();
void NewLine();
void Perenos();
bool CheckForLineBreak();
void BufEncode();
} WB1;
 
97,11 → 96,11
line_length = stolbec_len * list.font_w;
 
if (debug_mode) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xDDDddd);
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd);
}
 
if (style.bg_color!=page_bg) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color);
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color);
}
 
if (style.image) {
118,20 → 117,16
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
if (link) {
if (line[0]==' ') && (line[1]==NULL) {} else {
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]);
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, link_color_inactive);
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom);
}
}
stolbec += stolbec_len;
if (debug_mode) debug(#line);
line = NULL;
}
}
//============================================================================================
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
bufsize = in_filesize;
bufpointer = bufpos;
Prepare();
}
//============================================================================================
void TWebBrowser::SetPageDefaults()
{
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
171,7 → 166,6
if (style.pre)
{
DrawStyle();
line = NULL;
NewLine();
break;
}
193,10 → 187,11
}
if (bukva = GetUnicodeSymbol(#tag)) {
bufpos += j;
CheckForLineBreak();
} else {
bukva = '&';
goto DEFAULT_MARK;
}
goto DEFAULT_MARK;
break;
case '<':
bufpos++;
223,6 → 218,7
{
ignor_param = true;
if (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
// chrncat(#tagparam, bukva, sizeof(tagparam)-1);
}
bufpos++;
}
250,12 → 246,11
else opened = 1;
 
if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
Perenos();
CheckForLineBreak();
DrawStyle();
line = NULL;
if (tag) SetStyle();
}
strlcpy(#oldtag, #tag, sizeof(oldtag));
strlcpy(#oldtag, #tag, sizeof(oldtag)-1);
tag = attr = tagparam = ignor_param = NULL;
break;
default:
268,7 → 263,7
if (!stolbec) && (!line) break; //no paces at the beginning of the line
}
if (line_len < sizeof(line)) chrcat(#line, bukva);
Perenos();
CheckForLineBreak();
}
}
DrawStyle();
277,21 → 272,27
DrawPage();
}
//============================================================================================
void TWebBrowser::Perenos()
bool TWebBrowser::CheckForLineBreak()
{
int perenos_num;
int line_break_pos;
char new_line_text[4096];
if (strlen(#line)*zoom + stolbec < list.column_max) return;
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (strlen(#line)*zoom>list.column_max) {
perenos_num=list.column_max/zoom;
if (strlen(#line)*zoom + stolbec < list.column_max) return false;
line_break_pos = strrchr(#line, ' ');
if (line_break_pos*zoom + stolbec > list.column_max) {
line_break_pos = list.column_max/zoom - stolbec;
while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--;
}
if (!line_break_pos) && (strlen(#line)*zoom>list.column_max) {
line_break_pos=list.column_max/zoom;
if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt
}
strcpy(#new_line_text, #line + perenos_num);
line[perenos_num] = 0x00;
strcpy(#new_line_text, #line + line_break_pos);
line[line_break_pos] = 0x00;
DrawStyle();
strcpy(#line, #new_line_text);
NewLine();
//if (strlen(#line)*zoom + stolbec > list.column_max)CheckForLineBreak();
return true;
}
//============================================================================================
void TWebBrowser::SetStyle() {
309,7 → 310,11
IF(istag("q"))
{
if (opened) strcat(#line, " \"");
if (opened) {
meta_encoding = strlen(#line);
if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
chrcat(#line, '\"');
}
if (!opened) strcat(#line, "\" ");
return;
}
404,11 → 409,11
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
if (istag("img")) {
do{
if (isattr("src=")) strncpy(#img_path, #val, sizeof(img_path)-1);
if (isattr("src=")) strlcpy(#img_path, #val, sizeof(img_path)-1);
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
} while(GetNextParam());
if (!img_path) return;
if (!img_path) { line=0; return; }
style.image = true;
text_color_index++;
text_colors[text_color_index] = 0x9A6F29;
418,9 → 423,8
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
line[50]= NULL;
}
if (strlen(#line) + stolbec > list.column_max) Perenos();
while (CheckForLineBreak()) {};
DrawStyle();
line=0;
text_color_index--;
style.image = false;
//ImgCache.Images( left1, draw_y, WB1.list.w);
559,6 → 563,7
draw_y += list.item_h;
if (style.blq) stolbec = 6; else stolbec = 0;
if (style.li) stolbec = style.li_tab * 5;
if (debug_mode) debugln(NULL);
}
//============================================================================================
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
/programs/cmm/TWB/absolute_url.h
14,9 → 14,8
 
IF (!strncmp(in_URL,"//", 2))
{
//strcpy(#newurl, "http:");
//strcat(#newurl, in_URL);
sprintf(#newurl, "http:%s", in_URL);
strcpy(#newurl, "http:");
strcat(#newurl, in_URL);
strcpy(orig_URL, #newurl);
return;
}
/programs/cmm/TWB/parce_tag.h
6,6 → 6,7
if (!tagparam) return false;
 
if (debug_mode) {
debug("tag: "); debugln(#tag);
debug("tagparam: "); debugln(#tagparam);
}
23,7 → 24,7
 
//find VAL start and copy
i = strrchr(#tagparam, quotes);
strlcpy(#val, #tagparam + i, sizeof(val));
strlcpy(#val, #tagparam + i, sizeof(val)-1);
tagparam[i] = '\0'; i--;
 
//find ATTR end
38,8 → 39,8
//find VAL start and copy
while (i > 0) && (tagparam[i] != '=') i--;
i++;
strlcpy(#val, #tagparam + i, sizeof(val));
tagparam[i] = '\0';
strlcpy(#val, #tagparam + i, sizeof(val)-1);
// tagparam[i] = '\0';
 
//find ATTR end
//already have
47,21 → 48,23
 
//find ATTR start and copy
while (i>0) && (!__isWhite(tagparam[i])) i--;
strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
strlcpy(#attr, #tagparam + i + 1, sizeof(attr)-1);
tagparam[i] = '\0';
 
//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
i = strchr(#attr,'=');
if (!quotes) && (i) {
strlcpy(#val, i+1, sizeof(val)-1);
ESBYTE[i+1] = '\0';
}
 
strlwr(#attr);
 
if (debug_mode) {
if (quotes) {
debug("quote: "); debugch(quotes); debugln(" ");
debug("val: "); debugln(#val);
debug("attr: "); debugln(#attr);
debugln(" ");
}
else {
debugln("unquoted text");
}
sprintf(#param, "val: %s\nattr: %s\n\n", #val, #attr);
debug(#param);
}
 
return true;
}
/programs/cmm/TWB/unicode_tags.h
65,11 → 65,11
0};
 
 
byte unicode_chars[] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
unsigned char unicode_chars[] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
 
bool GetUnicodeSymbol(dword in_tag)
{
int j;
int j, specia1040;
for (j=0; unicode_tags[j]!=0; j+=2;)
{
80,10 → 80,19
}
}
 
j = atoi(in_tag + 1) - 1040;
if (tag[1] == '1') && (j>=0) && (j<=72) && (strlen(in_tag) == 5)
specia1040 = atoi(in_tag + 1) - 1040;
if (tag[1] == '1') && (specia1040>=0)
&& (specia1040<=72) && (strlen(in_tag) == 5)
{
chrcat(#line, unicode_chars[j]);
if (strlen(#line)<sizeof(line)-2) {
/*
j = strlen(#line);
line[j] = unicode_chars[specia1040];
line[j+1] = EOS;
*/
chrcat(#line, unicode_chars[specia1040]);
}
return true;
}