Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7757 → Rev 7758

/programs/cmm/TWB/unicode_tags.h
File deleted
/programs/cmm/TWB/absolute_url.h
File deleted
/programs/cmm/TWB/TWB.c
1,8 → 1,7
#include "..\TWB\colors.h"
#include "..\TWB\anchors.h"
#include "..\TWB\parce_tag.h"
#include "..\TWB\absolute_url.h"
#include "..\TWB\unicode_tags.h"
#include "..\TWB\special.h"
#include "..\TWB\img_cache.h"
dword page_bg;
dword link_color_inactive;
22,6 → 21,8
image,
align;
dword bg_color;
 
dword main_title;
};
 
struct TWebBrowser {
63,13 → 64,18
{
dword start_x, line_length, stolbec_len;
if (!header)
if (style.main_title)
{
strncpy(#header, #line, sizeof(header)-1);
strncat(#header, " - ", sizeof(header)-1);
strncat(#header, #version, sizeof(header)-1);
line = 0;
return;
}
if (t_html) && (!t_body) return;
if (t_html) && (!t_body) {
line = 0;
return;
}
if (line)
{
112,7 → 118,7
void TWebBrowser::SetPageDefaults()
{
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
style.li = link = text_color_index = text_colors[0] = style.li_tab = false;
style.li = link = text_color_index = text_colors[0] = style.li_tab = style.main_title = false;
style.align = ALIGN_LEFT;
link_color_inactive = 0x0000FF;
link_color_active = 0xFF0000;
121,7 → 127,7
DrawBuf.Fill(0, page_bg);
PageLinks.Clear();
anchors.clear();
strncpy(#header, #version, sizeof(header)-1);
header = NULL;
cur_encoding = CH_NULL;
draw_y = body_magrin;
stolbec = 0;
258,25 → 264,34
list.count = draw_y;
list.CheckDoesValuesOkey();
anchors.current = NULL;
if (!header) {
strncpy(#header, #version, sizeof(header)-1);
DrawTitle(#header);
}
}
//============================================================================================
bool TWebBrowser::CheckForLineBreak()
{
int line_break_pos;
char new_line_text[4096];
//Do we need a line break?
if (strlen(#line)*zoom + stolbec < list.column_max) return false;
//Yes, we do. Lets calculate where...
line_break_pos = strrchr(#line, ' ');
//Is a new line fits in the current 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
//Maybe a new line is too big for the whole new line? Then we have to split it
if (!line_break_pos) && (style.li_tab*5 + strlen(#line) * zoom >= list.column_max) {
line_break_pos = list.column_max/zoom - stolbec;
}
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();
296,16 → 311,10
anchors.current = NULL;
}
}
 
if (tag.is("html")) {
t_html = tag.opened;
return;
}
if (tag.is("title")) {
if (tag.opened) header=NULL;
return;
}
if (tag.is("q"))
{
if (tag.opened) {
316,6 → 325,11
if (!tag.opened) strcat(#line, "\" ");
return;
}
if (tag.is("title")) {
style.main_title = tag.opened;
if (!tag.opened) DrawTitle(#header);
return;
}
if (tag.is("body")) {
t_body = tag.opened;
if (value = tag.get_value_of("link=")) link_color_inactive = GetColor(value);
325,19 → 339,6
style.bg_color = page_bg = GetColor(value);
DrawBuf.Fill(0, page_bg);
}
if (tag.opened) {
if (cur_encoding==CH_NULL) {
cur_encoding = CH_CP866;
//BufEncode(CH_UTF8);
debugln("Document has no information about encoding!");
}
if (!streq(#header, #version)) {
ChangeCharset(charsets[cur_encoding], "CP866", #header);
strncat(#header, " - ", sizeof(header)-1);
strncat(#header, #version, sizeof(header)-1);
}
DrawTitle(#header);
}
return;
}
if (tag.is("a")) {
415,28 → 416,25
//ImgCache.Images( list.x, draw_y, WB1.list.w);
return;
}
if (tag.is("h4")) {
NewLine();
style.h = tag.opened;
style.b = tag.opened;
}
if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) {
style.h = tag.opened;
if (tag.opened)
{
if (tag.opened) {
NewLine();
draw_y += 10;
WB1.zoom=2;
WB1.list.font_type |= 10011001b;
if (value = tag.get_value_of("align=")) {
if (streq(value, "center")) style.align = ALIGN_CENTER;
if (streq(value, "right")) style.align = ALIGN_RIGHT;
}
list.item_h = basic_line_h * 2;
list.item_h = basic_line_h * 2 - 2;
if (tag.is("h1")) style.b = true;
}
else
{
} else {
if (tag.is("h1")) style.b = false;
NewLine();
WB1.zoom=1;
WB1.list.font_type = 10011000b;
style.align = ALIGN_LEFT;
list.item_h = basic_line_h;
}
return;
451,6 → 449,7
style.li = tag.opened;
if (tag.opened)
{
if (style.li_tab==0) style.li_tab++;
NewLine();
stolbec = style.li_tab * 5 - 2;
strcpy(#line, "\31 ");
462,11 → 461,13
if (!tag.opened)
{
style.li = false;
style.li_tab--;
if (style.li_tab>0) style.li_tab--;
NewLine();
}
else style.li_tab++;
else {
if (style.li_tab<5) style.li_tab++;
}
}
if (tag.is("hr")) {
if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
$push edi;
490,7 → 491,13
else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5;
else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8;
}
if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
if (meta_encoding!=CH_NULL) {
BufEncode(meta_encoding);
if (header) {
ChangeCharset(charsets[cur_encoding], "CP866", #header);
DrawTitle(#header);
}
}
return;
}
}
/programs/cmm/TWB/links.h
54,6 → 54,7
return links[id].link;
}
 
bool open_new_window=false;
void LinksArray::Clear()
{
page_links.drop();
62,6 → 63,7
active = -1;
unic_count = 0;
CursorPointer.Restore();
open_new_window = false;
}
 
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
75,7 → 77,7
}
}
 
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
PathShow_data status_text = {0, 17,250, 6, 250};
 
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
{
93,7 → 95,9
return false;
}
if (mouse.mkm) && (mouse.up) {
RunProgram(#program_path, PageLinks.GetURL(PageLinks.active));
open_new_window = true;
EventClickLink(PageLinks.GetURL(PageLinks.active));
open_new_window = false;
return false;
}
if (mouse.lkm) && (mouse.up) {
/programs/cmm/TWB/special.h
0,0 → 1,94
char *unicode_symbols[]={
"quot","\"",
"amp", "&",
"lt", "<",
"gt", ">",
"#183","\31", "middot", "\31",
"#149","-",
"#151","-",
"#160"," ", "nbsp", " ",
"#169","(c)", "copy", "(c)",
"#171","<<", "laquo","<<",
"#174","(r)", "reg", "(r)",
"#187",">>", "raquo",">>",
 
"trade", "[TM]",
"bdquo", ",,",
 
"minus", "-",
"ndash", "-",
"mdash", "-", //--
 
"rsquo", "'",
"sect", "#",
 
"ensp", " ",
"emsp13", " ",
"emsp14", " ",
"numsp", " ",
"puncsp", " ",
"thinsp", " ",
 
"#1028", "\242",
"#1030", "I",
"#1031", "\244",
 
"#8211", "-",
"#8217", "'",
"#8220", "\"",
"#8222", "\"", "ldquo", "\"",
"#8221", "\"", "rdquo", "\"",
"#8470", "N",
"#8722", "-",
"#9642", "-", //square in the middle of the line
"#9658", ">",
"#9660", "v",
"#65122", "+",
 
"uarr", "\24",
"darr", "\25",
"rarr", "\26",
"larr", "\27",
 
"bull", "\31",
"percnt","%",
 
"#xfeff", "",
 
"times", "x",
"lowast","*",
 
0};
 
 
unsigned char unicode_chars[] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
 
bool GetUnicodeSymbol(dword _line, in_tag, size)
{
int j;
int code;
for (j=0; unicode_symbols[j]!=0; j+=2;)
{
if (!strcmp(in_tag, unicode_symbols[j]))
{
strncat(_line, unicode_symbols[j+1], size);
return true;
}
}
 
if (ESBYTE[in_tag]=='#')
{
code = atoi(in_tag + 1);
if (code>=0) && (code<=255) {
chrncat(_line, code, size); //NOT ALL ASCII CODES IN KOLIBRI ARE COMPATABLE WITH STANDARDS
return true;
}
if (code>=1040) && (code<=1040+72) {
chrncat(_line, unicode_chars[code-1040], size);
return true;
}
}
 
return false;
}