Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8015 → Rev 8016

/programs/cmm/TWB/TWB.c
18,6 → 18,7
struct _style {
bool
b, u, s, h,
font,
pre,
blq,
button,
30,6 → 31,7
struct TWebBrowser {
llist list;
_style style;
_img page_img;
dword draw_y, stolbec;
int zoom;
dword o_bufpointer;
95,8 → 97,8
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
}
 
text_color__ = text_colors[text_color_index];
if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
text_color__ = text_colors.get_last();
if (link) && (text_color__ == text_colors.get(0)) text_color__ = link_color_default;
 
DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
117,7 → 119,7
void TWebBrowser::SetPageDefaults()
{
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
link = text_color_index = text_colors[0] = style.tag_title = false;
link = style.tag_title = style.font = false;
style.tag_list.reset();
link_color_default = 0x0000FF;
link_color_active = 0xFF0000;
126,6 → 128,9
DrawBuf.Fill(0, page_bg);
links.clear();
anchors.clear();
page_img.clear();
text_colors.drop();
text_colors.add(0);
header = NULL;
cur_encoding = CH_CP866;
draw_y = BODY_MARGIN;
339,7 → 344,7
t_body = tag.opened;
if (value = tag.get_value_of("link=")) link_color_default = GetColor(value);
if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value);
if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value);
if (value = tag.get_value_of("text=")) text_colors.set(0, GetColor(value));
if (value = tag.get_value_of("bgcolor=")) {
style.bg_color = page_bg = GetColor(value);
DrawBuf.Fill(0, page_bg);
384,19 → 389,23
NewLine();
}
if (tag.is("font")) {
style.font = tag.opened;
style.bg_color = page_bg;
if (tag.opened)
{
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
if (value = tag.get_value_of("color=")) {
text_colors.add(GetColor(value));
} else {
text_colors.add(text_colors.get_last());
}
else if (text_color_index > 0) text_color_index--;
}
else text_colors.pop();
return;
}
if (tag.is("div")) {
if (streq(#tag.prior,"div")) && (tag.opened) return;
if (!tag.opened) && (style.font) text_colors.pop();
NewLine();
return;
}
435,8 → 444,8
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
if (!img_path) { line=0; return; }
style.image = true;
text_color_index++;
text_colors[text_color_index] = 0x9A6F29;
page_img.add(#img_path, stolbec+1*list.font_w+3, draw_y);
text_colors.add(0x9A6F29);
if (!line) {
if (!strncmp(#img_path, "data:", 5)) img_path=0;
replace_char(#img_path, '?', NULL, strlen(#img_path));
445,9 → 454,8
}
while (CheckForLineBreak()) {};
Paint();
text_color_index--;
text_colors.pop();
style.image = false;
//ImgCache.Images( list.x, draw_y, list.w);
return;
}
if (tag.is("h4")) {
591,5 → 599,6
void TWebBrowser::DrawPage()
{
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
page_img.draw(list.x, list.y, list.first, list.h);
DrawScroller();
}
/programs/cmm/TWB/colors.h
6,8 → 6,7
int rgb;
};
 
dword text_colors[300];
dword text_color_index;
collection_int text_colors;
 
struct color_spec color_specs[] = {
"aliceblue", 0xF0F8FF,
159,7 → 158,7
textlen=0;
char ch=0x00;
 
if (ESBYTE[htmlcolor]<>'#') return text_colors[0];
if (ESBYTE[htmlcolor]<>'#') return text_colors.get(0);
 
textlen = strlen(htmlcolor);
 
177,7 → 176,7
return color;
}
 
return text_colors[0];
return text_colors.get(0);
}
 
dword GetColor(char* color_str)
192,5 → 191,5
if (!strcmpi(color_str, color_specs[ii].name)) return color_specs[ii].rgb;
}
 
return text_colors[0];
return text_colors.get(0);
}
/programs/cmm/TWB/img.h
1,17 → 1,88
struct img
struct _img
{
collection src;
collection url;
collection_int xywh;
collection_int data;
collection_int xywh;
void drop();
int getid;
dword add();
void clear();
dword current_url();
bool next_url();
void set_data();
void draw();
};
 
void img::drop()
dword _img::add(dword _path, _x, _y)
{
src.drop();
char full_path[URL_SIZE];
strncpy(#full_path, _path, URL_SIZE);
GetAbsoluteURL(#full_path, history.current());
 
url.add(#full_path);
xywh.add(_x);
xywh.add(_y);
xywh.add(0);
xywh.add(0);
return full_path;
}
 
void _img::clear()
{
url.drop();
xywh.drop();
data.drop();
getid = 0;
}
 
dword _img::current_url()
{
return url.get(getid);
}
 
bool _img::next_url()
{
if (getid < url.count-1) {
getid++;
return 1;
}
return 0;
}
 
void _img::set_data(dword _data, _data_len)
{
data.set(getid, _data);
}
 
void DrawLibimgImage(dword _x, _y, _data, _data_len)
{
libimg_image im;
img_decode stdcall (_data, _data_len, 0);
$or eax, eax
$jz __ERROR__
im.image = EAX;
im.set_vars();
im.draw(_x, _y, im.w, im.h, 0, 0);
__ERROR__:
}
 
void _img::draw(int _x, _y, _start, _height)
{
int i, img_x, img_y;
 
for (i=0; i<url.count; i++)
{
img_x = xywh.get(i*4);
img_y = xywh.get(i*4 + 1);
 
if (img_y > _start) && (img_y < _start + _height)
{
if (cache.has(url.get(i)))
DrawLibimgImage(img_x + _x, img_y-_start + _y, cache.current_buf, cache.current_size);
}
}
}
 
/*
 
void ImageCache::Images(dword left1, top1, width1)
/programs/cmm/browser/WebView.c
1,8 → 1,6
//Copyright 2007-2020 by Veliant & Leency
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
 
//Licence restriction: compiling this app for WIN32 is forbidden.
 
#ifndef AUTOBUILD
#include "lang.h--"
#endif
32,6 → 30,10
#include "..\lib\patterns\toolbar_button.h"
#include "..\lib\patterns\restart_process.h"
 
#define URL_SIZE 4000
 
char version[]="WebView 2.65";
 
#include "texts.h"
#include "cache.h"
#include "show_src.h"
64,12 → 66,13
TAB_CLOSE_ID = 900
};
 
_history history;
 
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
 
#include "..\TWB\TWB.c" //HTML Parser, a core component
 
TWebBrowser WB1;
_history history;
 
#include "history.h"
 
79,10 → 82,6
#define TAB_H 20
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
 
#define URL_SIZE 4000
 
int action_buf;
 
_http http = 0;
 
bool source_mode = false;
106,6 → 105,8
 
dword shared_url;
 
dword http_get_type;
 
void LoadLibraries()
{
load_dll(boxlib, #box_lib_init,0);
202,7 → 203,7
break;
 
case evButton:
ProcessEvent( GetButtonID() );
ProcessEvent( @GetButtonID() );
break;
 
case evKey:
260,7 → 261,8
http.free();
GetAbsoluteURL(#http.redirect_url, history.current());
history.back();
OpenPage(#http.redirect_url);
if (http_get_type==PAGE) OpenPage(#http.redirect_url);
else if (http_get_type==IMG) http.get(#http.redirect_url);
} else {
notify("'Too many redirects.' -E");
StopLoading();
270,9 → 272,16
// Loading the page is complete, free resources
redirect_count = 0;
http.free();
pages_cache.add(history.current(), http.content_pointer, http.content_received);
if (http_get_type==PAGE) {
cache.add(history.current(), http.content_pointer, http.content_received, PAGE);
LoadInternalPage(http.content_pointer, http.content_received);
}
else if (http_get_type==IMG) {
cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG);
WB1.page_img.set_data(cache.data.get_last(), http.content_received);
GetImg();
}
}
break;
default:
if (ESDWORD[shared_url] != '\0') {
287,44 → 296,20
{
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:
ProcessEvent(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:
ProcessEvent(DOWNLOAD_MANAGER);
return true;
case SCAN_CODE_KEY_R:
ProcessEvent(REFRESH_BUTTON);
return true;
case SCAN_CODE_ENTER:
EventSeachWeb();
return true;
case SCAN_CODE_LEFT:
ProcessEvent(BACK_BUTTON);
return true;
case SCAN_CODE_RIGHT:
ProcessEvent(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 true;
case SCAN_CODE_KEY_H: ProcessEvent(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: ProcessEvent(DOWNLOAD_MANAGER); return true;
case SCAN_CODE_KEY_R: ProcessEvent(REFRESH_BUTTON); return true;
case SCAN_CODE_ENTER: EventSeachWeb(); return true;
case SCAN_CODE_LEFT: ProcessEvent(BACK_BUTTON); return true;
case SCAN_CODE_RIGHT: ProcessEvent(FORWARD_BUTTON); return true;
case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true;
case SCAN_CODE_TAB: EventActivateNextTab(); return true;
default: return false;
}
return false;
}
 
void SetElementSizes()
462,7 → 447,7
EventUpdateBrowser();
return;
case CLEAR_CACHE:
pages_cache.clear();
cache.clear();
notify(#clear_cache_ok);
EventRefreshPage();
return;
603,9 → 588,9
and then halndle it in the propper way.
*/
 
if (pages_cache.has(#new_url)) {
if (cache.has(#new_url)) {
//CACHED PAGE
LoadInternalPage(pages_cache.current_page_buf, pages_cache.current_page_size);
LoadInternalPage(cache.current_buf, cache.current_size);
 
} else if (!strncmp(#new_url,"WebView:",8)) {
//INTERNAL PAGE
620,6 → 605,7
strcpy(#editURL, #new_url);
}
 
http_get_type = PAGE;
if (!strncmp(#new_url,"http:",5)) {
http.get(#new_url);
} else if (!strncmp(#new_url,"https://",8)) {
779,6 → 765,7
} else {
WB1.DrawPage();
}
//GetImg();
}
}
 
941,6 → 928,9
ESI = math.min(status_w/6, strlen(links.active_url));
WriteText(10, status_y, 0, sc.work_text, links.active_url);
}
if (http.transfer>0) && (http_get_type==IMG) {
//
}
DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
}
983,4 → 973,16
return 0;
}
 
dword GetImg()
{
while (WB1.page_img.next_url()) {
if (cache.has(WB1.page_img.current_url())) continue;
http_get_type = IMG;
http.get(WB1.page_img.current_url());
return;
}
DrawOmnibox();
WB1.DrawPage();
}
 
stop:
/programs/cmm/browser/cache.h
1,17 → 1,21
enum {
PAGE=1, IMG
};
 
struct PAGES_CACHE
struct _cache
{
dword current_page_buf;
dword current_page_size;
dword current_buf;
dword current_size;
collection url;
collection_int data;
collection_int size;
collection_int type;
void add();
bool has();
void clear();
} pages_cache=0;
} cache=0;
 
void PAGES_CACHE::add(dword _url, _data, _size)
void _cache::add(dword _url, _data, _size, _type)
{
dword data_pointer;
data_pointer = malloc(_size);
20,25 → 24,26
 
url.add(_url);
size.add(_size);
type.add(_type);
}
 
bool PAGES_CACHE::has(dword _link)
bool _cache::has(dword _link)
{
int pos;
pos = url.get_pos_by_name(_link);
if (pos != -1) {
current_page_buf = data.get(pos);
current_page_size = size.get(pos);
current_buf = data.get(pos);
current_size = size.get(pos);
return true;
}
return false;
}
 
void PAGES_CACHE::clear()
void _cache::clear()
{
url.drop();
data.drop();
size.drop();
current_page_buf = NULL;
current_page_size = NULL;
current_buf = NULL;
current_size = NULL;
}
/programs/cmm/browser/history.h
30,7 → 30,7
free(history_pointer);
history_pointer = malloc(history.items.data_size+256);
strcat(history_pointer, HISTORY_HEADER);
for (i=0; i<history.items.count-1; i++)
for (i=0; i<history.items.count-1; i++) //if (cache.type.get(i) == PAGE)
{
strcat(history_pointer, "\t<a href='");
strcat(history_pointer, history.items.get(i));
38,14 → 38,14
strcat(history_pointer, history.items.get(i));
strcat(history_pointer, "</a><br>");
}
/*
 
strcat(history_pointer, "<br><b>Cached images</b><br>");
for (i=1; i<ImgCache.pics_count; i++)
for (i=1; i<cache.url.count; i++) if (cache.type.get(i) == IMG)
{
strcat(history_pointer, "<a href='");
strcat(history_pointer, #pics[i].path);
strcat(history_pointer, cache.url.get(i));
strcat(history_pointer, "'>");
strcat(history_pointer, #pics[i].path);
strcat(history_pointer, cache.url.get(i));
strcat(history_pointer, "</a><br>");
// strcat(history_pointer, "<img src='");
53,7 → 53,7
// strcat(history_pointer, "'><br>");
// strcat(history_pointer, #pics[i].path);
}
*/
 
strcat(history_pointer, "</body></html>");
LoadInternalPage(history_pointer, strlen(history_pointer));
}
/programs/cmm/browser/texts.h
1,5 → 1,3
char version[]="WebView 2.61b";
 
#ifdef LANG_RUS
char buidin_page_error[] = FROM "buidin_pages\\page_not_found_ru.htm""\0";
char buidin_page_home[] = FROM "buidin_pages\\homepage_ru.htm""\0";