Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8499 → Rev 8500

/programs/cmm/browser/TWB/TWB.c
56,6 → 56,7
 
void SetPageDefaults();
void ParseHtml();
void Reparse();
void NewLine();
void ChangeEncoding();
void AddCharToTheLine();
110,6 → 111,11
tag_table_reset();
}
//============================================================================================
void TWebBrowser::Reparse()
{
ParseHtml(bufpointer, bufsize);
}
//============================================================================================
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
int tab_len;
dword bufpos;
223,25 → 229,6
}
}
//============================================================================================
void TWebBrowser::NewLine()
{
static bool empty_line = true;
 
if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return;
if (t_html) && (!t_body) return;
if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
if (!empty_line) empty_line=true; else return;
} else {
empty_line = false;
}
 
draw_y += style.cur_line_h;
style.cur_line_h = list.item_h;
if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0;
draw_x += style.tag_list.level * 5 * list.font_w + left_gap;
}
//============================================================================================
void TWebBrowser::ChangeEncoding(int _new_encoding)
{
if (cur_encoding == _new_encoding) return;
258,9 → 245,7
 
void TWebBrowser::DrawPage()
{
if (list.w!=canvas.bufw) {
ParseHtml(bufpointer, bufsize);
}
if (list.w!=canvas.bufw) Reparse();
canvas.Show(list.first, list.h);
 
scroll_wv.max_area = list.count;
/programs/cmm/browser/TWB/parse_tag.h
7,11 → 7,13
collection attributes;
collection values;
dword value;
dword number;
bool is();
bool parse();
void debug_tag();
dword get_next_param();
dword get_value_of();
signed get_number_of();
} tag=0;
 
bool _tag::is(dword _text)
207,3 → 209,13
}
return value;
}
 
signed _tag::get_number_of(dword _attr_name)
{
if (get_value_of(_attr_name)) {
number = atoi(tag.value);
} else {
number = 0;
}
return number;
}
/programs/cmm/browser/TWB/render.h
1,6 → 1,6
CANVAS canvas;
 
