WebView 1.85: russification, new feature to search the web, allow to set background color of the text, add help page, more hotkeys

Pixie: better icon of audio button

git-svn-id: svn://kolibrios.org@7743 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-03-21 18:49:45 +00:00
parent ce732ebdd3
commit a1815a31ee
13 changed files with 162 additions and 53 deletions

View File

@ -13,6 +13,8 @@ bool
button,
image,
align;
dword
bg_color;
};
struct TWebBrowser {
@ -47,7 +49,7 @@ dword text_colors[300];
dword text_color_index;
dword link_color_inactive;
dword link_color_active;
dword bg_color;
dword page_bg;
int draw_y;
int stolbec;
@ -93,8 +95,12 @@ void TWebBrowser::DrawStyle()
stolbec_len = strlen(#line) * zoom;
line_length = stolbec_len * list.font_w;
if (style.bg_color!=page_bg) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color);
}
if (style.image) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xF9DBCB);
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB);
}
if (style.button) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
@ -130,8 +136,9 @@ void TWebBrowser::Prepare(){
style.align = ALIGN_LEFT;
link_color_inactive = 0x0000FF;
link_color_active = 0xFF0000;
bg_color = 0xFFFFFF;
DrawBuf.Fill(0, bg_color);
page_bg = 0xFFFFFF;
style.bg_color = page_bg;
DrawBuf.Fill(0, page_bg);
PageLinks.Clear();
strcpy(#header, #version);
draw_y = body_magrin;
@ -300,8 +307,8 @@ void TWebBrowser::SetStyle() {
if (isattr("text=")) text_colors[0]=GetColor(#val);
if (isattr("bgcolor="))
{
bg_color = GetColor(#val);
DrawBuf.Fill(0, bg_color);
style.bg_color = page_bg = GetColor(#val);
DrawBuf.Fill(0, page_bg);
}
} while(GetNextParam());
if (opened) && (cur_encoding==CH_NULL) {
@ -340,12 +347,14 @@ void TWebBrowser::SetStyle() {
return;
}
if (istag("font")) {
style.bg_color = page_bg;
if (opened)
{
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
do{
if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
if (isattr("bg=")) style.bg_color = GetColor(#val);
} while(GetNextParam());
}
else if (text_color_index > 0) text_color_index--;
@ -426,8 +435,9 @@ void TWebBrowser::SetStyle() {
if (opened)
{
NewLine();
stolbec = style.li_tab * 5 - 2;
strcpy(#line, "\31 ");
stolbec-=2;
//stolbec-=2;
}
return;
}

View File

@ -67,8 +67,8 @@ void ImageCache::Images(dword left1, top1, width1)
if (imgh<=0) return;
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, bg_color);
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, bg_color);
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);

View File

@ -93,7 +93,7 @@ bool LinksArray::HoverAndProceed(dword mx, my)
if (links[active].underline) DrawBar(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) DrawBar(links[i].x, -WB1.list.first + links[i].y
+ links[i].h, links[i].w, links[i].underline_h, bg_color);
+ links[i].h, links[i].w, links[i].underline_h, page_bg);
active = i;
DrawStatusBar(links[active].link);
return true;

View File

@ -28,14 +28,15 @@
_http http = {0, 0, 0, 0, 0, 0, 0};
char homepage[] = FROM "html\\homepage.htm""\0";
#ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.84";
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.85";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
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";
char accept_language[]= "Accept-Language: ru\n";
char rmb_menu[] =
"<EFBFBD>®á¬®âà¥âì ¨á室­¨ª
@ -46,11 +47,13 @@ char link_menu[] =
"Š®¯¨à®¢ âì áá뫪ã
ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
#else
char version[]="Text-based Browser 1.84";
char version[]="Text-based Browser 1.85";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...<br>";
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";
char accept_language[]= "Accept-Language: en\n";
char rmb_menu[] =
"View source
@ -64,7 +67,8 @@ Download link contents";
#define URL_SERVICE_HISTORY "WebView://history"
#define URL_SERVICE_HOME "WebView://home"
#define URL_SERVICE_HOMEPAGE "WebView://home"
#define URL_SERVICE_HELP "WebView://help"
#define URL_SERVICE_SOURCE "WebView://source:"
proc_info Form;
@ -132,7 +136,7 @@ void main()
CreateThread(#Downloader,#downloader_stak+4092);
ExitProcess();
}
else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOMEPAGE);
WB1.list.SetFont(8, 14, 10011000b);
WB1.list.no_selection = true;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
@ -169,7 +173,14 @@ void main()
|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb();
if (key_scancode == SCAN_CODE_LEFT) ProcessEvent(BACK_BUTTON);
if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON);
}
if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
if (address_box.flags & ed_focus)
{
if (key_scancode == SCAN_CODE_ENTER) {
@ -185,6 +196,7 @@ void main()
#define KEY_SCROLL_N 11
if (SCAN_CODE_UP == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyUp();
if (SCAN_CODE_DOWN == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyDown();
if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
else ProcessEvent(key_scancode);
}
@ -224,7 +236,7 @@ void main()
GetAbsoluteURL(#http.redirect_url);
history.back();
strcpy(#editURL, #URL);
DrawEditBoxWebView();
DrawOmnibox();
OpenPage();
//ProcessLink(history.current());
}
@ -280,7 +292,7 @@ void Draw_Window()
OpenPage();
else {
WB1.DrawPage();
DrawEditBoxWebView();
DrawOmnibox();
}
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
DrawProgress();
@ -388,7 +400,7 @@ void StopLoading()
bufpointer = free(bufpointer);
}
wv_progress_bar.value = 0;
DrawEditBoxWebView();
DrawOmnibox();
}
void SetPageDefaults()
@ -423,10 +435,11 @@ void OpenPage()
if (!strncmp(#URL,"WebView:",8))
{
SetPageDefaults();
if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help));
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
else {bufsize=0; ShowPage();} //page not found
DrawEditBoxWebView();
DrawOmnibox();
return;
}
if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8))
@ -497,7 +510,7 @@ void ProcessAnchor()
WB1.DrawPage();
strcpy(#editURL, #URL);
strcat(#editURL, #anchor);
DrawEditBoxWebView();
DrawOmnibox();
}
void EventSubmitOmnibox()
@ -593,7 +606,7 @@ void ProcessLink()
open_in_a_new_window = false;
}
void DrawEditBoxWebView()
void DrawOmnibox()
{
int skin_x_offset;
DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
@ -609,7 +622,7 @@ void DrawEditBoxWebView()
void ShowPage()
{
DrawEditBoxWebView();
DrawOmnibox();
if (!bufsize)
{
if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
@ -655,6 +668,12 @@ void EventUpdateProgressBar()
}
}
void EventSeachWeb()
{
sprintf(#URL, "https://www.google.com/search?q=%s", #editURL);
ProcessLink();
}
void DrawStatusBar(dword _status_text)
{
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;

View File

@ -1,3 +1,26 @@
#ifdef LANG_RUS
#define HISTORY_HEADER "<html>
<head>
<title>ˆáâ®à¨ï</title>
</head>
<body>
<h1>ˆáâ®à¨ï</h1>
<br>
<b><EFBFBD>®á¥é¥­­ë¥ áâà ­¨æë</b><br>
"
#else
#define HISTORY_HEADER "<html>
<head>
<title>History</title>
</head>
<body>
<h1>History</h1>
<br>
<b>Visited pages</b><br>
"
#endif
ShowHistory()
{
int i;
@ -6,16 +29,16 @@ ShowHistory()
free(history_pointer);
history_pointer = malloc(history.items.data_size+256);
strcat(history_pointer, "<html><head><title>History</title></head><body><h1>History</h1>");
strcat(history_pointer, "<br><b>Visited pages</b><br>");
strcat(history_pointer, HISTORY_HEADER);
for (i=0; i<history.items.count; i++)
{
strcat(history_pointer, "<a href='");
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++)
{
@ -24,13 +47,13 @@ ShowHistory()
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, "<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));
}

View File

@ -0,0 +1,23 @@
<html>
<head>
<meta charset="uft">
<title>WebView Help</title>
</head>
<body><pre><h1>WebView Help</h1>
<b>Shortcut keys</b>
<font bg="#C7CEE4">[CTRL + N or CTRL + T]</font> New window
<font bg="#C7CEE4">[CTRL + R or F5]</font> Refresh the current page
<font bg="#C7CEE4">[CTRL + U]</font> View a web page's source code
<font bg="#C7CEE4">[CTRL + H]</font> Open browser history
<font bg="#C7CEE4">[CTRL + J]</font> Display the file downloader
<font bg="#C7CEE4">[CTRL + W]</font> Exit browser
<font bg="#C7CEE4">[CTRL + ENTER]</font> Submit a web search
<font bg="#C7CEE4">[CTRL + LEFT]</font> Back a page.
<font bg="#C7CEE4">[CTRL + RIGHT]</font> Forward a page.
<font bg="#C7CEE4">[F6]</font> Moves a text cursor to the omnibox
</pre>
</body>
</html>

View File

@ -0,0 +1,20 @@
<html>
<head>
<meta charset="cp-866">
<title>‘¯à ¢ª  WebView</title>
</head>
<body><pre><h1>‘¯à ¢ª  WebView</h1>
<font bg="#C7CEE4">[CTRL + N ¨«¨ CTRL + T]</font> <20>®¢®¥ ®ª­®
<font bg="#C7CEE4">[CTRL + R ¨«¨ F5]</font> <20>¥à¥§ £à㧨âì áâà ­¨æã
<font bg="#C7CEE4">[CTRL + U]</font> ‘¬®âà¥âì ¨á室­ë© ª®¤ áâà ­¨æë
<font bg="#C7CEE4">[CTRL + H]</font> ‘¬®âà¥âì ¨áâ®à¨î ¯®á¥é¥­­ëå áâà ­¨æ
<font bg="#C7CEE4">[CTRL + J]</font> Žâªàëâì § £àã§ç¨ª ä ©«®¢
<font bg="#C7CEE4">[CTRL + W]</font> ‡ ªàëâì ¡à ã§¥à
<font bg="#C7CEE4">[CTRL + ENTER]</font> <20>®¨áª ¢ ¨­â¥à­¥â¥ á ¯®¬®éìî Google
<font bg="#C7CEE4">[CTRL + ‚‹…‚Ž]</font> €­ «®£¨ç­® ª­®¯ª¥ "<22> § ¤" ¢ ¡à ã§¥à¥
<font bg="#C7CEE4">[CTRL + <><E2809A>Ž]</font> €­ «®£¨ç­® ª­®¯ª¥ "‚¯¥à¥¤"
<font bg="#C7CEE4">[F6]</font> <20>¥à¥¬¥é ¥â ⥪áâ®¢ë© ªãàá®à ¢ ®¬­¨¡®ªá
</pre>
</body>
</html>

View File

@ -1,15 +0,0 @@
<html>
<head>
<title>Homepage</title>
</head>
<body>
<br>
Bookmarks:<br>
1. <a href="http://kolibrios.org">KolibriOS homepage</a><br>
2. <a href="http://kolibri-n.org">KolibriN homepage</a><br>
3. <a href="http://store.kolibri-n.org">Kolibri Stuff</a>
</body>
</html>

View File

@ -0,0 +1,17 @@
<html>
<head>
<meta charset="uft">
<title>Homepage</title>
</head>
<body><pre>Bookmarks:
1. <a href="http://kolibrios.org" id="valera">KolibriOS homepage</a>
2. <a href="http://kolibri-n.org" id="hodor">KolibriN homepage</a>
3. <a href="http://store.kolibri-n.org">Kolibri Stuff</a>
<font color="#555555">Hint: to run a web search, type a text in the adress box
and press Ctrl+Enter. You can also use other <a href="WebView://help"><font color="#555555">Hotkeys</font></a>.</font>
</pre>
</body>
</html>

View File

@ -0,0 +1,17 @@
<html>
<head>
<meta charset="cp-866">
<title>„®¬ è­ïï áâà ­¨æ </title>
</head>
<body><pre>‡ ª« ¤ª¨:
1. <a href="http://kolibrios.org" id="valera">„®¬ è­ïï áâà ­¨æ  KolibriOS</a>
2. <a href="http://kolibri-n.org" id="hodor">KolibriN10</a>
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>
</pre>
</body>
</html>

View File

@ -3,8 +3,6 @@
char *file_captions[] = {
"Žâªàëâì", "Enter",100,
"Žâªàëâì á ¯®¬®éìî...", "CrlEnt",201,
"Žâªàëâì ª ª ⥪áâ", "F3",202,
"Žâªàëâì ª ª HEX", "F4",203,
"Š®¯¨à®¢ âì", "Crl+C",104,
"‚ë१ âì", "Crl+X",105,
"‚áâ ¢¨âì", "Crl+V",106,
@ -17,8 +15,6 @@ char *file_captions[] = {
char *file_captions[] = {
"Ava", "Enter",100,
"Ava ...", "CrlEnt",201,
"Vaata tekstina", "F3",202,
"Vaata HEX", "F4",203,
"Kopeeri", "Crl+C",104,
"Lõika", "Crl+X",105,
"Aseta", "Crl+V",106,
@ -31,8 +27,6 @@ char *file_captions[] = {
char *file_captions[] = {
"Open", "Enter",100,
"Open with...", "CrlEnt",201,
"View as text", "F3",202,
"View as HEX", "F4",203,
"Copy", "Crl+C",104,
"Cut", "Crl+X",105,
"Paste", "Crl+V",106,

View File

@ -176,6 +176,7 @@ int check_is_the_url_absolute(dword _in)
if(!strncmp(_in,"mailto:",7)) return true;
if(!strncmp(_in,"tel:",4)) return true;
if(!strncmp(_in,"#",1)) return true;
if(!strncmp(_in,"WebView:",8)) return true;
if(check_is_the_adress_local(_in)) return true;
return false;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB