forked from KolibriOS/kolibrios
WebView unstable: big headers, refactoring
git-svn-id: svn://kolibrios.org@5768 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
cdc2991cc4
commit
0c41783078
@ -6,7 +6,7 @@ enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
|||||||
|
|
||||||
struct _style {
|
struct _style {
|
||||||
byte
|
byte
|
||||||
b, i, u, s,
|
b, i, u, s, h,
|
||||||
pre,
|
pre,
|
||||||
blq,
|
blq,
|
||||||
li,
|
li,
|
||||||
@ -17,7 +17,6 @@ byte
|
|||||||
struct TWebBrowser {
|
struct TWebBrowser {
|
||||||
llist list;
|
llist list;
|
||||||
_style style;
|
_style style;
|
||||||
dword draw_line_width;
|
|
||||||
DrawBufer DrawBuf;
|
DrawBufer DrawBuf;
|
||||||
void Prepare();
|
void Prepare();
|
||||||
void SetStyle();
|
void SetStyle();
|
||||||
@ -59,9 +58,10 @@ char header[2048];
|
|||||||
char line[500];
|
char line[500];
|
||||||
char tagparam[10000];
|
char tagparam[10000];
|
||||||
char tag[100];
|
char tag[100];
|
||||||
|
char oldtag[100];
|
||||||
char attr[1200];
|
char attr[1200];
|
||||||
char val[4096];
|
char val[4096];
|
||||||
char anchor[256];
|
char anchor[256]=0;
|
||||||
|
|
||||||
#include "..\TWB\history.h"
|
#include "..\TWB\history.h"
|
||||||
#include "..\TWB\links.h"
|
#include "..\TWB\links.h"
|
||||||
@ -91,9 +91,10 @@ void TWebBrowser::DrawStyle()
|
|||||||
{
|
{
|
||||||
start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x;
|
start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x;
|
||||||
start_y = stroka * list.line_h + body_magrin;
|
start_y = stroka * list.line_h + body_magrin;
|
||||||
stolbec_len = utf8_strlen(#line);
|
stolbec_len = utf8_strlen(#line) * DrawBuf.zoom;
|
||||||
line_length = stolbec_len * list.font_w * DrawBuf.zoom;
|
line_length = stolbec_len * list.font_w;
|
||||||
|
|
||||||
|
if (style.h) stroka++;
|
||||||
WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
|
WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
|
||||||
if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
|
if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
|
||||||
if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.line_h); } // bug with zoom>1
|
if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.line_h); } // bug with zoom>1
|
||||||
@ -122,7 +123,7 @@ void TWebBrowser::Prepare(){
|
|||||||
dword bufpos = bufpointer;
|
dword bufpos = bufpointer;
|
||||||
int line_len;
|
int line_len;
|
||||||
|
|
||||||
style.b = style.i = style.u = style.s = style.blq = t_html = t_body =
|
style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body =
|
||||||
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
|
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
|
||||||
style.align = ALIGN_LEFT;
|
style.align = ALIGN_LEFT;
|
||||||
link_color_inactive = 0x0000FF;
|
link_color_inactive = 0x0000FF;
|
||||||
@ -135,22 +136,16 @@ void TWebBrowser::Prepare(){
|
|||||||
stolbec = 0;
|
stolbec = 0;
|
||||||
line = 0;
|
line = 0;
|
||||||
|
|
||||||
draw_line_width = list.w * DrawBuf.zoom;
|
|
||||||
|
|
||||||
//for plaint text use CP866 for other UTF
|
//for plaint text use CP866 for other UTF
|
||||||
if (strstri(bufpointer, "html"))
|
if (strstri(bufpointer, "html"))
|
||||||
{
|
{
|
||||||
style.pre = 0;
|
style.pre = 0;
|
||||||
cur_encoding = CH_CP866;
|
cur_encoding = CH_CP866;
|
||||||
//WB1.list.SetFont(8, 14, 10111000b);
|
|
||||||
//list.line_h = list.font_h + 4;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
style.pre = 1;
|
style.pre = 1;
|
||||||
cur_encoding = CH_UTF8;
|
cur_encoding = CH_UTF8;
|
||||||
//WB1.list.SetFont(8, 14, 10001000b);
|
|
||||||
//list.line_h = list.font_h + 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
|
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
|
||||||
@ -189,24 +184,12 @@ void TWebBrowser::Prepare(){
|
|||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
bufpos++;
|
bufpos++;
|
||||||
|
if (!strncmp(bufpos,"!--",3))
|
||||||
|
{
|
||||||
|
if (!strncmp(bufpos,"-->",3)) || (bufpointer + bufsize <= bufpos) break;
|
||||||
|
bufpos++;
|
||||||
|
}
|
||||||
tag = attr = tagparam = ignor_param = NULL;
|
tag = attr = tagparam = ignor_param = NULL;
|
||||||
if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
|
|
||||||
{
|
|
||||||
bufpos++;
|
|
||||||
if (ESBYTE[bufpos] == '-')
|
|
||||||
{
|
|
||||||
HH_:
|
|
||||||
do
|
|
||||||
{
|
|
||||||
bufpos++;
|
|
||||||
if (bufpointer + bufsize <= bufpos) break 2;
|
|
||||||
}
|
|
||||||
while (ESBYTE[bufpos] <>'-');
|
|
||||||
|
|
||||||
bufpos++;
|
|
||||||
if (ESBYTE[bufpos] <>'-') goto HH_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
|
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
|
||||||
{
|
{
|
||||||
bukva = ESBYTE[bufpos];
|
bukva = ESBYTE[bufpos];
|
||||||
@ -227,10 +210,11 @@ void TWebBrowser::Prepare(){
|
|||||||
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
||||||
if (tagparam) GetNextParam();
|
if (tagparam) GetNextParam();
|
||||||
|
|
||||||
if (stolbec + utf8_strlen(#line) > list.column_max) Perenos();
|
Perenos();
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
line = NULL;
|
line = NULL;
|
||||||
if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
|
if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
|
||||||
|
strcpy(#oldtag, #tag);
|
||||||
tag = attr = tagparam = ignor_param = NULL;
|
tag = attr = tagparam = ignor_param = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -243,7 +227,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);
|
||||||
if (stolbec + line_len > list.column_max) Perenos();
|
Perenos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawStyle();
|
DrawStyle();
|
||||||
@ -262,6 +246,7 @@ void TWebBrowser::Perenos()
|
|||||||
{
|
{
|
||||||
int perenos_num;
|
int perenos_num;
|
||||||
char new_line_text[4096];
|
char new_line_text[4096];
|
||||||
|
if (stolbec + utf8_strlen(#line) < list.column_max) return;
|
||||||
perenos_num = strrchr(#line, ' ');
|
perenos_num = strrchr(#line, ' ');
|
||||||
if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max;
|
if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max;
|
||||||
strcpy(#new_line_text, #line + perenos_num);
|
strcpy(#new_line_text, #line + perenos_num);
|
||||||
@ -271,7 +256,6 @@ void TWebBrowser::Perenos()
|
|||||||
NewLine();
|
NewLine();
|
||||||
}
|
}
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
char oldtag[100];
|
|
||||||
void TWebBrowser::SetStyle(int left1, top1) {
|
void TWebBrowser::SetStyle(int left1, top1) {
|
||||||
dword hr_color;
|
dword hr_color;
|
||||||
byte opened;
|
byte opened;
|
||||||
@ -388,47 +372,25 @@ void TWebBrowser::SetStyle(int left1, top1) {
|
|||||||
if (istag("blockquote")) { style.blq = opened; return; }
|
if (istag("blockquote")) { style.blq = opened; return; }
|
||||||
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
|
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
|
||||||
if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; }
|
if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; }
|
||||||
/*
|
|
||||||
if (istag("center"))
|
|
||||||
{
|
|
||||||
if (opened) style.align = ALIGN_CENTER;
|
|
||||||
if (!opened)
|
|
||||||
{
|
|
||||||
NewLine();
|
|
||||||
style.align = ALIGN_LEFT;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (istag("right"))
|
|
||||||
{
|
|
||||||
if (opened) style.align = ALIGN_RIGHT;
|
|
||||||
if (!opened)
|
|
||||||
{
|
|
||||||
NewLine();
|
|
||||||
style.align = ALIGN_LEFT;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
|
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
|
||||||
|
style.h = opened;
|
||||||
NewLine();
|
NewLine();
|
||||||
if (opened) && (stroka>1) NewLine();
|
|
||||||
strcpy(#oldtag, #tag);
|
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
|
WB1.DrawBuf.zoom=2;
|
||||||
|
WB1.list.SetFont(8, 14, 10111001b);
|
||||||
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
|
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
|
||||||
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
|
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
|
||||||
style.b = 1;
|
if (stroka>1) NewLine();
|
||||||
}
|
}
|
||||||
if (!opened)
|
else
|
||||||
{
|
{
|
||||||
|
WB1.DrawBuf.zoom=1;
|
||||||
|
WB1.list.SetFont(8, 14, 10111000b);
|
||||||
style.align = ALIGN_LEFT;
|
style.align = ALIGN_LEFT;
|
||||||
style.b = 0;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
oldtag=NULL;
|
|
||||||
if (istag("dt")) {
|
if (istag("dt")) {
|
||||||
style.li = opened;
|
style.li = opened;
|
||||||
if (opened) NewLine();
|
if (opened) NewLine();
|
||||||
|
@ -30,14 +30,14 @@
|
|||||||
char homepage[] = FROM "html\\homepage.htm";
|
char homepage[] = FROM "html\\homepage.htm";
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.3 UNSTABLE";
|
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.31 UNSTABLE";
|
||||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||||
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||||
char accept_language[]= "Accept-Language: ru\n";
|
char accept_language[]= "Accept-Language: ru\n";
|
||||||
#else
|
#else
|
||||||
char version[]=" Text-based Browser 1.3 UNSTABLE";
|
char version[]=" Text-based Browser 1.31 UNSTABLE";
|
||||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||||
?define T_LAST_SLIDE "This slide is the last"
|
?define T_LAST_SLIDE "This slide is the last"
|
||||||
char loading[] = "Loading...<br>";
|
char loading[] = "Loading...<br>";
|
||||||
@ -78,13 +78,11 @@ enum {
|
|||||||
FORWARD_BUTTON,
|
FORWARD_BUTTON,
|
||||||
REFRESH_BUTTON,
|
REFRESH_BUTTON,
|
||||||
GOTOURL_BUTTON,
|
GOTOURL_BUTTON,
|
||||||
SEARCHWEB_BUTTON,
|
|
||||||
SANDWICH_BUTTON
|
SANDWICH_BUTTON
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ZOOM2x=1100,
|
VIEW_SOURCE=1100,
|
||||||
VIEW_SOURCE,
|
|
||||||
EDIT_SOURCE,
|
EDIT_SOURCE,
|
||||||
VIEW_HISTORY,
|
VIEW_HISTORY,
|
||||||
FREE_IMG_CACHE,
|
FREE_IMG_CACHE,
|
||||||
@ -92,7 +90,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#include "..\TWB\TWB.c"
|
#include "..\TWB\TWB.c"
|
||||||
#include "menu_rmb.h"
|
#include "menu.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "show_src.h"
|
#include "show_src.h"
|
||||||
#include "network_get.h"
|
#include "network_get.h"
|
||||||
@ -424,20 +422,6 @@ void Scan(dword id__)
|
|||||||
CreateThread(#menu_rmb,#stak+4092);
|
CreateThread(#menu_rmb,#stak+4092);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ZOOM2x:
|
|
||||||
if (WB1.DrawBuf.zoom==2)
|
|
||||||
{
|
|
||||||
WB1.DrawBuf.zoom=1;
|
|
||||||
WB1.list.SetFont(8, 14, 10111000b);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WB1.DrawBuf.zoom=2;
|
|
||||||
WB1.list.SetFont(8, 14, 10111001b);
|
|
||||||
}
|
|
||||||
Draw_Window();
|
|
||||||
return;
|
|
||||||
|
|
||||||
case VIEW_SOURCE:
|
case VIEW_SOURCE:
|
||||||
WB1.list.first = 0;
|
WB1.list.first = 0;
|
||||||
ShowSource();
|
ShowSource();
|
||||||
@ -605,7 +589,6 @@ void OpenPage()
|
|||||||
bufpointer = malloc(bufsize);
|
bufpointer = malloc(bufsize);
|
||||||
SetPageDefaults();
|
SetPageDefaults();
|
||||||
ReadFile(0, bufsize, bufpointer, #URL);
|
ReadFile(0, bufsize, bufpointer, #URL);
|
||||||
//ShowSource();
|
|
||||||
}
|
}
|
||||||
ShowPage();
|
ShowPage();
|
||||||
}
|
}
|
||||||
@ -633,7 +616,9 @@ void ShowPage()
|
|||||||
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
WB1.Prepare();
|
WB1.Prepare();
|
||||||
|
}
|
||||||
|
|
||||||
if (!header) strcpy(#header, #version);
|
if (!header) strcpy(#header, #version);
|
||||||
if (!strcmp(#version, #header)) DrawTitle(#header);
|
if (!strcmp(#version, #header)) DrawTitle(#header);
|
||||||
|
@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
char *ITEMS_LIST[]={
|
char *ITEMS_LIST[]={
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
"Zoom 2x",
|
|
||||||
"<EFBFBD>®á¬®âà¥âì ¨á室¨ª",
|
"<EFBFBD>®á¬®âà¥âì ¨á室¨ª",
|
||||||
"<EFBFBD>¥¤ ªâ¨à®¢ âì ¨á室¨ª",
|
"<EFBFBD>¥¤ ªâ¨à®¢ âì ¨á室¨ª",
|
||||||
"ˆáâ®à¨ï",
|
"ˆáâ®à¨ï",
|
||||||
"Žç¨áâ¨âì ªíè ª à⨮ª",
|
"Žç¨áâ¨âì ªíè ª à⨮ª",
|
||||||
"Œ¥¥¤¦¥à § £à㧮ª",
|
"Œ¥¥¤¦¥à § £à㧮ª",
|
||||||
#else
|
#else
|
||||||
"Zoom 2x",
|
|
||||||
"View source",
|
"View source",
|
||||||
"Edit source",
|
"Edit source",
|
||||||
"History",
|
"History",
|
||||||
@ -72,11 +70,10 @@ void DrawMenuList()
|
|||||||
}
|
}
|
||||||
WriteText(18,N*menu.line_h+8,0x80,0x000000,ITEMS_LIST[N]);
|
WriteText(18,N*menu.line_h+8,0x80,0x000000,ITEMS_LIST[N]);
|
||||||
}
|
}
|
||||||
if (WB1.DrawBuf.zoom == 2) DrawBar(6, 8, 6, 6, 0x777777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemClick()
|
void ItemClick()
|
||||||
{
|
{
|
||||||
action_buf = ZOOM2x + menu.current;
|
action_buf = VIEW_SOURCE + menu.current;
|
||||||
ExitProcess();
|
ExitProcess();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user