Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5748 → Rev 5749

/programs/cmm/TWB/table.h
File deleted
\ No newline at end of file
/programs/cmm/TWB/TWB.c
1,7 → 1,5
dword bufpointer;
dword o_bufpointer;
dword bufsize;
 
 
scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
 
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
28,6 → 26,7
void LoadInternalPage();
void NewLine();
void Perenos();
void BufEncode();
byte end_parsing;
} WB1;
 
39,19 → 38,11
cur_encoding,
t_html,
t_body;
/*
struct _condition {
byte
text_active,
text_val,
href,
max
} condition;
*/
 
byte condition_text_active, condition_text_val, condition_href, condition_max;
dword bufpointer;
dword o_bufpointer;
dword bufsize;
 
 
dword text_colors[300];
dword text_color_index;
dword link_color_inactive;
78,7 → 69,6
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
#include "..\TWB\parce_tag.h"
#include "..\TWB\table.h"
 
 
//============================================================================================
133,10 → 123,8
int line_len;
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 = condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
end_parsing = false;
condition_max = 255;
style.align = ALIGN_LEFT;
link_color_inactive = 0x0000FF;
link_color_active = 0xFF0000;
150,8 → 138,21
 
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;
if (strstri(bufpointer, "html")) style.pre = 0;
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++;)
{
158,7 → 159,6
if (end_parsing) break;
bukva = ESBYTE[bufpos];
if (ignor_text) && (bukva!='<') continue;
if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
switch (bukva)
{
case 0x0a:
190,7 → 190,7
if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
break;
case '<':
bufpos++; //ïðîìîòàåì ñèìâîë <
bufpos++;
tag = attr = tagparam = ignor_param = NULL;
if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
{
226,10 → 226,6
}
strlwr(#tag);
 
if (condition_text_active) && (condition_text_val != condition_href)
{
if (strcmp(#tag, "/condition")!=0) break;
}
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
if (tagparam) GetNextParam();
 
293,22 → 289,17
}
else opened = 1;
if (istag("html"))
{
if (istag("html")) {
t_html = opened;
return;
}
 
if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) ignor_text = opened;
if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; }
if (istag("form")) if (!opened) ignor_text = false;
 
if(istag("title"))
{
if(istag("title")) {
if (opened) header=NULL;
else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
return;
}
 
if (ignor_text) return;
IF(istag("q"))
315,18 → 306,14
{
if (opened) strcat(#line, " \"");
if (!opened) strcat(#line, "\" ");
return;
}
 
if (anchor) && (isattr("id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
{
if (anchor) && (isattr("id=")) { //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
if (!strcmp(#anchor, #val)) anchor_line_num=list.first+stroka;
}
if (istag("body"))
{
if (istag("body")) {
t_body = opened;
do{
if (isattr("condition_max=")) condition_max = atoi(#val);
if (isattr("link=")) link_color_inactive = GetColor(#val);
if (isattr("alink=")) link_color_active = GetColor(#val);
if (isattr("text=")) text_colors[0]=GetColor(#val);
336,28 → 323,19
DrawBuf.Fill(bg_color);
}
} while(GetNextParam());
if (opened) && (cur_encoding==CH_NULL)
{
debugln("Document has no information about encoding, UTF will be used");
//BufEncode(CH_UTF8);
}
if (opened) && (cur_encoding==CH_NULL) debugln("Document has no information about encoding, UTF will be used");
return;
}
 
if (istag("a"))
{
if (istag("a")) {
if (opened)
{
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
 
do{
if (isattr("href="))
{
if (stroka - 1 > list.visible) || (stroka < -2) return;
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
link = 1;
text_colors[text_color_index] = link_color_inactive;
PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom);
377,31 → 355,20
}
return;
}
 
if (istag("font"))
{
if (istag("font")) {
if (opened)
{
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
do{
if (strcmp(#attr, "color=") == 0) //&& (attr[1] == '#')
{
text_colors[text_color_index] = GetColor(#val);
}
if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
} while(GetNextParam());
}
else
if (text_color_index > 0) text_color_index--;
else if (text_color_index > 0) text_color_index--;
return;
}
if (istag("br")) {
NewLine();
return;
}
if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
IF(oldtag[0] <>'h') NewLine();
IF(oldtag[0] != 'h') NewLine();
if (isattr("bgcolor="))
{
bg_color=GetColor(#val);
415,50 → 382,17
IF(opened) NewLine();
return;
}
 
if(istag("table")) {
table.active = opened;
NewLine();
if (opened) table.NewTable();
}
 
if(istag("td")) {
if (opened)
{
table.cur_col++;
table.row_h = 0;
do {
if (isattr("width="))
{
table.col_w[table.cur_col] = atoi(#val);
// NewLine();
// strcpy(#line, #val);
// NewLine();
}
} while(GetNextParam());
}
else
{
if (table.row_h > table.row_max_h) table.row_max_h = table.row_h;
}
}
 
if(istag("tr")) {
if (opened)
{
table.cur_col = 0;
table.row_max_h = 0;
table.row_start = stroka;
}
else
{
NewLine();
if (table.cur_row == 0) table.max_cols = table.cur_col;
table.cur_row++;
table.max_cols = table.cur_col;
}
}
 
if (istag("br")) { NewLine(); return; }
if (istag("tr")) { if (opened) { NewLine(); strcat(#line, "| "); } return; }
if (istag("td")) || (istag("th")) { if (!opened) strcat(#line, " | "); return; }
if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; }
if (istag("i")) || (istag("em")) || (istag("subtitle")) { style.i=opened; return; }
if (istag("u")) || (istag("ins")) { style.u=opened; return;}
if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; }
if (istag("dd")) { stolbec += 5; return; }
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"))
{
481,7 → 415,7
return;
}
*/
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) {
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
NewLine();
if (opened) && (stroka>1) NewLine();
strcpy(#oldtag, #tag);
500,28 → 434,11
}
else
oldtag=NULL;
if (istag("b")) || (istag("strong")) || (istag("big")) {
style.b = opened;
return;
}
if(istag("i")) || (istag("em")) || (istag("subtitle")) {
style.i = opened;
return;
}
if (istag("dt"))
{
if (istag("dt")) {
style.li = opened;
IF(opened == 0) return;
NewLine();
if (opened) NewLine();
return;
}
if (istag("condition"))
{
condition_text_active = opened;
if (opened) && (isattr("show_if=")) condition_text_val = atoi(#val);
return;
}
if (istag("li")) || (istag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
{
style.li = opened;
534,19 → 451,16
}
return;
}
if (istag("u")) || (istag("ins")) style.u = opened;
if (istag("s")) || (istag("strike")) || (istag("del")) style.s = opened;
if (istag("ul")) || (istag("ol")) IF(!opened)
if (istag("ul")) || (istag("ol")) {
if (!opened)
{
style.li = opened;
style.li_tab--;
NewLine();
} ELSE style.li_tab++;
if (istag("dd")) stolbec += 5;
if (istag("blockquote")) style.blq = opened;
if (istag("pre")) || (istag("code")) style.pre = opened;
if (istag("hr"))
{
}
else style.li_tab++;
}
if (istag("hr")) {
if (anchor) || (stroka < -1)
{
stroka+=2;
557,26 → 471,18
DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
NewLine();
}
if (istag("img"))
{
ImgCache.Images( left1, top1, WB1.list.w);
return;
}
if (istag("meta")) || (istag("?xml"))
{
if (istag("meta")) || (istag("?xml")) {
do{
if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
{
strcpy(#val, #val[strrchr(#val, '=')]); //ïîèñê â content=
strlwr(#val);
meta_encoding = CH_NULL;
if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8;
else if (isval("koi8-r")) || (isval("koi8-u")) meta_encoding = CH_KOI8;
else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251;
else if (isval("windows-1252")) || (isval("windows1252")) meta_encoding = CH_CP1252;
else if (isval("iso-8859-5")) || (isval("iso8859-5")) meta_encoding = CH_ISO8859_5;
else if (isval("dos")) || (isval("cp-866")) meta_encoding = CH_CP866;
if (cur_encoding==CH_NULL) BufEncode(meta_encoding);
if (cur_encoding!=meta_encoding) BufEncode(meta_encoding);
return;
}
} while(GetNextParam());
584,7 → 490,7
}
}
 
void BufEncode(int set_new_encoding)
void TWebBrowser::BufEncode(int set_new_encoding)
{
int bufpointer_realsize;
cur_encoding = set_new_encoding;
597,11 → 503,7
{
strcpy(bufpointer, o_bufpointer);
}
if (set_new_encoding == CH_CP1251)
{
bufpointer = ChangeCharset("CP1251", "UTF-8", bufpointer);
}
}
//============================================================================================
void TWebBrowser::DrawScroller()
{
/programs/cmm/browser/WebView.c
30,7 → 30,7
char homepage[] = FROM "html\\homepage.htm";
 
#ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.22";
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.23";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
37,7 → 37,7
char page_not_found[] = FROM "html\page_not_found_ru.htm";
char accept_language[]= "Accept-Language: ru\n";
#else
char version[]=" Text-based Browser 1.22";
char version[]=" Text-based Browser 1.23";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...<br>";
308,6 → 308,7
address_box.width = Form.cwidth - address_box.left - 25 - 22;
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom,
Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
WB1.list.wheel_size = 7;
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
317,6 → 318,7
{
int img_off;
// tab {
/*
if (TAB_H)
{
DrawBar(0, 0, TAB_W, TAB_H+1, panel_color);
326,7 → 328,7
DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color);
img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0);
}
else DrawBar(0,0, Form.cwidth,1, col_bg);
else */ DrawBar(0,0, Form.cwidth,1, col_bg);
// }
DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color);
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
494,19 → 496,6
}
 
strcpy(#URL, PageLinks.GetURL(id-401));
//$1 - Condition Script
if (URL[0] == '$')
{
if (URL[1]=='-') && (condition_href) condition_href--;
else if (URL[1]=='+')
{
if (condition_href<condition_max) condition_href++; else notify(T_LAST_SLIDE);
}
else condition_href = atoi(#URL+1);
strcpy(#URL, BrowserHistory.CurrentUrl());
ShowPage();
return;
}
//#1
if (URL[0] == '#')
{
/programs/cmm/lib/list_box.h
12,6 → 12,7
int x, y, w, h, line_h, text_y;
dword font_w, font_h, font_type;
int count, visible, first, current, column_max; //visible = row_max
int wheel_size;
int active;
void ClearList();
int MouseOver(int xx, yy);
57,6 → 58,7
line_h = line_hh;
text_y = line_h - font_h / 2;
visible = h / line_h;
wheel_size = 3;
//if (visible > count) visible=count;
}
 
74,13 → 76,13
if (scroll_state == 65535)
{
if (first == 0) return 0;
if (first > 3) first -= 2; else first=0;
if (first > wheel_size+1) first -= wheel_size; else first=0;
return 1;
}
if (scroll_state == 1)
{
if (visible + first == count) return 0;
if (visible+first+3 > count) first = count - visible; else first+=2;
if (visible+first+wheel_size+1 > count) first = count - visible; else first+=wheel_size;
return 1;
}
return 0;