forked from KolibriOS/kolibrios
WebView 1.94: code refactoring and bugfixing; also
- rework source code view, open it in a new tab - fix tagparm parsing for case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b - fix: show image text in multiple lines if need git-svn-id: svn://kolibrios.org@7750 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
eaed653ad3
commit
e7484ebe37
@ -29,9 +29,8 @@ struct TWebBrowser {
|
|||||||
void DrawStyle();
|
void DrawStyle();
|
||||||
void DrawPage();
|
void DrawPage();
|
||||||
void DrawScroller();
|
void DrawScroller();
|
||||||
void LoadInternalPage();
|
|
||||||
void NewLine();
|
void NewLine();
|
||||||
void Perenos();
|
bool CheckForLineBreak();
|
||||||
void BufEncode();
|
void BufEncode();
|
||||||
} WB1;
|
} WB1;
|
||||||
|
|
||||||
@ -97,11 +96,11 @@ void TWebBrowser::DrawStyle()
|
|||||||
line_length = stolbec_len * list.font_w;
|
line_length = stolbec_len * list.font_w;
|
||||||
|
|
||||||
if (debug_mode) {
|
if (debug_mode) {
|
||||||
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xDDDddd);
|
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style.bg_color!=page_bg) {
|
if (style.bg_color!=page_bg) {
|
||||||
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color);
|
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style.image) {
|
if (style.image) {
|
||||||
@ -118,20 +117,16 @@ void TWebBrowser::DrawStyle()
|
|||||||
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
|
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
|
||||||
if (link) {
|
if (link) {
|
||||||
if (line[0]==' ') && (line[1]==NULL) {} else {
|
if (line[0]==' ') && (line[1]==NULL) {} else {
|
||||||
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]);
|
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, link_color_inactive);
|
||||||
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom);
|
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stolbec += stolbec_len;
|
stolbec += stolbec_len;
|
||||||
|
if (debug_mode) debug(#line);
|
||||||
|
line = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
|
|
||||||
bufsize = in_filesize;
|
|
||||||
bufpointer = bufpos;
|
|
||||||
Prepare();
|
|
||||||
}
|
|
||||||
//============================================================================================
|
|
||||||
void TWebBrowser::SetPageDefaults()
|
void TWebBrowser::SetPageDefaults()
|
||||||
{
|
{
|
||||||
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
|
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
|
||||||
@ -171,7 +166,6 @@ void TWebBrowser::Prepare(){
|
|||||||
if (style.pre)
|
if (style.pre)
|
||||||
{
|
{
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
line = NULL;
|
|
||||||
NewLine();
|
NewLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -193,10 +187,11 @@ void TWebBrowser::Prepare(){
|
|||||||
}
|
}
|
||||||
if (bukva = GetUnicodeSymbol(#tag)) {
|
if (bukva = GetUnicodeSymbol(#tag)) {
|
||||||
bufpos += j;
|
bufpos += j;
|
||||||
|
CheckForLineBreak();
|
||||||
} else {
|
} else {
|
||||||
bukva = '&';
|
bukva = '&';
|
||||||
|
goto DEFAULT_MARK;
|
||||||
}
|
}
|
||||||
goto DEFAULT_MARK;
|
|
||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
bufpos++;
|
bufpos++;
|
||||||
@ -223,6 +218,7 @@ void TWebBrowser::Prepare(){
|
|||||||
{
|
{
|
||||||
ignor_param = true;
|
ignor_param = true;
|
||||||
if (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
|
if (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
|
||||||
|
// chrncat(#tagparam, bukva, sizeof(tagparam)-1);
|
||||||
}
|
}
|
||||||
bufpos++;
|
bufpos++;
|
||||||
}
|
}
|
||||||
@ -250,12 +246,11 @@ void TWebBrowser::Prepare(){
|
|||||||
else opened = 1;
|
else opened = 1;
|
||||||
|
|
||||||
if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
|
if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
|
||||||
Perenos();
|
CheckForLineBreak();
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
line = NULL;
|
|
||||||
if (tag) SetStyle();
|
if (tag) SetStyle();
|
||||||
}
|
}
|
||||||
strlcpy(#oldtag, #tag, sizeof(oldtag));
|
strlcpy(#oldtag, #tag, sizeof(oldtag)-1);
|
||||||
tag = attr = tagparam = ignor_param = NULL;
|
tag = attr = tagparam = ignor_param = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -268,7 +263,7 @@ void TWebBrowser::Prepare(){
|
|||||||
if (!stolbec) && (!line) break; //no paces at the beginning of the line
|
if (!stolbec) && (!line) break; //no paces at the beginning of the line
|
||||||
}
|
}
|
||||||
if (line_len < sizeof(line)) chrcat(#line, bukva);
|
if (line_len < sizeof(line)) chrcat(#line, bukva);
|
||||||
Perenos();
|
CheckForLineBreak();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
@ -277,21 +272,27 @@ void TWebBrowser::Prepare(){
|
|||||||
DrawPage();
|
DrawPage();
|
||||||
}
|
}
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
void TWebBrowser::Perenos()
|
bool TWebBrowser::CheckForLineBreak()
|
||||||
{
|
{
|
||||||
int perenos_num;
|
int line_break_pos;
|
||||||
char new_line_text[4096];
|
char new_line_text[4096];
|
||||||
if (strlen(#line)*zoom + stolbec < list.column_max) return;
|
if (strlen(#line)*zoom + stolbec < list.column_max) return false;
|
||||||
perenos_num = strrchr(#line, ' ');
|
line_break_pos = strrchr(#line, ' ');
|
||||||
if (!perenos_num) && (strlen(#line)*zoom>list.column_max) {
|
if (line_break_pos*zoom + stolbec > list.column_max) {
|
||||||
perenos_num=list.column_max/zoom;
|
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
|
if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt
|
||||||
}
|
}
|
||||||
strcpy(#new_line_text, #line + perenos_num);
|
strcpy(#new_line_text, #line + line_break_pos);
|
||||||
line[perenos_num] = 0x00;
|
line[line_break_pos] = 0x00;
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
strcpy(#line, #new_line_text);
|
strcpy(#line, #new_line_text);
|
||||||
NewLine();
|
NewLine();
|
||||||
|
//if (strlen(#line)*zoom + stolbec > list.column_max)CheckForLineBreak();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
void TWebBrowser::SetStyle() {
|
void TWebBrowser::SetStyle() {
|
||||||
@ -309,7 +310,11 @@ void TWebBrowser::SetStyle() {
|
|||||||
|
|
||||||
IF(istag("q"))
|
IF(istag("q"))
|
||||||
{
|
{
|
||||||
if (opened) strcat(#line, " \"");
|
if (opened) {
|
||||||
|
meta_encoding = strlen(#line);
|
||||||
|
if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
|
||||||
|
chrcat(#line, '\"');
|
||||||
|
}
|
||||||
if (!opened) strcat(#line, "\" ");
|
if (!opened) strcat(#line, "\" ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -404,11 +409,11 @@ void TWebBrowser::SetStyle() {
|
|||||||
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
|
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
|
||||||
if (istag("img")) {
|
if (istag("img")) {
|
||||||
do{
|
do{
|
||||||
if (isattr("src=")) strncpy(#img_path, #val, sizeof(img_path)-1);
|
if (isattr("src=")) strlcpy(#img_path, #val, sizeof(img_path)-1);
|
||||||
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
|
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
|
||||||
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
|
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
|
||||||
} while(GetNextParam());
|
} while(GetNextParam());
|
||||||
if (!img_path) return;
|
if (!img_path) { line=0; return; }
|
||||||
style.image = true;
|
style.image = true;
|
||||||
text_color_index++;
|
text_color_index++;
|
||||||
text_colors[text_color_index] = 0x9A6F29;
|
text_colors[text_color_index] = 0x9A6F29;
|
||||||
@ -418,9 +423,8 @@ void TWebBrowser::SetStyle() {
|
|||||||
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
|
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
|
||||||
line[50]= NULL;
|
line[50]= NULL;
|
||||||
}
|
}
|
||||||
if (strlen(#line) + stolbec > list.column_max) Perenos();
|
while (CheckForLineBreak()) {};
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
line=0;
|
|
||||||
text_color_index--;
|
text_color_index--;
|
||||||
style.image = false;
|
style.image = false;
|
||||||
//ImgCache.Images( left1, draw_y, WB1.list.w);
|
//ImgCache.Images( left1, draw_y, WB1.list.w);
|
||||||
@ -559,6 +563,7 @@ void TWebBrowser::NewLine()
|
|||||||
draw_y += list.item_h;
|
draw_y += list.item_h;
|
||||||
if (style.blq) stolbec = 6; else stolbec = 0;
|
if (style.blq) stolbec = 6; else stolbec = 0;
|
||||||
if (style.li) stolbec = style.li_tab * 5;
|
if (style.li) stolbec = style.li_tab * 5;
|
||||||
|
if (debug_mode) debugln(NULL);
|
||||||
}
|
}
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
|
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
|
||||||
|
@ -14,9 +14,8 @@ void GetAbsoluteURL(dword in_URL)
|
|||||||
|
|
||||||
IF (!strncmp(in_URL,"//", 2))
|
IF (!strncmp(in_URL,"//", 2))
|
||||||
{
|
{
|
||||||
//strcpy(#newurl, "http:");
|
strcpy(#newurl, "http:");
|
||||||
//strcat(#newurl, in_URL);
|
strcat(#newurl, in_URL);
|
||||||
sprintf(#newurl, "http:%s", in_URL);
|
|
||||||
strcpy(orig_URL, #newurl);
|
strcpy(orig_URL, #newurl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ bool GetNextParam()
|
|||||||
if (!tagparam) return false;
|
if (!tagparam) return false;
|
||||||
|
|
||||||
if (debug_mode) {
|
if (debug_mode) {
|
||||||
|
debug("tag: "); debugln(#tag);
|
||||||
debug("tagparam: "); debugln(#tagparam);
|
debug("tagparam: "); debugln(#tagparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ bool GetNextParam()
|
|||||||
|
|
||||||
//find VAL start and copy
|
//find VAL start and copy
|
||||||
i = strrchr(#tagparam, quotes);
|
i = strrchr(#tagparam, quotes);
|
||||||
strlcpy(#val, #tagparam + i, sizeof(val));
|
strlcpy(#val, #tagparam + i, sizeof(val)-1);
|
||||||
tagparam[i] = '\0'; i--;
|
tagparam[i] = '\0'; i--;
|
||||||
|
|
||||||
//find ATTR end
|
//find ATTR end
|
||||||
@ -38,8 +39,8 @@ bool GetNextParam()
|
|||||||
//find VAL start and copy
|
//find VAL start and copy
|
||||||
while (i > 0) && (tagparam[i] != '=') i--;
|
while (i > 0) && (tagparam[i] != '=') i--;
|
||||||
i++;
|
i++;
|
||||||
strlcpy(#val, #tagparam + i, sizeof(val));
|
strlcpy(#val, #tagparam + i, sizeof(val)-1);
|
||||||
tagparam[i] = '\0';
|
// tagparam[i] = '\0';
|
||||||
|
|
||||||
//find ATTR end
|
//find ATTR end
|
||||||
//already have
|
//already have
|
||||||
@ -47,20 +48,22 @@ bool GetNextParam()
|
|||||||
|
|
||||||
//find ATTR start and copy
|
//find ATTR start and copy
|
||||||
while (i>0) && (!__isWhite(tagparam[i])) i--;
|
while (i>0) && (!__isWhite(tagparam[i])) i--;
|
||||||
strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
|
strlcpy(#attr, #tagparam + i + 1, sizeof(attr)-1);
|
||||||
tagparam[i] = '\0';
|
tagparam[i] = '\0';
|
||||||
|
|
||||||
|
//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
|
||||||
|
i = strchr(#attr,'=');
|
||||||
|
if (!quotes) && (i) {
|
||||||
|
strlcpy(#val, i+1, sizeof(val)-1);
|
||||||
|
ESBYTE[i+1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
strlwr(#attr);
|
strlwr(#attr);
|
||||||
|
|
||||||
if (debug_mode) {
|
if (debug_mode) {
|
||||||
if (quotes) {
|
debug("val: "); debugln(#val);
|
||||||
debug("quote: "); debugch(quotes); debugln(" ");
|
debug("attr: "); debugln(#attr);
|
||||||
}
|
debugln(" ");
|
||||||
else {
|
|
||||||
debugln("unquoted text");
|
|
||||||
}
|
|
||||||
sprintf(#param, "val: %s\nattr: %s\n\n", #val, #attr);
|
|
||||||
debug(#param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -65,11 +65,11 @@ char *unicode_tags[]={
|
|||||||
0};
|
0};
|
||||||
|
|
||||||
|
|
||||||
byte unicode_chars[] = "€亗儎厗噲墛媽崕彁憭摂晼棙櫄洔潪煚、¥ウЖ┆<EFBFBD><EFBFBD><EFBFBD>徕沅彐玷殛腱眍镳駂<EFBFBD>243i\105\244\0";
|
unsigned char unicode_chars[] = "€<EFBFBD>‚ƒ„…†‡ˆ‰Š‹Œ<EFBFBD>Ž<EFBFBD><EFBFBD>‘’“”•–—˜™š›œ<EFBFBD>žŸ ¡¢£¤¥¦§¨©ª«¬®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
|
||||||
|
|
||||||
bool GetUnicodeSymbol(dword in_tag)
|
bool GetUnicodeSymbol(dword in_tag)
|
||||||
{
|
{
|
||||||
int j;
|
int j, specia1040;
|
||||||
|
|
||||||
for (j=0; unicode_tags[j]!=0; j+=2;)
|
for (j=0; unicode_tags[j]!=0; j+=2;)
|
||||||
{
|
{
|
||||||
@ -80,10 +80,19 @@ bool GetUnicodeSymbol(dword in_tag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = atoi(in_tag + 1) - 1040;
|
specia1040 = atoi(in_tag + 1) - 1040;
|
||||||
if (tag[1] == '1') && (j>=0) && (j<=72) && (strlen(in_tag) == 5)
|
|
||||||
|
if (tag[1] == '1') && (specia1040>=0)
|
||||||
|
&& (specia1040<=72) && (strlen(in_tag) == 5)
|
||||||
{
|
{
|
||||||
chrcat(#line, unicode_chars[j]);
|
if (strlen(#line)<sizeof(line)-2) {
|
||||||
|
/*
|
||||||
|
j = strlen(#line);
|
||||||
|
line[j] = unicode_chars[specia1040];
|
||||||
|
line[j+1] = EOS;
|
||||||
|
*/
|
||||||
|
chrcat(#line, unicode_chars[specia1040]);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +28,8 @@
|
|||||||
#include "..\lib\patterns\http_downloader.h"
|
#include "..\lib\patterns\http_downloader.h"
|
||||||
#include "..\lib\patterns\simple_open_dialog.h"
|
#include "..\lib\patterns\simple_open_dialog.h"
|
||||||
|
|
||||||
_http http = {0, 0, 0, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.93";
|
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.94";
|
||||||
#define T_LOADING "‡ £à㧪 áâà ¨æë..."
|
#define T_LOADING "‡ £à㧪 áâà ¨æë..."
|
||||||
#define T_RENDERING "<22>¥¤¥à¨£..."
|
#define T_RENDERING "<22>¥¤¥à¨£..."
|
||||||
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
||||||
@ -48,7 +45,7 @@ char link_menu[] =
|
|||||||
"Š®¯¨à®¢ âì áá뫪ã
|
"Š®¯¨à®¢ âì áá뫪ã
|
||||||
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
|
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
|
||||||
#else
|
#else
|
||||||
char version[]="Text-based Browser 1.93";
|
char version[]="Text-based Browser 1.94";
|
||||||
#define T_LOADING "Loading..."
|
#define T_LOADING "Loading..."
|
||||||
#define T_RENDERING "Rendering..."
|
#define T_RENDERING "Rendering..."
|
||||||
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
|
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
|
||||||
@ -65,31 +62,34 @@ char link_menu[] =
|
|||||||
Download link contents";
|
Download link contents";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define URL_SERVICE_HISTORY "WebView://history"
|
|
||||||
#define URL_SERVICE_HOMEPAGE "WebView://home"
|
|
||||||
#define URL_SERVICE_HELP "WebView://help"
|
|
||||||
#define URL_SERVICE_SOURCE "WebView://source:"
|
|
||||||
|
|
||||||
proc_info Form;
|
|
||||||
|
|
||||||
char stak[4096];
|
|
||||||
|
|
||||||
int action_buf;
|
|
||||||
|
|
||||||
dword TOOLBAR_H = 40;
|
|
||||||
dword STATUSBAR_H = 15;
|
|
||||||
|
|
||||||
dword col_bg = 0xE3E2E2;
|
dword col_bg = 0xE3E2E2;
|
||||||
dword panel_color = 0xE3E2E2;
|
dword panel_color = 0xE3E2E2;
|
||||||
dword border_color = 0x8C8C8C;
|
dword border_color = 0x8C8C8C;
|
||||||
|
|
||||||
bool debug_mode = false;
|
bool debug_mode = false;
|
||||||
|
bool open_in_a_new_window = 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"
|
||||||
|
|
||||||
|
dword TOOLBAR_H = 40;
|
||||||
|
dword STATUSBAR_H = 15;
|
||||||
|
|
||||||
|
int action_buf;
|
||||||
|
|
||||||
|
bool source_mode = false;
|
||||||
|
|
||||||
progress_bar wv_progress_bar;
|
progress_bar wv_progress_bar;
|
||||||
|
char stak[4096];
|
||||||
bool souce_mode = false;
|
proc_info Form;
|
||||||
bool open_in_a_new_window = false;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BACK_BUTTON=1000,
|
BACK_BUTTON=1000,
|
||||||
@ -97,19 +97,14 @@ enum {
|
|||||||
REFRESH_BUTTON,
|
REFRESH_BUTTON,
|
||||||
GOTOURL_BUTTON,
|
GOTOURL_BUTTON,
|
||||||
SANDWICH_BUTTON,
|
SANDWICH_BUTTON,
|
||||||
VIEW_SOURCE=1100,
|
VIEW_SOURCE,
|
||||||
EDIT_SOURCE,
|
EDIT_SOURCE,
|
||||||
VIEW_HISTORY,
|
VIEW_HISTORY,
|
||||||
DOWNLOAD_MANAGER,
|
DOWNLOAD_MANAGER,
|
||||||
COPY_LINK_URL=1200,
|
COPY_LINK_URL,
|
||||||
DOWNLOAD_LINK_CONTENTS,
|
DOWNLOAD_LINK_CONTENTS,
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "..\TWB\TWB.c"
|
|
||||||
#include "history.h"
|
|
||||||
#include "show_src.h"
|
|
||||||
#include "download_manager.h"
|
|
||||||
|
|
||||||
char default_dir[] = "/rd/1";
|
char default_dir[] = "/rd/1";
|
||||||
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
||||||
|
|
||||||
@ -132,10 +127,13 @@ void LoadLibraries()
|
|||||||
void HandleParam()
|
void HandleParam()
|
||||||
{
|
{
|
||||||
if (param) {
|
if (param) {
|
||||||
if (param[0]=='-') && (param[1]=='d') {
|
if (!strncmp(#param, "-d ", 3)) {
|
||||||
strcpy(#downloader_edit, #param+3);
|
strcpy(#downloader_edit, #param+3);
|
||||||
CreateThread(#Downloader,#downloader_stak+4092);
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
ExitProcess();
|
ExitProcess();
|
||||||
|
} else if (!strncmp(#param, "-s ", 3)) {
|
||||||
|
source_mode = true;
|
||||||
|
strcpy(#URL, #param + 3);
|
||||||
} else {
|
} else {
|
||||||
strcpy(#URL, #param);
|
strcpy(#URL, #param);
|
||||||
}
|
}
|
||||||
@ -185,7 +183,7 @@ void main()
|
|||||||
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
||||||
if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
|
if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
|
||||||
if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
|
if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
|
||||||
if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE);
|
if (key_scancode == SCAN_CODE_KEY_U) EventViewSource();
|
||||||
if (key_scancode == SCAN_CODE_KEY_T)
|
if (key_scancode == SCAN_CODE_KEY_T)
|
||||||
|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
|
|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
|
||||||
if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
|
if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
|
||||||
@ -224,7 +222,7 @@ void main()
|
|||||||
ProcessEvent(menu.cur_y);
|
ProcessEvent(menu.cur_y);
|
||||||
menu.cur_y = 0;
|
menu.cur_y = 0;
|
||||||
}
|
}
|
||||||
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,0,0,0);
|
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
|
||||||
GetProcessInfo(#Form, SelfInfo);
|
GetProcessInfo(#Form, SelfInfo);
|
||||||
system.color.get();
|
system.color.get();
|
||||||
col_bg = system.color.work;
|
col_bg = system.color.work;
|
||||||
@ -359,17 +357,15 @@ void ProcessEvent(dword id__)
|
|||||||
EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
|
EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
|
||||||
return;
|
return;
|
||||||
case VIEW_SOURCE:
|
case VIEW_SOURCE:
|
||||||
WB1.list.first = 0;
|
EventViewSource();
|
||||||
ShowSource();
|
|
||||||
WB1.LoadInternalPage(bufpointer, bufsize);
|
|
||||||
break;
|
break;
|
||||||
case EDIT_SOURCE:
|
case EDIT_SOURCE:
|
||||||
if (!strncmp(#URL,"http",4))
|
if (check_is_the_adress_local(#URL)) {
|
||||||
{
|
RunProgram("/rd/1/tinypad", #URL);
|
||||||
|
} else {
|
||||||
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
|
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
|
||||||
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
|
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
|
||||||
}
|
}
|
||||||
else RunProgram("/rd/1/tinypad", #URL);
|
|
||||||
return;
|
return;
|
||||||
case VIEW_HISTORY:
|
case VIEW_HISTORY:
|
||||||
strcpy(#URL, URL_SERVICE_HISTORY);
|
strcpy(#URL, URL_SERVICE_HISTORY);
|
||||||
@ -444,14 +440,13 @@ void OpenPage()
|
|||||||
{
|
{
|
||||||
char getUrl[sizeof(URL)];
|
char getUrl[sizeof(URL)];
|
||||||
StopLoading();
|
StopLoading();
|
||||||
souce_mode = false;
|
|
||||||
strcpy(#editURL, #URL);
|
strcpy(#editURL, #URL);
|
||||||
history.add(#URL);
|
history.add(#URL);
|
||||||
if (!strncmp(#URL,"WebView:",8))
|
if (!strncmp(#URL,"WebView:",8))
|
||||||
{
|
{
|
||||||
SetPageDefaults();
|
SetPageDefaults();
|
||||||
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
|
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)-1);
|
||||||
else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help));
|
else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)-1);
|
||||||
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
|
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
|
||||||
else {bufsize=0; ShowPage();} //page not found
|
else {bufsize=0; ShowPage();} //page not found
|
||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
@ -500,7 +495,7 @@ void ProcessAnchor()
|
|||||||
int anchor_pos;
|
int anchor_pos;
|
||||||
|
|
||||||
anchor_pos = strrchr(#URL, '#')-1;
|
anchor_pos = strrchr(#URL, '#')-1;
|
||||||
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor));
|
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1);
|
||||||
URL[anchor_pos] = 0x00;
|
URL[anchor_pos] = 0x00;
|
||||||
|
|
||||||
//#1
|
//#1
|
||||||
@ -626,25 +621,30 @@ void DrawOmnibox()
|
|||||||
int skin_x_offset;
|
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, address_box.width+3, 2, address_box.color);
|
||||||
DrawBar(address_box.left-2, address_box.top, 2, 22, 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);
|
if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
|
||||||
//address_box.offset = 0;
|
|
||||||
EditBox_UpdateText(#address_box, address_box.flags);
|
EditBox_UpdateText(#address_box, address_box.flags);
|
||||||
edit_box_draw stdcall(#address_box);
|
edit_box_draw stdcall(#address_box);
|
||||||
if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
|
if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
|
||||||
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
|
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 ShowPage()
|
void ShowPage()
|
||||||
{
|
{
|
||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
if (!bufsize)
|
if (!bufsize) || (!bufpointer) {
|
||||||
{
|
LoadInternalPage(#page_not_found, sizeof(page_not_found)-1);
|
||||||
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
|
||||||
}
|
}
|
||||||
else
|
WB1.Prepare();
|
||||||
{
|
if (source_mode) {
|
||||||
WB1.Prepare();
|
source_mode = false;
|
||||||
|
ShowSource();
|
||||||
|
LoadInternalPage(bufpointer, bufsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,6 +698,14 @@ void EventOpenDialog()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventViewSource()
|
||||||
|
{
|
||||||
|
char source_view_param[sizeof(URL)+4];
|
||||||
|
strcpy(#source_view_param, "-s ");
|
||||||
|
strcat(#source_view_param, #URL);
|
||||||
|
RunProgram(#program_path, #source_view_param);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawStatusBar(dword _status_text)
|
void DrawStatusBar(dword _status_text)
|
||||||
{
|
{
|
||||||
status_text.start_x = 10;
|
status_text.start_x = 10;
|
||||||
|
@ -23,37 +23,37 @@
|
|||||||
|
|
||||||
ShowHistory()
|
ShowHistory()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static int history_pointer;
|
static int history_pointer;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
free(history_pointer);
|
||||||
|
history_pointer = malloc(history.items.data_size+256);
|
||||||
|
strcat(history_pointer, HISTORY_HEADER);
|
||||||
|
for (i=0; i<history.items.count; i++)
|
||||||
|
{
|
||||||
|
strcat(history_pointer, "\t<a href='");
|
||||||
|
strcat(history_pointer, history.items.get(i));
|
||||||
|
strcat(history_pointer, "'>");
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
strcat(history_pointer, "<a href='");
|
||||||
|
strcat(history_pointer, #pics[i].path);
|
||||||
|
strcat(history_pointer, "'>");
|
||||||
|
strcat(history_pointer, #pics[i].path);
|
||||||
|
strcat(history_pointer, "</a><br>");
|
||||||
|
|
||||||
free(history_pointer);
|
// strcat(history_pointer, "<img src='");
|
||||||
history_pointer = malloc(history.items.data_size+256);
|
// strcat(history_pointer, #pics[i].path);
|
||||||
strcat(history_pointer, HISTORY_HEADER);
|
// strcat(history_pointer, "'><br>");
|
||||||
for (i=0; i<history.items.count; i++)
|
// strcat(history_pointer, #pics[i].path);
|
||||||
{
|
}
|
||||||
strcat(history_pointer, "\t<a href='");
|
*/
|
||||||
strcat(history_pointer, history.items.get(i));
|
strcat(history_pointer, "</body></html>");
|
||||||
strcat(history_pointer, "'>");
|
LoadInternalPage(history_pointer, strlen(history_pointer));
|
||||||
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++)
|
|
||||||
{
|
|
||||||
strcat(history_pointer, "<a href='");
|
|
||||||
strcat(history_pointer, #pics[i].path);
|
|
||||||
strcat(history_pointer, "'>");
|
|
||||||
strcat(history_pointer, #pics[i].path);
|
|
||||||
strcat(history_pointer, "</a><br>");
|
|
||||||
|
|
||||||
// strcat(history_pointer, "<img src='");
|
|
||||||
// strcat(history_pointer, #pics[i].path);
|
|
||||||
// strcat(history_pointer, "'><br>");
|
|
||||||
// strcat(history_pointer, #pics[i].path);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
strcat(history_pointer, "</body></html>");
|
|
||||||
WB1.LoadInternalPage(history_pointer, strlen(history_pointer));
|
|
||||||
}
|
}
|
@ -9,7 +9,7 @@
|
|||||||
3. <a href="http://store.kolibri-n.org">Kolibri Store</a>
|
3. <a href="http://store.kolibri-n.org">Kolibri Store</a>
|
||||||
|
|
||||||
<font color="#555555">„«ï ¯®¨áª ¢ Google ¡¥à¨â¥ â¥áâ ¢ ¤à¥á®© áâப¥
|
<font color="#555555">„«ï ¯®¨áª ¢ Google ¡¥à¨â¥ â¥áâ ¢ ¤à¥á®© áâப¥
|
||||||
¨ ¦¬¨â¥ Ctrl+Enter. …áâì â ª¦¥ ¤à㣨¥ <a href="WebView://help"><font color="#555555">ƒ®àï稥 ª« ¢¨è¨</font></a>.</font>
|
¨ ¦¬¨â¥ Ctrl+Enter. …áâì â ª¦¥ ¤à㣨¥ <a href="WebView:help"><font color="#555555">ƒ®àï稥 ª« ¢¨è¨</font></a>.</font>
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -1,231 +1,95 @@
|
|||||||
enum { TAG, OPTION_VALUE, TEXT, COMMENT, SCRIPT};
|
|
||||||
|
|
||||||
|
dword source_buf_start, source_buf_end;
|
||||||
|
int opened_font=0;
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
void SourceBufAdd(dword _mode, src)
|
||||||
|
{
|
||||||
|
dword font_found_pointer, src_orig = src;
|
||||||
|
|
||||||
|
if (_mode) mode = _mode;
|
||||||
|
|
||||||
|
strcpy(source_buf_end, src);
|
||||||
|
source_buf_end += strlen(source_buf_end);
|
||||||
|
|
||||||
|
if (font_found_pointer = strstr(src, "</font>")) {
|
||||||
|
opened_font--;
|
||||||
|
src = font_found_pointer+2;
|
||||||
|
}
|
||||||
|
|
||||||
|
src = src_orig;
|
||||||
|
if (font_found_pointer = strstr(src, "<font ")) {
|
||||||
|
opened_font++;
|
||||||
|
src = font_found_pointer+2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseAllOpenedFonts(dword _mode)
|
||||||
|
{
|
||||||
|
while (opened_font) SourceBufAdd(_mode, "</font>");
|
||||||
|
}
|
||||||
|
|
||||||
|
enum { TAG=1, VALUE, TEXT, COMMENT, SCRIPT};
|
||||||
dword ShowSource()
|
dword ShowSource()
|
||||||
{
|
{
|
||||||
dword new_buf, new_buf_start, i, j;
|
dword i, j;
|
||||||
int opened_font=0;
|
bool activate_script_mode = false;
|
||||||
int mode = TEXT;
|
|
||||||
|
|
||||||
if (souce_mode) return;
|
opened_font=0;
|
||||||
souce_mode = true;
|
source_buf_start = source_buf_end = malloc(bufsize*5);
|
||||||
new_buf = malloc(bufsize*5);
|
|
||||||
new_buf_start = new_buf;
|
|
||||||
header[strrchr(#header, '-')-2]=0;
|
header[strrchr(#header, '-')-2]=0;
|
||||||
sprintf(new_buf,"<html><head><title>Source: %s</title><body><pre>",#header);
|
|
||||||
new_buf += strlen(new_buf);
|
SourceBufAdd(TEXT, "<html><head><title>Source: ");
|
||||||
for (i=bufpointer; i<bufpointer+bufsize; i++)
|
SourceBufAdd(TEXT, #header);
|
||||||
|
SourceBufAdd(TEXT, "</title><body><pre>");
|
||||||
|
|
||||||
|
for (i=bufpointer; i<bufpointer+bufsize; i++) switch (ESBYTE[i])
|
||||||
{
|
{
|
||||||
switch (ESBYTE[i])
|
case '<':
|
||||||
{
|
if (!strncmp(i+1,"!--", 3)) SourceBufAdd(COMMENT, "<font color=#bbb><");
|
||||||
case '<':
|
else if (SCRIPT == mode) {
|
||||||
if (mode == TEXT) && (!strncmp(i+1,"script", 6)) {
|
if (!strncmp(i+1,"/script>", 8)) {
|
||||||
mode = SCRIPT;
|
CloseAllOpenedFonts(NULL);
|
||||||
strcpy(new_buf, "<font color=#00f><script</font><font color=#994500>"); opened_font++;
|
SourceBufAdd(TAG, "<font color=#00f><");
|
||||||
new_buf+=54;
|
|
||||||
i+=6;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (mode == COMMENT) || (mode == SCRIPT) && (!strncmp(i+1,"/script>", 8)) {
|
else SourceBufAdd(NULL, "<");
|
||||||
mode = TEXT;
|
}
|
||||||
while (opened_font) {
|
else if (COMMENT == mode) {
|
||||||
strcpy(new_buf, "</font>"); opened_font--;
|
SourceBufAdd(NULL, "<");
|
||||||
new_buf+=7;
|
}
|
||||||
}
|
else if (TEXT == mode) {
|
||||||
strcpy(new_buf, "<font color=#00f></script></font>");
|
if (!strncmp(i+1,"script", 6)) activate_script_mode = true;
|
||||||
new_buf+=39;
|
SourceBufAdd(TAG, "<font color=#00f><");
|
||||||
i+=8;
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case '>':
|
||||||
if (ESBYTE[i+1]=='!') && (ESBYTE[i+2]=='-') && (ESBYTE[i+3]=='-') {
|
if (TAG == mode) && (activate_script_mode) {
|
||||||
mode = COMMENT;
|
activate_script_mode = false;
|
||||||
strcpy(new_buf, "<font color=#bbb><"); opened_font++;
|
SourceBufAdd(SCRIPT, "></font><font color=#994500>");
|
||||||
new_buf+=21;
|
}
|
||||||
break;
|
else if (VALUE == mode) CloseAllOpenedFonts(TEXT);
|
||||||
}
|
else if (COMMENT == mode) && (!strncmp(i-2,"--", 2)) {
|
||||||
if (mode == TEXT) {
|
SourceBufAdd(TEXT, ">");
|
||||||
mode = TAG;
|
CloseAllOpenedFonts(TEXT);
|
||||||
strcpy(new_buf, "<font color=#00f><"); opened_font++;
|
}
|
||||||
new_buf+=21;
|
else if (COMMENT == mode) || (SCRIPT == mode) SourceBufAdd(NULL, ">");
|
||||||
break;
|
else if (TAG == mode) SourceBufAdd(TEXT, "></font>");
|
||||||
}
|
break;
|
||||||
if (mode == COMMENT) || (mode == SCRIPT) {
|
case '&':
|
||||||
strcpy(new_buf, "<");
|
SourceBufAdd(NULL, "&");
|
||||||
new_buf+=4;
|
break;
|
||||||
break;
|
case '\"':
|
||||||
}
|
case '\'':
|
||||||
break;
|
if (TAG == mode) SourceBufAdd(VALUE, "<font color=#F301F2>'");
|
||||||
case '>':
|
else if (VALUE == mode) SourceBufAdd(TAG, "'</font>");
|
||||||
if (mode == OPTION_VALUE) { //fix non-closed quote in TAG
|
else SourceBufAdd(NULL, "'");
|
||||||
mode = TEXT;
|
break;
|
||||||
while (opened_font) {
|
default:
|
||||||
strcpy(new_buf, ""</font>"); opened_font--;
|
ESBYTE[source_buf_end] = ESBYTE[i];
|
||||||
new_buf+=13;
|
source_buf_end++;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mode == COMMENT) && (ESBYTE[i-1]=='-') && (ESBYTE[i-2]=='-') {
|
|
||||||
mode = TEXT;
|
|
||||||
strcpy(new_buf, "></font>"); opened_font--;
|
|
||||||
new_buf+=11;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mode == COMMENT) || (mode == SCRIPT) {
|
|
||||||
strcpy(new_buf, ">");
|
|
||||||
new_buf+=4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mode == TAG) {
|
|
||||||
mode = TEXT;
|
|
||||||
strcpy(new_buf, "></font>"); opened_font--;
|
|
||||||
new_buf+=11;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '\"':
|
|
||||||
case '\'':
|
|
||||||
if (mode == TAG) {
|
|
||||||
mode = OPTION_VALUE;
|
|
||||||
strcpy(new_buf, "<font color=#F301F2>'"); opened_font++;
|
|
||||||
new_buf+=25;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mode == OPTION_VALUE) {
|
|
||||||
mode = TAG;
|
|
||||||
strcpy(new_buf, "'</font>"); opened_font--;
|
|
||||||
new_buf+=12;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
ESBYTE[new_buf] = ESBYTE[i];
|
|
||||||
new_buf++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ESBYTE[new_buf] = 0;
|
ESBYTE[source_buf_end] = 0;
|
||||||
bufsize = new_buf - new_buf_start;
|
bufsize = source_buf_end - source_buf_start;
|
||||||
free(bufpointer);
|
free(bufpointer);
|
||||||
bufpointer = new_buf_start;
|
bufpointer = source_buf_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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 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>C/C++/C-- source: %s</title><body><pre>",#URL);
|
|
||||||
new_buf += strlen(new_buf);
|
|
||||||
for (i=bufpointer; i<bufpointer+bufsize; i++)
|
|
||||||
{
|
|
||||||
if ('<' == ESBYTE[i]) {
|
|
||||||
strcpy(new_buf, "<");
|
|
||||||
new_buf+=4;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ('>' == ESBYTE[i]) {
|
|
||||||
strcpy(new_buf, ">");
|
|
||||||
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=#777>//");
|
|
||||||
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=#665>/*");
|
|
||||||
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;
|
|
||||||
bufsize = new_buf - new_buf_start;
|
|
||||||
free(bufpointer);
|
|
||||||
bufpointer = new_buf_start;
|
|
||||||
}
|
|
||||||
*/
|
|
@ -193,7 +193,7 @@ void OpenPage()
|
|||||||
if (!strncmp(#URL,"CodeView:",8))
|
if (!strncmp(#URL,"CodeView:",8))
|
||||||
{
|
{
|
||||||
SetPageDefaults();
|
SetPageDefaults();
|
||||||
if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
|
if (!strcmp(#URL, URL_SERVICE_HOME)) LoadInternalPage(#homepage, sizeof(homepage));
|
||||||
DrawEditBoxWebView();
|
DrawEditBoxWebView();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ void OpenPage()
|
|||||||
SetPageDefaults();
|
SetPageDefaults();
|
||||||
ReadFile(0, bufsize, bufpointer, #URL);
|
ReadFile(0, bufsize, bufpointer, #URL);
|
||||||
ShowCodeSource();
|
ShowCodeSource();
|
||||||
WB1.LoadInternalPage(bufpointer, bufsize);
|
LoadInternalPage(bufpointer, bufsize);
|
||||||
}
|
}
|
||||||
ShowPage();
|
ShowPage();
|
||||||
}
|
}
|
||||||
@ -226,18 +226,17 @@ DrawEditBoxWebView()
|
|||||||
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
|
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 ShowPage()
|
void ShowPage()
|
||||||
{
|
{
|
||||||
DrawEditBoxWebView();
|
DrawEditBoxWebView();
|
||||||
if (!bufsize)
|
if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||||
{
|
WB1.Prepare();
|
||||||
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WB1.Prepare();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStatusBar() {return;};
|
void DrawStatusBar() {return;};
|
||||||
|
@ -154,7 +154,7 @@ void DrawTranslation()
|
|||||||
{
|
{
|
||||||
int y_pos=TOPH+1;
|
int y_pos=TOPH+1;
|
||||||
char draw_buf[4096];
|
char draw_buf[4096];
|
||||||
strlcpy(#draw_buf, #translate_result, sizeof(draw_buf));
|
strlcpy(#draw_buf, #translate_result, sizeof(draw_buf)-1);
|
||||||
|
|
||||||
DrawBar(0, y_pos, Form.width-9, Form.cheight - y_pos, 0xFFFFFF);
|
DrawBar(0, y_pos, Form.width-9, Form.cheight - y_pos, 0xFFFFFF);
|
||||||
strttl(#draw_buf);
|
strttl(#draw_buf);
|
||||||
|
@ -28,6 +28,7 @@ char program_path[4096];
|
|||||||
#define bool int
|
#define bool int
|
||||||
|
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
|
#define EOS 0
|
||||||
#define OLD -1
|
#define OLD -1
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
@ -395,37 +395,23 @@ inline fastcall void strcat( EDI, ESI)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:void strncat(dword text1, text2, signed len)
|
:void strncat(dword dst, src, dword len)
|
||||||
signed o1,o2;
|
|
||||||
char s;
|
|
||||||
{
|
{
|
||||||
s = DSBYTE[text1];
|
while (ESBYTE[dst]) dst++;
|
||||||
while(s){
|
while (ESBYTE[src]) && (len) {
|
||||||
$inc text1
|
ESBYTE[dst] = ESBYTE[src];
|
||||||
s = DSBYTE[text1];
|
dst++;
|
||||||
|
src++;
|
||||||
|
len--;
|
||||||
}
|
}
|
||||||
o1 = len/4;
|
|
||||||
o2 = len-4*o1;
|
|
||||||
while(o1){
|
|
||||||
DSDWORD[text1] = DSDWORD[text2];
|
|
||||||
text1 += 4;
|
|
||||||
text2 += 4;
|
|
||||||
$dec o1
|
|
||||||
}
|
|
||||||
while(o2){
|
|
||||||
DSBYTE[text1] = DSBYTE[text2];
|
|
||||||
$inc text1
|
|
||||||
$inc text2
|
|
||||||
$dec o2
|
|
||||||
}
|
|
||||||
DSBYTE[text1] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fastcall void chrcat(ESI, BL)
|
inline fastcall void chrcat(ESI, DI)
|
||||||
{
|
{
|
||||||
EDI = strlen(ESI);
|
while (ESBYTE[ESI]) ESI++;
|
||||||
ESBYTE[ESI+EDI] = BL;
|
ESBYTE[ESI] = DI;
|
||||||
ESBYTE[ESI+EDI+1] = 0;
|
ESI++;
|
||||||
|
ESBYTE[ESI] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline dword strchr(dword shb;char s)
|
inline dword strchr(dword shb;char s)
|
||||||
|
Loading…
Reference in New Issue
Block a user