Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7756 → Rev 7757

/programs/cmm/TWB/TWB.c
2,8 → 2,12
#include "..\TWB\anchors.h"
#include "..\TWB\parce_tag.h"
#include "..\TWB\absolute_url.h"
char line[500];
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
dword page_bg;
dword link_color_inactive;
dword link_color_active;
#include "..\TWB\links.h"
 
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
 
39,15 → 43,10
void BufEncode();
} WB1;
 
dword page_bg;
#include "..\TWB\img_cache.h"
char line[500];
 
dword link_color_inactive;
dword link_color_active;
 
bool link, cur_encoding, t_html, t_body;
 
#include "..\TWB\links.h"
 
dword bufpointer=0;
dword bufsize=0;
57,7 → 56,7
int body_magrin=6;
int basic_line_h=22;
 
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,15,0,0xeeeeee,0xBBBbbb,0xeeeeee};
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
 
//============================================================================================
void TWebBrowser::DrawStyle()
128,8 → 127,10
stolbec = 0;
line = 0;
zoom = 1;
if (o_bufpointer) free(o_bufpointer);
o_bufpointer = 0;
//hold original buffer
if (o_bufpointer) o_bufpointer=free(o_bufpointer);
o_bufpointer = malloc(bufsize);
memmov(o_bufpointer, bufpointer, bufsize);
}
//============================================================================================
void TWebBrowser::AddCharToTheLine(unsigned char _char)
187,7 → 188,7
bukva = ESBYTE[bufpos+j];
chrcat(#unicode_symbol, bukva);
}
if (bukva = GetUnicodeSymbol(#unicode_symbol)) {
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) {
bufpos += j;
CheckForLineBreak();
} else {
242,7 → 243,7
if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!!
if (tag.params) tag.parse_params();
 
if (tag.name) && (!tag.is("i")) && (!tag.is("svg")) {
if (tag.name) {
CheckForLineBreak();
DrawStyle();
if (tag.name) SetStyle();
305,7 → 306,7
return;
}
IF(tag.is("q"))
if (tag.is("q"))
{
if (tag.opened) {
meta_encoding = strlen(#line);
384,6 → 385,7
return;
}
if (tag.is("br")) { NewLine(); return; }
if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; }
if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
459,7 → 461,7
if (tag.is("ul")) || (tag.is("ol")) {
if (!tag.opened)
{
style.li = tag.opened;
style.li = false;
style.li_tab--;
NewLine();
}
495,18 → 497,11
//============================================================================================
void TWebBrowser::BufEncode(dword set_new_encoding)
{
if (cur_encoding == set_new_encoding) return;
if (o_bufpointer==0) {
o_bufpointer = malloc(bufsize);
strcpy(o_bufpointer, bufpointer);
} else {
strcpy(bufpointer, o_bufpointer);
}
//debugval("cur_encoding ", cur_encoding);
//debugval("set_new_encoding", set_new_encoding);
if (cur_encoding != set_new_encoding) {
cur_encoding = set_new_encoding;
bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
}
}
//============================================================================================
void TWebBrowser::DrawScroller()
{
/programs/cmm/TWB/absolute_url.h
1,40 → 1,33
 
dword GetAbsoluteURL(dword in_URL)
:dword GetAbsoluteURL(dword new_URL, base_URL)
{
int i;
dword orig_URL = in_URL;
dword orig_URL = new_URL;
char newurl[URL_SIZE+1];
strcpy(#newurl, base_URL);
 
while (i=strstr(in_URL, "&"))
while (i=strstr(new_URL, "&"))
{
strcpy(i+1, i+5);
}
 
if (check_is_the_url_absolute(in_URL)) return orig_URL;
if (check_is_the_url_absolute(new_URL)) return orig_URL;
 
IF (!strncmp(in_URL,"//", 2))
IF (!strncmp(new_URL,"//", 2))
{
strcpy(#newurl, "http:");
strcat(#newurl, in_URL);
strcat(#newurl, new_URL);
strcpy(orig_URL, #newurl);
return orig_URL;
}
IF (!strncmp(in_URL,"./", 2)) in_URL+=2;
if (!http.transfer)
{
strcpy(#newurl, history.current());
}
else
{
strcpy(#newurl, history.items.get(history.active-2));
}
IF (!strncmp(new_URL,"./", 2)) new_URL+=2;
 
if (ESBYTE[in_URL] == '/') //remove everything after site domain name
if (ESBYTE[new_URL] == '/') //remove everything after site domain name
{
i = strchr(#newurl+8, '/');
if (i) ESBYTE[i]=0;
in_URL+=1;
new_URL+=1;
}
_CUT_ST_LEVEL_MARK:
44,9 → 37,9
newurl[strrchr(#newurl, '/')] = 0x00;
}
IF (!strncmp(in_URL,"../",3))
IF (!strncmp(new_URL,"../",3))
{
in_URL+=3;
new_URL+=3;
newurl[strrchr(#newurl, '/')-1] = 0x00;
goto _CUT_ST_LEVEL_MARK;
}
53,7 → 46,7
if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
strcat(#newurl, in_URL);
strcat(#newurl, new_URL);
strcpy(orig_URL, #newurl);
return orig_URL;
}
/programs/cmm/TWB/img_cache.h
52,7 → 52,9
imgh = DSWORD[pics[cur_pic].image+8];
if (imgw > width1) imgw = width1;
//draw_y += imgh + 5; TEMPORARY TURN OFF!!!
/*
draw_y += imgh + 5; TEMPORARY TURN OFF!!!
if (top1+imgh<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //if all image is out of visible area
if (top1<WB1.list.y) //if image partly visible (at the top)
{
69,7 → 71,6
img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first);
DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, page_bg);
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, page_bg);
/*
if (link)
{
UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
/programs/cmm/TWB/links.h
9,7 → 9,8
 
struct array_link {
dword link;
int x,y,w,h;
unsigned int x,y,w,h;
unsigned int unic_id;
int underline, underline_h;
};
 
16,13 → 17,15
struct LinksArray {
array_link links[MAXLINKS];
collection page_links;
int count;
int active;
unsigned int count;
unsigned int unic_count;
unsigned int active;
bool HoverAndProceed();
void AddLink();
void AddText();
dword GetURL();
void Clear();
void DrawUnderline();
} PageLinks;
 
void LinksArray::AddLink(dword lpath)
29,6 → 32,7
{
if (count>= MAXLINKS) return;
page_links.add(lpath);
unic_count++;
}
 
void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h)
41,6 → 45,7
links[count].underline = _link_underline;
links[count].underline_h = _underline_h;
links[count].link = page_links.get(page_links.count-1);
links[count].unic_id = unic_count;
count++;
}
 
55,12 → 60,24
page_links.realloc_size = 4096 * 32;
count = 0;
active = -1;
unic_count = 0;
CursorPointer.Restore();
}
 
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
{
int i;
for (i=0; i<count; i++)
{
if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
}
}
}
 
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
 
bool LinksArray::HoverAndProceed(dword mx, my)
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
{
int i;
if (!count) return true;
68,10 → 85,10
{
if (mx>links[i].x) && (my>links[i].y)
&& (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
&& (my>WB1.list.y+WB1.list.first)
&& (my>list_y+list_first)
{
if (mouse.lkm) && (mouse.down) {
DrawRectangle(links[active].x, -WB1.list.first + links[active].y,
DrawRectangle(links[active].x, -list_first + links[active].y,
links[active].w, links[active].h, 0);
return false;
}
91,10 → 108,15
if (active==i) return false;
CursorPointer.Load(#CursorFile);
CursorPointer.Set();
if (links[active].underline) DrawUnderline(links[active].x, -WB1.list.first + links[active].y
+ links[active].h, links[active].w, links[active].underline_h, link_color_inactive);
if (links[i].underline) DrawUnderline(links[i].x, -WB1.list.first + links[i].y
+ links[i].h, links[i].w, links[i].underline_h, page_bg);
 
if (links[active].underline) {
DrawUnderline(active, list_first, list_y, link_color_inactive);
}
 
if (links[i].underline) {
DrawUnderline(i, list_first, list_y, page_bg);
}
 
active = i;
DrawStatusBar(links[active].link);
return true;
104,15 → 126,10
{
CursorPointer.Restore();
if (links[active].underline) {
DrawUnderline(links[active].x, -WB1.list.first + links[active].y + links[active].h,links[active].w,
links[active].underline_h, link_color_inactive);
DrawUnderline(active, list_first, list_y, link_color_inactive);
}
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
DrawStatusBar(NULL);
active = -1;
}
}
 
void DrawUnderline(dword x,y,w,h,color)
{
if (y>WB1.list.y) DrawBar(x,y,w,h,color);
}
/programs/cmm/TWB/unicode_tags.h
1,14 → 1,9
char *unicode_symbols[]={
"#32", " ",
"#34", "\"", "quot","\"",
"#38", "&", "amp", "&",
"#39", "'",
"#039","'",
"#60", "<", "lt", "<",
"#62", ">", "gt", ">",
"#91", "[",
"#93", "]",
"#96", "'",
"quot","\"",
"amp", "&",
"lt", "<",
"gt", ">",
"#183","\31", "middot", "\31",
"#149","-",
"#151","-",
"#160"," ", "nbsp", " ",
32,11 → 27,13
 
"#8211", "-",
"#8217", "'",
"#8220", "\"",
"#8222", "\"", "ldquo", "\"",
"#8221", "\"", "rdquo", "\"",
"#8470", "N",
"#8722", "-",
"#9642", "-", //square in the middle of the line
"#65122", "+",
 
"uarr", "\24",
"darr", "\25",
53,34 → 50,32
 
unsigned char unicode_chars[] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
 
bool GetUnicodeSymbol(dword in_tag)
bool GetUnicodeSymbol(dword _line, in_tag, size)
{
int j, specia1040;
int j;
int code;
for (j=0; unicode_symbols[j]!=0; j+=2;)
{
if (!strcmp(in_tag, unicode_symbols[j]))
{
strcat(#line, unicode_symbols[j+1]);
strncat(_line, unicode_symbols[j+1], size);
return true;
}
}
 
specia1040 = atoi(in_tag + 1) - 1040;
if (ESBYTE[in_tag+1] == '1') && (specia1040>=0)
&& (specia1040<=72) && (strlen(in_tag) == 5)
if (ESBYTE[in_tag]=='#')
{
if (strlen(#line)<sizeof(line)-2) {
/*
j = strlen(#line);
line[j] = unicode_chars[specia1040];
line[j+1] = EOS;
*/
chrcat(#line, unicode_chars[specia1040]);
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;
}
/programs/cmm/aelia/aelia.c
23,6 → 23,8
#include "canvas.h"
#include "favicon.h"
 
_history history;
 
char default_dir[] = "/rd/1";
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
 
/programs/cmm/browser/WebView.c
23,13 → 23,26
#include "..\lib\obj\http.h"
#include "..\lib\obj\iconv.h"
#include "..\lib\obj\proc_lib.h"
 
//useful patterns
#include "..\lib\patterns\history.h"
#include "..\lib\patterns\http_downloader.h"
#include "..\lib\patterns\simple_open_dialog.h"
 
#include "show_src.h"
_http http = {0, 0, 0, 0, 0, 0, 0};
#include "download_manager.h"
_history history;
#include "history.h"
 
bool debug_mode = false;
dword col_bg = 0xE3E2E2;
dword panel_color = 0xE3E2E2;
dword border_color = 0x787878;
#include "..\TWB\TWB.c"
 
#ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 2.0 beta2";
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 2.0 beta4";
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
char homepage[] = FROM "html\\homepage_ru.htm""\0";
char help[] = FROM "html\\help_ru.htm""\0";
43,7 → 56,7
"Š®¯¨à®¢ âì áá뫪ã
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
#else
char version[]="Text-based Browser 2.0 beta2";
char version[]="Text-based Browser 2.0 beta4";
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
char homepage[] = FROM "html\\homepage_en.htm""\0";
char help[] = FROM "html\\help_en.htm""\0";
60,19 → 73,6
 
#define URL_SIZE 4000
 
dword col_bg = 0xE3E2E2;
dword panel_color = 0xE3E2E2;
dword border_color = 0x787878;
 
bool debug_mode = false;
 
_http http = {0, 0, 0, 0, 0, 0, 0};
 
#include "..\TWB\TWB.c"
#include "history.h"
#include "show_src.h"
#include "download_manager.h"
 
#define URL_SERVICE_HISTORY "WebView:history"
#define URL_SERVICE_HOMEPAGE "WebView:home"
#define URL_SERVICE_HELP "WebView:help"
158,7 → 158,7
case evMouse:
edit_box_mouse stdcall (#address_box);
mouse.get();
if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first))
&& (mouse.pkm) && (mouse.up) {
if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
break;
250,7 → 250,7
{
http.handle_redirect();
http.free();
GetAbsoluteURL(#http.redirect_url);
GetAbsoluteURL(#http.redirect_url, history.current());
debug("Redirect: "); debugln(#http.redirect_url);
history.back();
OpenPage(#http.redirect_url);
277,7 → 277,7
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
WB1.list.visible = WB1.list.h;
if (WB1.list.w!=WB1.DrawBuf.bufw) {
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20);
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
OpenPage(history.current());
}
}
301,13 → 301,12
if (!header) {
OpenPage(history.current());
WB1.DrawScroller();
}
else {
} else {
WB1.DrawPage();
DrawOmnibox();
}
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x,
scroll_wv.size_y-1, scroll_wv.bckg_col);
}
DrawProgress();
}
 
401,13 → 400,15
}
 
//rewrite into
//bool strrpl(dword dst, from, to, dst_len); !!!!!!!!
void ReplaceSpaceInUrl(dword url, size) {
//bool strrpl(dword dst, from, into, dst_len);
bool ReplaceSpaceInUrl(dword url, size) {
unsigned int i, j;
for (i=size-3; i>0; i--)
bool was_changed=false;
for (i=url+size-3; i>url; i--)
{
if (ESBYTE[i]!=' ') continue;
for (j=size-3; j>i; j--) {
for (j=url+size-3; j>=i; j--) {
ESBYTE[j+3]=ESBYTE[j+2];
ESBYTE[j+2]=ESBYTE[j+1];
ESBYTE[j+1]=ESBYTE[j];
}
414,8 → 415,9
ESBYTE[i] = '%';
ESBYTE[i+1] = '2';
ESBYTE[i+2] = '0';
was_changed = true;
}
debugln(url);
return was_changed;
}
 
bool GetLocalFileData(dword _path)
462,7 → 464,11
img_draw stdcall(skin.image, address_box.left+address_box.width+1,
address_box.top-3, 17, skin.h, 85, SKIN_Y);
 
//ReplaceSpaceInUrl(#new_url, URL_SIZE);
if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
strcpy(#editURL, #new_url);
DrawOmnibox();
}
 
if (!strncmp(#new_url,"http:",5)) {
http.get(#new_url);
} else if (!strncmp(#new_url,"https://",8)) {
509,7 → 515,7
}
 
strcpy(#new_url, _click_URL);
GetAbsoluteURL(#new_url);
GetAbsoluteURL(#new_url, history.current());
 
if (strrchr(#new_url, '#')!=0) {
anchors.take_anchor_from(#new_url);
594,16 → 600,15
strcat(#editURL, #anchors.current);
DrawOmnibox();
}
WB1.ParseHtml();
if (source_mode) {
source_mode = false;
WB1.ParseHtml();
ShowSource(bufpointer, bufsize);
return;
}
WB1.ParseHtml();
} else {
WB1.DrawPage();
}
}
}
 
byte UrlExtIs(dword base, ext)
{
/programs/cmm/browser/show_src.h
38,8 → 38,8
dword source_buf_start;
 
opened_font_counter=0;
source_buf_end = malloc(_in_bufsize*5);
source_buf_start = source_buf_end;
source_buf_start = malloc(_in_bufsize*5);
source_buf_end = source_buf_start;
 
SourceBufAdd(TEXT, "<html><head><title>View Source</title><body><pre>");
 
89,6 → 89,6
source_buf_end++;
}
ESBYTE[source_buf_end] = 0;
LoadInternalPage(source_buf_start, _in_bufsize);
LoadInternalPage(source_buf_start, source_buf_end-source_buf_start);
free(source_buf_start);
}
/programs/cmm/codeview/show_src.h
File deleted
\ No newline at end of file
/programs/cmm/codeview/codeview.c
14,14 → 14,12
#include "..\lib\obj\box_lib.h"
#include "..\lib\obj\libio.h"
#include "..\lib\obj\libimg.h"
#include "..\lib\obj\http.h"
#include "..\lib\obj\iconv.h"
#include "..\lib\obj\proc_lib.h"
 
#include "..\lib\patterns\history.h"
#include "..\lib\patterns\http_downloader.h"
//useful patterns
#include "..\lib\patterns\simple_open_dialog.h"
 
_http http = {0, 0, 0, 0, 0, 0, 0};
 
char homepage[] = FROM "html\\homepage.htm""\0";
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
 
28,7 → 26,7
char version[]="C-- Code View";
char accept_language[]= "Accept-Language: en\n";
 
#define URL_SERVICE_HOME "CodeView://home"
#define URL_SERVICE_HOME "CodeView:home"
 
proc_info Form;
 
52,24 → 50,33
 
#define URL_SIZE 4000;
#include "..\TWB\TWB.c"
#include "show_src.h"
#include "highlight_c.h"
 
char URL[URL_SIZE+1];
char editURL[URL_SIZE+1];
char default_dir[] = "/rd/1";
od_filter filter2 = { 16, "C\0H\0C--\0H--\0CPP\0\0" };
 
char current_path[URL_SIZE+1];
char edit_path[URL_SIZE+1];
int mouse_twb;
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,#mouse_twb,2,19,19};
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#edit_path,#mouse_twb,2,19,19};
 
#define SKIN_Y 24
 
void main()
void LoadLibraries()
{
int i;
int id;
load_dll(boxlib, #box_lib_init,0);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1);
load_dll(iconv_lib, #iconv_open,0);
if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
load_dll(Proc_lib, #OpenDialog_init,0);
OpenDialog_init stdcall (#o_dialog);
}
 
void main()
{
int i;
LoadLibraries();
if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME);
WB1.list.SetFont(8, 14, 10011000b);
WB1.list.no_selection = true;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
89,8 → 96,7
break;
 
case evButton:
id=GetButtonID();
if (1==id) ExitProcess();
if (GetButtonID()==1) ExitProcess();
break;
 
case evKey:
97,15 → 103,21
GetKeys();
 
if (SCAN_CODE_F5 == key_scancode) {
OpenPage();
OpenPage(#current_path);
}
if (SCAN_CODE_F3 == key_scancode) {
RunProgram("/rd/1/tinypad", #URL);
RunProgram("/rd/1/tinypad", #current_path);
}
 
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
}
 
if (address_box.flags & 0b10)
{
if (key_ascii == ASCII_KEY_ENTER) EventGoToPage();
if (key_ascii == ASCII_KEY_ENTER) {
OpenPage(#edit_path);
}
else {
EAX = key_editbox;
edit_box_key stdcall(#address_box);
126,7 → 138,8
if (Form.status_window>2) { DrawTitle(#header); break; }
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
Draw_Window();
SetElementSizes();
draw_window();
break;
}
}
144,23 → 157,22
WB1.list.visible = WB1.list.h;
if (WB1.list.w!=WB1.DrawBuf.bufw) {
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700);
OpenPage();
OpenPage(#current_path);
}
}
 
void Draw_Window()
void draw_window()
{
DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
SetElementSizes();
DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,border_color);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
DrawEditBoxWebView();
if (!header)
OpenPage();
else {
if (!header) {
OpenPage(#current_path);
} else {
WB1.DrawPage();
DrawEditBoxWebView();
}
167,54 → 179,27
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
}
 
void EventGoToPage()
{
if (!editURL[0]) {
strcpy(#URL, URL_SERVICE_HOME);
}
else
{
strcpy(#URL, #editURL);
}
OpenPage();
}
 
 
void SetPageDefaults()
void OpenPage(dword _path)
{
strncpy(#header, #version, sizeof(header)-1);
WB1.list.count = WB1.list.first = 0;
cur_encoding = CH_NULL;
}
 
void OpenPage()
{
char getUrl[URL_SIZE+1];
strcpy(#editURL, #URL);
history.add(#URL);
if (!strncmp(#URL,"CodeView:",8))
{
SetPageDefaults();
if (!strcmp(#URL, URL_SERVICE_HOME)) LoadInternalPage(#homepage, sizeof(homepage));
DrawEditBoxWebView();
dword buf, size;
strcpy(#current_path, _path);
if (streq(_path, URL_SERVICE_HOME)) {
LoadInternalPage(#homepage, sizeof(homepage));
return;
}
else
file_size stdcall (_path);
if (EBX)
{
file_size stdcall (#URL);
bufsize = EBX;
if (bufsize)
{
free(bufpointer);
bufpointer = malloc(bufsize);
SetPageDefaults();
ReadFile(0, bufsize, bufpointer, #URL);
size = EBX;
buf = malloc(size);
ReadFile(0, size, buf, _path);
ShowCodeSource();
LoadInternalPage(bufpointer, bufsize);
free(buf);
return;
}
ShowPage();
LoadInternalPage(NULL,NULL);
}
}
 
DrawEditBoxWebView()
{
221,7 → 206,7
int skin_x_offset;
DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#edit_path);
address_box.offset = 0;
edit_box_draw stdcall(#address_box);
skin_x_offset = 51;
228,20 → 213,36
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
}
 
void LoadInternalPage(dword bufpos, in_filesize){
bufsize = in_filesize;
bufpointer = bufpos;
ShowPage();
void LoadInternalPage(dword _bufpos, _bufsize)
{
if (bufpointer) free(bufpointer);
 
if (!_bufpos) || (!_bufsize) {
LoadInternalPage(#page_not_found, sizeof(page_not_found));
return;
}
strcpy(#edit_path, #current_path);
DrawEditBoxWebView();
 
void ShowPage()
{
DrawEditBoxWebView();
if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found));
bufpointer = _bufpos;
bufsize = _bufsize;
bufpointer = malloc(bufsize);
strcpy(bufpointer, _bufpos);
 
WB1.list.first = 0;
WB1.ParseHtml();
WB1.DrawPage();
}
 
void EventOpenDialog()
{
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
OpenPage(#openfile_path);
}
}
 
 
void DrawStatusBar() {return;};
void EventClickLink() {return;};
void EventShowLinkMenu() {return;};
/programs/cmm/codeview/highlight_c.h
0,0 → 1,121
enum { TAG, OPTION_VALUE, TEXT, COMMENT, INLINE_COMMENT, CODE };
 
 
 
char* C_HL_keywords[] = {
"switch", "if", "while", "for", "break", "continue", "return", "else",
"union", "typedef", "static", "class", "case", "#include",
"volatile", "register", "sizeof", "typedef", "union", "goto", "const", "auto",
"#define", "#endif", "#error", "#ifdef", "#ifndef", "#undef", "#if", "#else",
"inline",
 
"int ", "dword ", "long ", "double ", "float ", "char ", "unsigned ", "signed ",
"void ", "bool ", "enum ", "byte ", "word ", "struct ", "NULL", "loop", "stdcall ",
":void ", ":int ", ":bool ", ":dword ", NULL
};
 
dword ShowCodeSource(dword _bufpointer, _bufsize)
{
dword new_buf, new_buf_start, i;
int mode = CODE;
 
char spstr[64];
dword keylen;
dword keyn;
dword keycolor;
 
new_buf = malloc(_bufsize*10);
new_buf_start = new_buf;
sprintf(new_buf,"<html><head><title>%s</title><body><pre>",#current_path);
new_buf += strlen(new_buf);
for (i=_bufpointer; i<_bufpointer+_bufsize; i++)
{
if ('<' == ESBYTE[i]) {
strcpy(new_buf, "&lt;");
new_buf+=4;
continue;
}
if ('>' == ESBYTE[i]) {
strcpy(new_buf, "&gt;");
new_buf+=4;
continue;
}
if (ESBYTE[i] >= '0') && (ESBYTE[i] <= '9') && (CODE == mode) {
strcpy(new_buf, "<font color=#CF00FF>?</font>");
ESBYTE[new_buf+20] = ESBYTE[i];
new_buf+=28;
if (ESBYTE[i+1] == 'x') {
strcpy(new_buf, "<font color=#CF00FF>x</font>");
new_buf+=28;
i++;
}
continue;
}
 
if (CODE == mode) && ('\"' == ESBYTE[i]) {
mode = TEXT;
strcpy(new_buf, "<font color=#080>\"");
new_buf+=18;
continue;
}
if (TEXT == mode) && ('\"' == ESBYTE[i]) {
mode = CODE;
strcpy(new_buf, "\"</font>");
new_buf+=8;
continue;
}
 
if (! strncmp(i, "//", 2) ) && (mode == CODE) {
mode = INLINE_COMMENT;
strcpy(new_buf, "<font color=#999>//");
new_buf+=19;
i++;
continue;
}
 
if (INLINE_COMMENT == mode) {
if (13 == ESBYTE[i]) {
mode = CODE;
strcpy(new_buf, "\13</font>");
new_buf+=8;
continue;
}
}
 
if (! strncmp(i, "/*", 2) ) {
mode = COMMENT;
strcpy(new_buf, "<font color=#999>/*");
new_buf+=19;
i++;
continue;
}
if (! strncmp(i, "*/", 2) ) {
mode = CODE;
strcpy(new_buf, "*/</font>");
new_buf+=9;
i++;
continue;
}
 
if (CODE == mode) for (keyn=0; C_HL_keywords[keyn]!=NULL; keyn++)
{
keylen = strlen(C_HL_keywords[keyn]);
if (! strncmp(i, C_HL_keywords[keyn], keylen) ) {
 
if (keyn<31) keycolor="#f00"; else keycolor="#00f";
sprintf(#spstr, "<font color=%s>%s</font>", keycolor, C_HL_keywords[keyn]);
strcpy(new_buf, #spstr);
 
new_buf += keylen + 24;
i += keylen-1;
goto _CONTINUE;
}
}
ESBYTE[new_buf] = ESBYTE[i];
new_buf++;
_CONTINUE:
}
ESBYTE[new_buf] = 0;
LoadInternalPage(new_buf_start, new_buf - new_buf_start);
free(new_buf_start);
}
/programs/cmm/codeview/html/homepage.htm
5,8 → 5,9
<body>
 
<br>
CodeView is a sipmle C--/C/C++ code viewer based on TWB component.
CodeView is a sipmle C--/C/C++ code viewer based on TWB component.<br>
<br>
Press Ctrl+O to open a file.
 
 
</body>
</html>
/programs/cmm/codeview/html/page_not_found_en.htm
1,14 → 1,10
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=cp-866" />
<meta charset=cp-866 />
<title>File not found</title>
</head>
<body>
<h1>&nbsp;File not found</h1>
<ul>
<li>
Check page address, there may have been made a typo.<br>
</li>
</ul>
Please, check file address, there may have been made a typo.
</body>
</html>
/programs/cmm/eolite/Eolite.c
50,6 → 50,8
ONLY_OPEN
};
 
_history history;
 
struct Eolite_colors
{
bool def;
/programs/cmm/lib/list_box.h
269,6 → 269,8
 
:void llist_copy(dword dest, src)
{
memmov(dest, src, sizeof(llist));
/*
EDI = dest;
ESI = src;
EDI.llist.x = ESI.llist.x;
286,6 → 288,7
EDI.llist.cur_y = ESI.llist.cur_y;
EDI.llist.column_max = ESI.llist.column_max;
EDI.llist.active = ESI.llist.active;
*/
}
 
#endif
/programs/cmm/lib/patterns/history.h
7,7 → 7,7
int back();
int forward();
dword current();
} history;
};
 
int _history::add(dword in)
{
/programs/cmm/lib/strings.h
115,6 → 115,30
}
 
/*
signed int strncmp(dword s1, s2, signed n)
unsigned char _s1,_s2;
{
if (n == 0)
return 0;
do {
_s1 = DSBYTE[s1];
_s2 = DSBYTE[s2];
if (_s1 != _s2)
{
$dec s2
return _s1 - _s2;
}
$inc s2
if (_s1 == 0)
break;
$inc s1
$dec n
} while (n);
return 0;
}
*/
 
/*
inline signed int strncmp(dword text1,text2,len)
{
134,7 → 158,7
EAX-=2+ECX;
}
 
inline strnlen(dword str, dword maxlen)
inline dword strnlen(dword str, dword maxlen)
{
dword cp;
for (cp = str; (maxlen != 0) && (DSBYTE[cp] != '\0'); cp++, maxlen--);
181,20 → 205,7
return 0;
}
 
/*
TODO: rewrite streq() using pure assembliy
 
inline fastcall void strcpy( EDI, ESI)
{
$cld
L2:
$lodsb
$stosb
$test al,al
$jnz L2
}
*/
 
inline fastcall streq(ESI, EDI)
{
loop()
212,31 → 223,6
return true;
}
 
/*
signed int strncmp(dword s1, s2, signed n)
unsigned char _s1,_s2;
{
if (n == 0)
return 0;
do {
_s1 = DSBYTE[s1];
_s2 = DSBYTE[s2];
if (_s1 != _s2)
{
$dec s2
return _s1 - _s2;
}
$inc s2
if (_s1 == 0)
break;
$inc s1
$dec n
} while (n);
return 0;
}
*/
 
 
inline fastcall void strcpy( EDI, ESI)
{
$cld
395,13 → 381,13
}
}
 
:void strncat(dword dst, src, dword len)
:void strncat(dword dst, src, len)
{
while (ESBYTE[dst]) && (len) {
dst++;
len--;
}
while (ESBYTE[src]) && (len) {
while (ESBYTE[src]) && (len>1) {
ESBYTE[dst] = ESBYTE[src];
dst++;
src++;
410,6 → 396,18
ESBYTE[dst] = 0;
}
 
:void chrncat(dword dst, unsigned char s, dword len)
{
while (ESBYTE[dst]) && (len) {
dst++;
len--;
}
if (len>1) {
ESBYTE[dst] = s;
ESBYTE[dst+1] = 0;
}
}
 
inline fastcall void chrcat(ESI, DI)
{
while (ESBYTE[ESI]) ESI++;
/programs/cmm/liza/liza.c
22,7 → 22,6
#include "../lib/obj/netcode.h"
#include "../lib/obj/iconv.h"
//patterns
#include "../lib/patterns/history.h"
#include "../lib/patterns/http_downloader.h"
//images
byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw";