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 DrawPage();
|
||||
void DrawScroller();
|
||||
void LoadInternalPage();
|
||||
void NewLine();
|
||||
void Perenos();
|
||||
bool CheckForLineBreak();
|
||||
void BufEncode();
|
||||
} WB1;
|
||||
|
||||
@ -97,11 +96,11 @@ void TWebBrowser::DrawStyle()
|
||||
line_length = stolbec_len * list.font_w;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
@ -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 (link) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
DrawStyle();
|
||||
line = NULL;
|
||||
NewLine();
|
||||
break;
|
||||
}
|
||||
@ -193,10 +187,11 @@ void TWebBrowser::Prepare(){
|
||||
}
|
||||
if (bukva = GetUnicodeSymbol(#tag)) {
|
||||
bufpos += j;
|
||||
CheckForLineBreak();
|
||||
} else {
|
||||
bukva = '&';
|
||||
goto DEFAULT_MARK;
|
||||
}
|
||||
goto DEFAULT_MARK;
|
||||
break;
|
||||
case '<':
|
||||
bufpos++;
|
||||
@ -223,6 +218,7 @@ void TWebBrowser::Prepare(){
|
||||
{
|
||||
ignor_param = true;
|
||||
if (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
|
||||
// chrncat(#tagparam, bukva, sizeof(tagparam)-1);
|
||||
}
|
||||
bufpos++;
|
||||
}
|
||||
@ -250,12 +246,11 @@ void TWebBrowser::Prepare(){
|
||||
else opened = 1;
|
||||
|
||||
if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
|
||||
Perenos();
|
||||
CheckForLineBreak();
|
||||
DrawStyle();
|
||||
line = NULL;
|
||||
if (tag) SetStyle();
|
||||
}
|
||||
strlcpy(#oldtag, #tag, sizeof(oldtag));
|
||||
strlcpy(#oldtag, #tag, sizeof(oldtag)-1);
|
||||
tag = attr = tagparam = ignor_param = NULL;
|
||||
break;
|
||||
default:
|
||||
@ -268,7 +263,7 @@ void TWebBrowser::Prepare(){
|
||||
if (!stolbec) && (!line) break; //no paces at the beginning of the line
|
||||
}
|
||||
if (line_len < sizeof(line)) chrcat(#line, bukva);
|
||||
Perenos();
|
||||
CheckForLineBreak();
|
||||
}
|
||||
}
|
||||
DrawStyle();
|
||||
@ -277,21 +272,27 @@ void TWebBrowser::Prepare(){
|
||||
DrawPage();
|
||||
}
|
||||
//============================================================================================
|
||||
void TWebBrowser::Perenos()
|
||||
bool TWebBrowser::CheckForLineBreak()
|
||||
{
|
||||
int perenos_num;
|
||||
int line_break_pos;
|
||||
char new_line_text[4096];
|
||||
if (strlen(#line)*zoom + stolbec < list.column_max) return;
|
||||
perenos_num = strrchr(#line, ' ');
|
||||
if (!perenos_num) && (strlen(#line)*zoom>list.column_max) {
|
||||
perenos_num=list.column_max/zoom;
|
||||
if (strlen(#line)*zoom + stolbec < list.column_max) return false;
|
||||
line_break_pos = strrchr(#line, ' ');
|
||||
if (line_break_pos*zoom + stolbec > list.column_max) {
|
||||
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
|
||||
}
|
||||
strcpy(#new_line_text, #line + perenos_num);
|
||||
line[perenos_num] = 0x00;
|
||||
strcpy(#new_line_text, #line + line_break_pos);
|
||||
line[line_break_pos] = 0x00;
|
||||
DrawStyle();
|
||||
strcpy(#line, #new_line_text);
|
||||
NewLine();
|
||||
//if (strlen(#line)*zoom + stolbec > list.column_max)CheckForLineBreak();
|
||||
return true;
|
||||
}
|
||||
//============================================================================================
|
||||
void TWebBrowser::SetStyle() {
|
||||
@ -309,7 +310,11 @@ void TWebBrowser::SetStyle() {
|
||||
|
||||
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, "\" ");
|
||||
return;
|
||||
}
|
||||
@ -404,11 +409,11 @@ void TWebBrowser::SetStyle() {
|
||||
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
|
||||
if (istag("img")) {
|
||||
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("alt=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
|
||||
} while(GetNextParam());
|
||||
if (!img_path) return;
|
||||
if (!img_path) { line=0; return; }
|
||||
style.image = true;
|
||||
text_color_index++;
|
||||
text_colors[text_color_index] = 0x9A6F29;
|
||||
@ -418,9 +423,8 @@ void TWebBrowser::SetStyle() {
|
||||
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
|
||||
line[50]= NULL;
|
||||
}
|
||||
if (strlen(#line) + stolbec > list.column_max) Perenos();
|
||||
while (CheckForLineBreak()) {};
|
||||
DrawStyle();
|
||||
line=0;
|
||||
text_color_index--;
|
||||
style.image = false;
|
||||
//ImgCache.Images( left1, draw_y, WB1.list.w);
|
||||
@ -559,6 +563,7 @@ void TWebBrowser::NewLine()
|
||||
draw_y += list.item_h;
|
||||
if (style.blq) stolbec = 6; else stolbec = 0;
|
||||
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; }
|
||||
|
@ -14,9 +14,8 @@ void GetAbsoluteURL(dword in_URL)
|
||||
|
||||
IF (!strncmp(in_URL,"//", 2))
|
||||
{
|
||||
//strcpy(#newurl, "http:");
|
||||
//strcat(#newurl, in_URL);
|
||||
sprintf(#newurl, "http:%s", in_URL);
|
||||
strcpy(#newurl, "http:");
|
||||
strcat(#newurl, in_URL);
|
||||
strcpy(orig_URL, #newurl);
|
||||
return;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ bool GetNextParam()
|
||||
if (!tagparam) return false;
|
||||
|
||||
if (debug_mode) {
|
||||
debug("tag: "); debugln(#tag);
|
||||
debug("tagparam: "); debugln(#tagparam);
|
||||
}
|
||||
|
||||
@ -23,7 +24,7 @@ bool GetNextParam()
|
||||
|
||||
//find VAL start and copy
|
||||
i = strrchr(#tagparam, quotes);
|
||||
strlcpy(#val, #tagparam + i, sizeof(val));
|
||||
strlcpy(#val, #tagparam + i, sizeof(val)-1);
|
||||
tagparam[i] = '\0'; i--;
|
||||
|
||||
//find ATTR end
|
||||
@ -38,8 +39,8 @@ bool GetNextParam()
|
||||
//find VAL start and copy
|
||||
while (i > 0) && (tagparam[i] != '=') i--;
|
||||
i++;
|
||||
strlcpy(#val, #tagparam + i, sizeof(val));
|
||||
tagparam[i] = '\0';
|
||||
strlcpy(#val, #tagparam + i, sizeof(val)-1);
|
||||
// tagparam[i] = '\0';
|
||||
|
||||
//find ATTR end
|
||||
//already have
|
||||
@ -47,20 +48,22 @@ bool GetNextParam()
|
||||
|
||||
//find ATTR start and copy
|
||||
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';
|
||||
|
||||
//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);
|
||||
|
||||
if (debug_mode) {
|
||||
if (quotes) {
|
||||
debug("quote: "); debugch(quotes); debugln(" ");
|
||||
}
|
||||
else {
|
||||
debugln("unquoted text");
|
||||
}
|
||||
sprintf(#param, "val: %s\nattr: %s\n\n", #val, #attr);
|
||||
debug(#param);
|
||||
debug("val: "); debugln(#val);
|
||||
debug("attr: "); debugln(#attr);
|
||||
debugln(" ");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -65,11 +65,11 @@ char *unicode_tags[]={
|
||||
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)
|
||||
{
|
||||
int j;
|
||||
int j, specia1040;
|
||||
|
||||
for (j=0; unicode_tags[j]!=0; j+=2;)
|
||||
{
|
||||
@ -80,10 +80,19 @@ bool GetUnicodeSymbol(dword in_tag)
|
||||
}
|
||||
}
|
||||
|
||||
j = atoi(in_tag + 1) - 1040;
|
||||
if (tag[1] == '1') && (j>=0) && (j<=72) && (strlen(in_tag) == 5)
|
||||
specia1040 = atoi(in_tag + 1) - 1040;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,8 @@
|
||||
#include "..\lib\patterns\http_downloader.h"
|
||||
#include "..\lib\patterns\simple_open_dialog.h"
|
||||
|
||||
_http http = {0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.93";
|
||||
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.94";
|
||||
#define T_LOADING "‡ £à㧪 áâà ¨æë..."
|
||||
#define T_RENDERING "<22>¥¤¥à¨£..."
|
||||
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
||||
@ -48,7 +45,7 @@ char link_menu[] =
|
||||
"Š®¯¨à®¢ âì áá뫪ã
|
||||
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
|
||||
#else
|
||||
char version[]="Text-based Browser 1.93";
|
||||
char version[]="Text-based Browser 1.94";
|
||||
#define T_LOADING "Loading..."
|
||||
#define T_RENDERING "Rendering..."
|
||||
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
|
||||
@ -65,31 +62,34 @@ char link_menu[] =
|
||||
Download link contents";
|
||||
#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 panel_color = 0xE3E2E2;
|
||||
dword border_color = 0x8C8C8C;
|
||||
|
||||
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;
|
||||
|
||||
bool souce_mode = false;
|
||||
bool open_in_a_new_window = false;
|
||||
char stak[4096];
|
||||
proc_info Form;
|
||||
|
||||
enum {
|
||||
BACK_BUTTON=1000,
|
||||
@ -97,19 +97,14 @@ enum {
|
||||
REFRESH_BUTTON,
|
||||
GOTOURL_BUTTON,
|
||||
SANDWICH_BUTTON,
|
||||
VIEW_SOURCE=1100,
|
||||
VIEW_SOURCE,
|
||||
EDIT_SOURCE,
|
||||
VIEW_HISTORY,
|
||||
DOWNLOAD_MANAGER,
|
||||
COPY_LINK_URL=1200,
|
||||
COPY_LINK_URL,
|
||||
DOWNLOAD_LINK_CONTENTS,
|
||||
};
|
||||
|
||||
#include "..\TWB\TWB.c"
|
||||
#include "history.h"
|
||||
#include "show_src.h"
|
||||
#include "download_manager.h"
|
||||
|
||||
char default_dir[] = "/rd/1";
|
||||
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
||||
|
||||
@ -132,10 +127,13 @@ void LoadLibraries()
|
||||
void HandleParam()
|
||||
{
|
||||
if (param) {
|
||||
if (param[0]=='-') && (param[1]=='d') {
|
||||
if (!strncmp(#param, "-d ", 3)) {
|
||||
strcpy(#downloader_edit, #param+3);
|
||||
CreateThread(#Downloader,#downloader_stak+4092);
|
||||
ExitProcess();
|
||||
} else if (!strncmp(#param, "-s ", 3)) {
|
||||
source_mode = true;
|
||||
strcpy(#URL, #param + 3);
|
||||
} else {
|
||||
strcpy(#URL, #param);
|
||||
}
|
||||
@ -185,7 +183,7 @@ void main()
|
||||
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
||||
if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
|
||||
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)
|
||||
|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
|
||||
if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
|
||||
@ -224,7 +222,7 @@ void main()
|
||||
ProcessEvent(menu.cur_y);
|
||||
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);
|
||||
system.color.get();
|
||||
col_bg = system.color.work;
|
||||
@ -359,17 +357,15 @@ void ProcessEvent(dword id__)
|
||||
EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
|
||||
return;
|
||||
case VIEW_SOURCE:
|
||||
WB1.list.first = 0;
|
||||
ShowSource();
|
||||
WB1.LoadInternalPage(bufpointer, bufsize);
|
||||
EventViewSource();
|
||||
break;
|
||||
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");
|
||||
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
|
||||
}
|
||||
else RunProgram("/rd/1/tinypad", #URL);
|
||||
return;
|
||||
case VIEW_HISTORY:
|
||||
strcpy(#URL, URL_SERVICE_HISTORY);
|
||||
@ -444,14 +440,13 @@ void OpenPage()
|
||||
{
|
||||
char getUrl[sizeof(URL)];
|
||||
StopLoading();
|
||||
souce_mode = false;
|
||||
strcpy(#editURL, #URL);
|
||||
history.add(#URL);
|
||||
if (!strncmp(#URL,"WebView:",8))
|
||||
{
|
||||
SetPageDefaults();
|
||||
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
|
||||
else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help));
|
||||
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)-1);
|
||||
else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)-1);
|
||||
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
|
||||
else {bufsize=0; ShowPage();} //page not found
|
||||
DrawOmnibox();
|
||||
@ -500,7 +495,7 @@ void ProcessAnchor()
|
||||
int anchor_pos;
|
||||
|
||||
anchor_pos = strrchr(#URL, '#')-1;
|
||||
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor));
|
||||
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1);
|
||||
URL[anchor_pos] = 0x00;
|
||||
|
||||
//#1
|
||||
@ -626,25 +621,30 @@ void DrawOmnibox()
|
||||
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.offset = 0;
|
||||
if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
|
||||
EditBox_UpdateText(#address_box, address_box.flags);
|
||||
edit_box_draw stdcall(#address_box);
|
||||
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);
|
||||
}
|
||||
|
||||
void LoadInternalPage(dword bufpos, in_filesize){
|
||||
bufsize = in_filesize;
|
||||
bufpointer = bufpos;
|
||||
ShowPage();
|
||||
}
|
||||
|
||||
void ShowPage()
|
||||
{
|
||||
DrawOmnibox();
|
||||
if (!bufsize)
|
||||
{
|
||||
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||
if (!bufsize) || (!bufpointer) {
|
||||
LoadInternalPage(#page_not_found, sizeof(page_not_found)-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
WB1.Prepare();
|
||||
WB1.Prepare();
|
||||
if (source_mode) {
|
||||
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)
|
||||
{
|
||||
status_text.start_x = 10;
|
||||
|
@ -23,37 +23,37 @@
|
||||
|
||||
ShowHistory()
|
||||
{
|
||||
int i;
|
||||
static int history_pointer;
|
||||
int t;
|
||||
int i;
|
||||
static int history_pointer;
|
||||
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);
|
||||
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>");
|
||||
|
||||
// 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));
|
||||
// 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>");
|
||||
LoadInternalPage(history_pointer, strlen(history_pointer));
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
3. <a href="http://store.kolibri-n.org">Kolibri Store</a>
|
||||
|
||||
<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>
|
||||
|
@ -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 new_buf, new_buf_start, i, j;
|
||||
int opened_font=0;
|
||||
int mode = TEXT;
|
||||
dword i, j;
|
||||
bool activate_script_mode = false;
|
||||
|
||||
if (souce_mode) return;
|
||||
souce_mode = true;
|
||||
new_buf = malloc(bufsize*5);
|
||||
new_buf_start = new_buf;
|
||||
opened_font=0;
|
||||
source_buf_start = source_buf_end = malloc(bufsize*5);
|
||||
header[strrchr(#header, '-')-2]=0;
|
||||
sprintf(new_buf,"<html><head><title>Source: %s</title><body><pre>",#header);
|
||||
new_buf += strlen(new_buf);
|
||||
for (i=bufpointer; i<bufpointer+bufsize; i++)
|
||||
|
||||
SourceBufAdd(TEXT, "<html><head><title>Source: ");
|
||||
SourceBufAdd(TEXT, #header);
|
||||
SourceBufAdd(TEXT, "</title><body><pre>");
|
||||
|
||||
for (i=bufpointer; i<bufpointer+bufsize; i++) switch (ESBYTE[i])
|
||||
{
|
||||
switch (ESBYTE[i])
|
||||
{
|
||||
case '<':
|
||||
if (mode == TEXT) && (!strncmp(i+1,"script", 6)) {
|
||||
mode = SCRIPT;
|
||||
strcpy(new_buf, "<font color=#00f><script</font><font color=#994500>"); opened_font++;
|
||||
new_buf+=54;
|
||||
i+=6;
|
||||
break;
|
||||
case '<':
|
||||
if (!strncmp(i+1,"!--", 3)) SourceBufAdd(COMMENT, "<font color=#bbb><");
|
||||
else if (SCRIPT == mode) {
|
||||
if (!strncmp(i+1,"/script>", 8)) {
|
||||
CloseAllOpenedFonts(NULL);
|
||||
SourceBufAdd(TAG, "<font color=#00f><");
|
||||
}
|
||||
if (mode == COMMENT) || (mode == SCRIPT) && (!strncmp(i+1,"/script>", 8)) {
|
||||
mode = TEXT;
|
||||
while (opened_font) {
|
||||
strcpy(new_buf, "</font>"); opened_font--;
|
||||
new_buf+=7;
|
||||
}
|
||||
strcpy(new_buf, "<font color=#00f></script></font>");
|
||||
new_buf+=39;
|
||||
i+=8;
|
||||
break;
|
||||
}
|
||||
if (ESBYTE[i+1]=='!') && (ESBYTE[i+2]=='-') && (ESBYTE[i+3]=='-') {
|
||||
mode = COMMENT;
|
||||
strcpy(new_buf, "<font color=#bbb><"); opened_font++;
|
||||
new_buf+=21;
|
||||
break;
|
||||
}
|
||||
if (mode == TEXT) {
|
||||
mode = TAG;
|
||||
strcpy(new_buf, "<font color=#00f><"); opened_font++;
|
||||
new_buf+=21;
|
||||
break;
|
||||
}
|
||||
if (mode == COMMENT) || (mode == SCRIPT) {
|
||||
strcpy(new_buf, "<");
|
||||
new_buf+=4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if (mode == OPTION_VALUE) { //fix non-closed quote in TAG
|
||||
mode = TEXT;
|
||||
while (opened_font) {
|
||||
strcpy(new_buf, ""</font>"); opened_font--;
|
||||
new_buf+=13;
|
||||
}
|
||||
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++;
|
||||
}
|
||||
else SourceBufAdd(NULL, "<");
|
||||
}
|
||||
else if (COMMENT == mode) {
|
||||
SourceBufAdd(NULL, "<");
|
||||
}
|
||||
else if (TEXT == mode) {
|
||||
if (!strncmp(i+1,"script", 6)) activate_script_mode = true;
|
||||
SourceBufAdd(TAG, "<font color=#00f><");
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if (TAG == mode) && (activate_script_mode) {
|
||||
activate_script_mode = false;
|
||||
SourceBufAdd(SCRIPT, "></font><font color=#994500>");
|
||||
}
|
||||
else if (VALUE == mode) CloseAllOpenedFonts(TEXT);
|
||||
else if (COMMENT == mode) && (!strncmp(i-2,"--", 2)) {
|
||||
SourceBufAdd(TEXT, ">");
|
||||
CloseAllOpenedFonts(TEXT);
|
||||
}
|
||||
else if (COMMENT == mode) || (SCRIPT == mode) SourceBufAdd(NULL, ">");
|
||||
else if (TAG == mode) SourceBufAdd(TEXT, "></font>");
|
||||
break;
|
||||
case '&':
|
||||
SourceBufAdd(NULL, "&");
|
||||
break;
|
||||
case '\"':
|
||||
case '\'':
|
||||
if (TAG == mode) SourceBufAdd(VALUE, "<font color=#F301F2>'");
|
||||
else if (VALUE == mode) SourceBufAdd(TAG, "'</font>");
|
||||
else SourceBufAdd(NULL, "'");
|
||||
break;
|
||||
default:
|
||||
ESBYTE[source_buf_end] = ESBYTE[i];
|
||||
source_buf_end++;
|
||||
}
|
||||
ESBYTE[new_buf] = 0;
|
||||
bufsize = new_buf - new_buf_start;
|
||||
ESBYTE[source_buf_end] = 0;
|
||||
bufsize = source_buf_end - source_buf_start;
|
||||
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))
|
||||
{
|
||||
SetPageDefaults();
|
||||
if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
|
||||
if (!strcmp(#URL, URL_SERVICE_HOME)) LoadInternalPage(#homepage, sizeof(homepage));
|
||||
DrawEditBoxWebView();
|
||||
return;
|
||||
}
|
||||
@ -208,7 +208,7 @@ void OpenPage()
|
||||
SetPageDefaults();
|
||||
ReadFile(0, bufsize, bufpointer, #URL);
|
||||
ShowCodeSource();
|
||||
WB1.LoadInternalPage(bufpointer, bufsize);
|
||||
LoadInternalPage(bufpointer, bufsize);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void LoadInternalPage(dword bufpos, in_filesize){
|
||||
bufsize = in_filesize;
|
||||
bufpointer = bufpos;
|
||||
ShowPage();
|
||||
}
|
||||
|
||||
void ShowPage()
|
||||
{
|
||||
DrawEditBoxWebView();
|
||||
if (!bufsize)
|
||||
{
|
||||
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||
}
|
||||
else
|
||||
{
|
||||
WB1.Prepare();
|
||||
}
|
||||
if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||
WB1.Prepare();
|
||||
}
|
||||
|
||||
void DrawStatusBar() {return;};
|
||||
|
@ -154,7 +154,7 @@ void DrawTranslation()
|
||||
{
|
||||
int y_pos=TOPH+1;
|
||||
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);
|
||||
strttl(#draw_buf);
|
||||
|
@ -28,6 +28,7 @@ char program_path[4096];
|
||||
#define bool int
|
||||
|
||||
#define NULL 0
|
||||
#define EOS 0
|
||||
#define OLD -1
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
@ -395,37 +395,23 @@ inline fastcall void strcat( EDI, ESI)
|
||||
}
|
||||
}
|
||||
|
||||
:void strncat(dword text1, text2, signed len)
|
||||
signed o1,o2;
|
||||
char s;
|
||||
:void strncat(dword dst, src, dword len)
|
||||
{
|
||||
s = DSBYTE[text1];
|
||||
while(s){
|
||||
$inc text1
|
||||
s = DSBYTE[text1];
|
||||
while (ESBYTE[dst]) dst++;
|
||||
while (ESBYTE[src]) && (len) {
|
||||
ESBYTE[dst] = ESBYTE[src];
|
||||
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);
|
||||
ESBYTE[ESI+EDI] = BL;
|
||||
ESBYTE[ESI+EDI+1] = 0;
|
||||
while (ESBYTE[ESI]) ESI++;
|
||||
ESBYTE[ESI] = DI;
|
||||
ESI++;
|
||||
ESBYTE[ESI] = 0;
|
||||
}
|
||||
|
||||
inline dword strchr(dword shb;char s)
|
||||
|
Loading…
Reference in New Issue
Block a user