void TWebBrowser::RenderLine()
void TWebBrowser::RenderLine(dword _line)
{
unsigned px; //paint x coordinate
unsigned pw; //paint y coordinate
9,22 → 9,28
 
if (style.title)
{
strncpy(#header, #linebuf, sizeof(TWebBrowser.header)-1);
strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
strncat(#header, #version, sizeof(TWebBrowser.header)-1);
linebuf = 0;
return;
}
if (t_html) && (!t_body) {
linebuf = 0;
return;
else if (t_html) && (!t_body) {
//
}
if (linebuf)
else if (ESBYTE[_line])
{
pw = strlen(#linebuf) * list.font_w;
pw = strlen(_line) * list.font_w;
zoom = list.font_w / BASIC_CHAR_W;
 
if (pw > draw_w) {
draw_w = pw;
NewLine();
}
 
if (debug_mode) {
canvas.DrawBar(draw_x, draw_y, pw, list.item_h, 0xCCCccc);
debugln(_line);
}
 
style.cur_line_h = math.max(style.cur_line_h, list.item_h);
 
if (bg_colors.get_last() - bg_colors.get(0)) {
42,65 → 48,83
pc = text_colors.get_last();
if (link) && (pc == text_colors.get(0)) pc = link_color_default;
 
canvas.WriteText(draw_x, draw_y, list.font_type, pc, #linebuf, NULL);
if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, #linebuf, NULL);
canvas.WriteText(draw_x, draw_y, list.font_type, pc, _line, NULL);
if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, _line, NULL);
if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc);
if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc);
if (link) {
if (linebuf[0]==' ') && (linebuf[1]==NULL) {} else {
if (ESBYTE[_line]==' ') && (ESBYTE[_line+1]==NULL) {} else {
canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default);
links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);
}
}
draw_x += pw;
if (debug_mode) debugln(#linebuf);
}
linebuf = NULL;
ESBYTE[_line] = NULL;
}
 
 
void TWebBrowser::RenderTextbuf()
{
int break_pos;
char next_line[sizeof(TWebBrowser.linebuf)];
int zoom = list.font_w / BASIC_CHAR_W;
dword lbp = #linebuf;
int br; //break position
char nul = '\0';
int len;
 
//Do we need a line break?
while (strlen(#linebuf) * list.font_w + draw_x >= draw_w) {
while (len = strlen(lbp)) && (len * list.font_w + draw_x >= draw_w) {
//Yes, we do. Lets calculate where...
break_pos = strrchr(#linebuf, ' ');
br = strrchr(lbp, ' ');
 
//Is a new line fits in the current line?
if (break_pos * list.font_w + draw_x > draw_w) {
break_pos = draw_w - draw_x /list.font_w;
while(break_pos) {
if (linebuf[break_pos]==' ') {
break_pos++;
if (br * list.font_w + draw_x >= draw_w) {
br = draw_w - draw_x /list.font_w;
while(br) {
if (ESBYTE[lbp + br]==' ') {
br++;
break;
}
break_pos--;
br--;
}
}
//Maybe a new line is too big for the whole new line? Then we have to split it
if (!break_pos) && (style.tag_list.level*5 + strlen(#linebuf) * zoom >= list.column_max) {
break_pos = draw_w - draw_x / list.font_w;
if (!br) && (len * list.font_w >= draw_w) {
br = draw_w - draw_x / list.font_w;
}
 
 
if (break_pos) {
strlcpy(#next_line, #linebuf + break_pos, sizeof(next_line));
linebuf[break_pos] = 0x00;
RenderLine();
strlcpy(#linebuf, #next_line, sizeof(TWebBrowser.linebuf));
NewLine();
if (br) {
ESBYTE[lbp + br] >< nul;
RenderLine(lbp);
ESBYTE[lbp + br] >< nul;
lbp += br;
while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++;
if (ESBYTE[lbp]) NewLine();
} else {
NewLine();
RenderLine();
RenderLine(lbp);
}
}
RenderLine();
RenderLine(lbp);
}
 
void TWebBrowser::NewLine()
{
static bool empty_line = true;
 
if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return;
if (t_html) && (!t_body) return;
if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
if (!empty_line) empty_line=true; else return;
} else {
empty_line = false;
}
 
draw_y += style.cur_line_h;
style.cur_line_h = list.item_h;
if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0; //left_gap += style.tag_list.level * 5 * list.font_w ???
draw_x += style.tag_list.level * 5 * list.font_w + left_gap;
}
 
bool TWebBrowser::RenderImage(dword cur_img)
{
int img_x, img_y, img_w, img_h;
/programs/cmm/browser/TWB/set_style.h
11,7 → 11,7
if (tag.is("p")) { tag_p(); return; }
if (tag.is("img")) { tag_img(); return; }
if (tag.is("div")) { tag_div(); return; }
if (tag.is("br")) { NewLine(); return; }
if (tag.is("br")) { /*draw_x++;*/NewLine(); return; }
if (tag.is("header")) { NewLine(); return; }
if (tag.is("article")) { NewLine(); return; }
if (tag.is("footer")) { NewLine(); return; }
202,6 → 202,7
if (tag.get_value_of("color")) hrcol = GetColor(tag.value);
if (draw_x != left_gap) NewLine();
canvas.DrawBar(5, style.cur_line_h / 2 + draw_y - 1, draw_w-10, 1, hrcol);
draw_x++;
NewLine();
return;
}
319,47 → 320,56
 
 
 
int tdepth;
int col_n;
 
 
struct TABLE {
int count;
int col;
collection_int cx;
collection_int col_w;
collection_int col_span;
collection_int row_h;
int row_y, next_row_y;
} table;
int colcount;
} t[5];
 
void TWebBrowser::tag_table_reset()
{
table.count = 0;
table.cx.drop();
table.row_y = 0;
table.next_row_y = 0;
int i;
tdepth = 0;
for (i=0; i<5; i++) {
t[i].col_w.drop();
t[i].row_h.drop();
t[i].col_span.drop();
t[i].row_y = 0;
t[i].next_row_y = 0;
}
}
 
void TWebBrowser::tag_table()
{
if (tag.opened) {
if (!table.count) {
table.next_row_y = table.row_y = draw_y;
if (tdepth==0) {
t[0].next_row_y = t[0].row_y = draw_y;
}
table.count++;
tdepth++;
} else {
table.count--;
if (!table.count) {
draw_y = math.max(draw_y + style.cur_line_h, table.next_row_y);
tdepth--;
if (tdepth==0) {
draw_y = math.max(draw_y + style.cur_line_h, t[0].next_row_y);
left_gap = BODY_MARGIN;
draw_w = list.w - BODY_MARGIN;
}
}
}
 
void TWebBrowser::tag_tr()
:void TWebBrowser::tag_tr()
{
if (tag.opened) {
if (table.count>1) {
if (tdepth>1) {
NewLine();
} else {
table.col = 0;
table.row_y = math.max(draw_y + style.cur_line_h, table.next_row_y);
t[0].colcount = math.max(t[0].colcount, col_n);
col_n = 0;
t[0].row_y = math.max(draw_y + style.cur_line_h, t[0].next_row_y);
left_gap = BODY_MARGIN;
NewLine();
}
366,29 → 376,36
}
}
 
void TWebBrowser::tag_td()
:void TWebBrowser::tag_td()
{
if (table.count>1) return;
if (tdepth>1) return;
if (tag.opened) {
table.next_row_y = math.max(draw_y + style.cur_line_h, table.next_row_y);
draw_y = table.row_y;
table.cx.set(table.col, math.max(draw_x,table.cx.get(table.col)) );
draw_x = left_gap = table.cx.get(table.col);
table.col++;
if (tag.get_value_of("width")) {
draw_w = EAX;
//debugval("draw_w", atoi(tag.value));
table.cx.set(table.col, draw_x + atoi(tag.value));
 
t[0].next_row_y = math.max(draw_y + style.cur_line_h, t[0].next_row_y);
style.cur_line_h = list.item_h;
t[0].col_w.set(col_n, math.max(draw_x,t[0].col_w.get(col_n)) );
draw_x = left_gap = t[0].col_w.get(col_n);
draw_w = list.w - left_gap;
draw_y = t[0].row_y;
if (tag.get_number_of("width")) {
if (!strchr(tag.value, '%')) {
draw_w = tag.number;
} else {
if (tag.number < 100) {
draw_w = draw_w - left_gap * tag.number / 100;
if (draw_w > list.w - left_gap) draw_w = list.w - left_gap;
}
//if (tag.get_value_of("height")) table.next_row_y = draw_y + atoi(tag.value);
}
}
col_n++;
t[0].col_w.set(col_n, draw_x + draw_w);
 
if (left_gap >= list.w - list.font_w - 10) {
debugln("left_gap overflow");
draw_x = left_gap = BODY_MARGIN;
table.cx.drop();
table.count = 999;
t[0].col_w.drop();
NewLine();
canvas.WriteText(draw_x, draw_y, 10011001b, 0xFE0000, "lgo", NULL);
}
 
if (draw_w < 0) || (draw_w >= list.w) {
396,5 → 413,8
draw_x = left_gap = BODY_MARGIN;
draw_w = list.w - left_gap;
NewLine();
canvas.WriteText(draw_x, draw_y, 10011001b, 0x0000FE, "drwo", NULL);
}
}
 
}
/programs/cmm/browser/WebView.c
149,9 → 149,10
}
}
 
if (links.hover(WB1.list.y, WB1.list.first))
if (WB1.list.MouseOver(mouse.x, mouse.y)) && (links.hover(WB1.list.y, WB1.list.first))
{
if (mouse.key&MOUSE_MIDDLE) && (mouse.up) {
GetKeyModifier();
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
EventClickLink(TARGET_NEW_WINDOW);
} else {
298,29 → 299,30
}
}
 
bool ProcessKeyEvent()
void ProcessKeyEvent()
{
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT)
{
if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();return;}
if (key_scancode == SCAN_CODE_KEY_T) {EventOpenNewTab(URL_SERVICE_TEST);return;}
}
 
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode)
{
case SCAN_CODE_KEY_O: EventOpenDialog(); return true;
case SCAN_CODE_KEY_H: ProcessButtonClick(VIEW_HISTORY); return true;
case SCAN_CODE_KEY_U: EventViewSource(); return true;
case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true;
case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true;
case SCAN_CODE_KEY_J: ProcessButtonClick(DOWNLOAD_MANAGER); return true;
case SCAN_CODE_KEY_R: ProcessButtonClick(REFRESH_BUTTON); return true;
case SCAN_CODE_ENTER: EventSeachWeb(); return true;
case SCAN_CODE_LEFT: ProcessButtonClick(BACK_BUTTON); return true;
case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true;
case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true;
case SCAN_CODE_TAB: EventActivateNextTab(); return true;
case SCAN_CODE_KEY_O: EventOpenDialog(); return;
case SCAN_CODE_KEY_H: ProcessButtonClick(VIEW_HISTORY); return;
case SCAN_CODE_KEY_U: EventViewSource(); return;
case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return;
case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return;
case SCAN_CODE_KEY_J: ProcessButtonClick(DOWNLOAD_MANAGER); return;
case SCAN_CODE_KEY_R: ProcessButtonClick(REFRESH_BUTTON); return;
case SCAN_CODE_ENTER: EventSeachWeb(); return;
case SCAN_CODE_LEFT: ProcessButtonClick(BACK_BUTTON); return;
case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return;
case SCAN_CODE_KEY_W: EventCloseActiveTab(); return;
case SCAN_CODE_TAB: EventActivateNextTab(); return;
case SCAN_CODE_F5: EventClearCache(); return;
default: return false;
default: return;
}
 
switch(key_scancode)
371,7 → 373,7
WB1.list.h-1, scroll_wv.bckg_col);
 
if (!canvas.bufw) {
OpenPage(history.current());
EventOpenFirstPage();
} else {
WB1.DrawPage();
DrawOmnibox();
381,6 → 383,11
DrawTabsBar();
}
 
void EventOpenFirstPage()
{
OpenPage(history.current());
}
 
void EventManuallyChangeEncoding(int _new_encoding)
{
dword newbuf, newsize;
921,12 → 928,13
 
void HandleRedirect()
{
char redirect_url[URL_SIZE];
http.header_field("location", #redirect_url, URL_SIZE);
get_absolute_url(#redirect_url, http.cur_url);
dword redirect_url = malloc(URL_SIZE);
http.header_field("location", redirect_url, URL_SIZE);
get_absolute_url(redirect_url, http.cur_url);
http.hfree();
if (http_get_type==PAGE) OpenPage(#redirect_url);
else if (http_get_type==IMG) GetUrl(#redirect_url);
if (http_get_type==PAGE) OpenPage(redirect_url);
else if (http_get_type==IMG) GetUrl(redirect_url);
free(redirect_url);
}
 
dword GetImg(bool _new)
948,7 → 956,7
if (_new) return;
DrawOmnibox();
DrawStatusBar(T_RENDERING);
WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
WB1.Reparse();
WB1.DrawPage();
debugln(sprintf(#param, T_DONE_IN_SEC, GetStartTime()-render_start_time/100));
DrawStatusBar(NULL);
/programs/cmm/browser/const.h
107,4 → 107,4
 
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
 
char version[]="WebView 3.30";
char version[]="WebView 3.31";
/programs/cmm/browser/res/help_en.htm
1,8 → 1,8
<html><head><title>WebView Help</title></head><body>
<html><title>WebView Help</title><body>
 
<h1>WebView Text-Based Browser</h1>
 
It is free and open-source. If you have any suggestions or want to help improving it please visit its topic at <a href="http://board.kolibrios.org/viewtopic.php?f=40&amp;t=1075">board.kolibrios.org</a><pre>
It is free and open-source. If you have any suggestions or want to help improving it please visit its topic at <a href="//board.kolibrios.org/viewtopic.php?f=40&amp;t=1075">board.kolibrios.org</a><pre>
 
<b>Shortcut keys</b>
 
/programs/cmm/browser/res/help_ru.htm
1,10 → 1,7
<html>
<head>
<meta charset="cp-866">
<title>‘¯à ¢ª  WebView</title>
</head>
<body><pre><h1>‘¯à ¢ª  WebView</h1>
 
<b>Š« ¢¨è¨ ¡ëáâண® ¢ë§®¢ </b>
 
<font bg=C7CEE4>[CTRL + N ¨«¨ CTRL + T]</font> ®¢®¥ ®ª­®
/programs/cmm/browser/res/homepage_en.htm
1,12 → 1,11
<html>
<head>
<meta charset="uft">
<title>Homepage</title>
</head>
<body><pre>Bookmarks:
1. <a href=http://kolibrios.org>KolibriOS homepage</a>
2. <a href=http://kolibri-n.org>KolibriN homepage</a>
3. <a href="http://store.kolibri-n.org">Kolibri Stuff</a>
1. <a href=//kolibrios.org>KolibriOS homepage</a>
2. <a href=//kolibri-n.org>KolibriN homepage</a>
3. <a href="//store.kolibri-n.org">Kolibri Stuff</a>
 
<font bg=#F8F15B>By the way,</font>
<font color="#555555">&bull; You can check for browser updates from the main menu.
/programs/cmm/browser/res/homepage_ru.htm
4,9 → 4,9
<title>„®¬ è­ïï áâà ­¨æ </title>
</head>
<body><pre>‡ ª« ¤ª¨:
1. <a href=http://kolibrios.org>„®¬ è­ïï áâà ­¨æ  KolibriOS</a>
2. <a href=http://kolibri-n.org>KolibriN10</a>
3. <a href="http://store.kolibri-n.org">Kolibri Store</a>
1. <a href=//kolibrios.org>„®¬ è­ïï áâà ­¨æ  KolibriOS</a>
2. <a href=//kolibri-n.org>KolibriN10</a>
3. <a href="//store.kolibri-n.org">Kolibri Store</a>
 
<font bg=#F8F15B>Šáâ â¨,</font>
<font color="#555555">&bull; ˆ§ £« ¢­®£® ¬¥­î ¬®¦­® ¯à®¢¥à¨âì ­ «¨ç¨¥ ®¡­®¢«¥­¨©
/programs/cmm/browser/res/test.htm
1,27 → 1,27
<html>
<head><title>WebView Test Page</title></head>
<title>TEST</title>
<body>
<pre>
<a href=http://kolibrios.org>KolibriOS</a>
<a href=http://kolibri-n.org>KolibriN10</a>
<a href=http://store.kolibri-n.org>Kolibri Store</a>
<a href=//kolibrios.org>KolibriOS</a>
<a href=//kolibri-n.org>KolibriN10</a>
<a href=//store.kolibri-n.org>Kolibri Store</a>
 
<a href=http://os-menuet.narod.ru>os-menuet.narod.ru</a>
<a href=http://coolthemes.narod.ru/indexold.html>coolthemes.narod.ru</a>
<a href=http://www.fdd5-25.net/index.htm>fdd5-25.net</a>
<a href=http://www.mestack.narod.ru/index.html>mestack.narod.ru</a>
<a href=http://dgmag.in>dgmag.in</a>
<a href=http://baravy.by/me/b.html>http://baravy.by/me/b.html</a>
<a href=//os-menuet.narod.ru>os-menuet.narod.ru</a>
<a href=//coolthemes.narod.ru/indexold.html>coolthemes.narod.ru</a>
<a href=//www.fdd5-25.net/index.htm>fdd5-25.net</a>
<a href=//www.mestack.narod.ru/index.html>mestack.narod.ru</a>
<a href=//dgmag.in>dgmag.in</a>
<a href=//baravy.by/me/b.html>baravy.by/me/b.html</a>
 
<a href=http://www.artcon.ru>artcon.ru</a>
<a href=https://acmp.ru/index.asp?main=tasks>acmp.ru</a>
<a href=http://edition.cnn.com/EVENTS/1996/year.in.review>cnn 1996</a>
<a href=https://vetusware.com>vetusware.com</a>
<a href=http://old-dos.ru>old-dos.ru</a>
<a href=http://nubo.ru>nubo.ru</a>
<a href=http://samlib.ru/b>samlib.ru/b</a>
<a href=//www.artcon.ru>artcon.ru</a>
<a href=//acmp.ru/index.asp?main=tasks>acmp.ru</a>
<a href=//edition.cnn.com/EVENTS/1996/year.in.review>cnn 1996</a>
<a href=//vetusware.com>vetusware.com</a>
<a href=//old-dos.ru>old-dos.ru</a>
<a href=//nubo.ru>nubo.ru</a>
<a href=//samlib.ru/b>samlib.ru/b</a>
 
<a href=http://umvirt.com/coins>UmVirt Conis</a>
<a href=http://linux.org.ru>LOR</a>
<a href=http://opennet.ru>opennet</a>
<a href=https://bash.im>bash.im</a>
<a href=//umvirt.com/coins/>UmVirt Conis</a>
<a href=//linux.org.ru>LOR</a>
<a href=//opennet.ru>opennet</a>
<a href=//bash.im>bash.im</a>
/programs/cmm/browser/tabs.h
147,7 → 147,7
tab.close(_id);
tab.restore(tab.active);
SetElementSizes();
WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
WB1.Reparse();
WB1.DrawPage();
SetOmniboxText(history.current());
} else {
170,7 → 170,7
tab.restore(_id);
DrawTabsBar();
SetElementSizes();
WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
WB1.Reparse();
WB1.DrawPage();
SetOmniboxText(history.current());
DrawStatusBar(NULL);