HTMLv 0.97.7

git-svn-id: svn://kolibrios.org@3058 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-11-18 21:49:28 +00:00
parent c69c5c905b
commit 29de2e5854
10 changed files with 301 additions and 310 deletions

View File

@ -5,11 +5,12 @@
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\figures.h"
#include "..\lib\encoding.h"
#include "..\lib\file_system.h"
#include "..\lib\mem.h"
#include "..\lib\dll.h"
//áèáëèîòåêè
//áèáëèîòåêè .obj
#include "..\lib\libio_lib.h"
#include "..\lib\libimg_lib.h"
#include "..\lib\edit_box_lib.h"
@ -47,6 +48,7 @@ mouse m;
#include "TWB.h"
#include "include\menu_rmb.h"
void tre()
{
char *font_picture;
@ -55,22 +57,10 @@ void tre()
int height=20;
// char palette[256*4];
int x;
debug("fuck this shit\n");
//init_font(#fontinfo);
debug("fuck this shit!\n");
strcpy(#text, "hello world\0");
text_out stdcall (#text, #fontlol, 17, 0x0, 10, 10);
strcpy(#text, "fuck this shit!\0");
text_out stdcall (#text, #fontlol, 27, 0x0, 10, 30);
strcpy(#text, "alarm!\0");
text_out stdcall (#text, #fontlol, 47, 0x00FF0000, 10, 70);
text_out stdcall ("hello world\0",#fontlol, 17, 0x0, 10, 10);
text_out stdcall ("heyeyey!\0",#fontlol, 27, 0x0, 10, 30);
text_out stdcall ("alarm!\0", #fontlol, 47, 0x00FF0000, 10, 70);
/*
strcpy(#text, "hello world\0");
@ -233,7 +223,7 @@ void SetElementSizes()
void Draw_Window()
{
int j;
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0x00E4DFE1,0);
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0x00E4DFE1,0,0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) //åñëè ñâåðíóòî â çàãîëîâîê, íè÷åãî íå ðèñóåì
@ -254,8 +244,8 @@ void Draw_Window()
PutImage(#URLgoto,40,19,onLeft(57,0),14);
DefineButton(onLeft(37,0),15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
DefineButton(onLeft(56,0),15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
DrawRegion(205,14,onLeft(58,205),18,0x94AECE); //îáîäîê ïîëîñû àäðåñà
DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3);
DrawRectangle(205,14,onLeft(58,205),18,0x94AECE); //îáîäîê ïîëîñû àäðåñà
DrawRectangle(206,15,onLeft(59,205),16,0xE4ECF3);
SetElementSizes();
WB1.ShowPage();

View File

@ -1,6 +1,12 @@
11.11.12 - 0.97.6a
SoUrcerer - Синхронизация программы с новой
оптимизированной версией библитеки TryeType.
18.11.12 - 0.97.7
- если изображение не загрузилось, но содержит ссылку отображается
заменяющий его текст;
- частично исправлен перенос ссылках в тексте;
- отображение в меню текущей кодировки;
- SoUrcerer - Синхронизация программы с новой оптимизированной
версией библитеки TryeType.
10.11.12 - 0.97.6
- нормальный запуск программы даже без библиотеки lib_img;

View File

@ -8,7 +8,7 @@ dword
char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.97.6";
char version[]=" Text-based Browser 0.97.7";
struct TWebBrowser {
@ -27,7 +27,7 @@ struct TWebBrowser {
TWebBrowser WB1;
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
link, ignor_text, li_tab, first_line_drawed;
link, ignor_text, li_tab, first_line_drawed, cur_encoding;
dword text_colors[300],
@ -262,6 +262,7 @@ void TWebBrowser::ReadHtml(byte encoding)
else
ReadFile(0, filesize, buf, #URL);
cur_encoding = encoding;
if (encoding==_WIN) wintodos(buf);
if (encoding==_UTF) utf8rutodos(buf);
if (encoding==_KOI) koitodos(buf);
@ -282,7 +283,7 @@ void TWebBrowser::OpenPage()
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
downloader_id = RunProgram("/sys/network/downloader", #URL);
//ıòî ãåíèàëüíî è ıòî ïèçäåö!!!
//Browser Hack v2.0
Pause(60);
if (GetProcessSlot(downloader_id)<>0)
{
@ -376,56 +377,9 @@ void TWebBrowser::ParseHTML(dword bword){
break;
}
case 0x0d:
debug("0x0d");
bukva = ' ';
goto DEFAULT_MARK;
case '<':
bword++; //ïğîìîòàåì ñèìâîë <
tag = parametr = tagparam = ignor_param = 0;
if (ESBYTE[bword] == '!') //ôèëüòğàöèÿ âíóòğè <!-- -->, äåğçêî
{
bword++;
if (ESBYTE[bword] == '-')
{
HH_:
do
{
bword++;
if (buf + filesize <= bword) break 2;
}
while (ESBYTE[bword] <>'-');
bword++;
if (ESBYTE[bword] <>'-') goto HH_;
}
}
while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàğàìåòğû
{
bukva = ESBYTE[bword];
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
if (!ignor_param) && (bukva <>' ')
{
if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
}
else
{
ignor_param = true;
if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
}
bword++;
}
strlwr(#tag);
strlwr(#tagparam);
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //for br/
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
DrawPage();
line=0;
if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáğàáîòêà òåãîâ
tag = parametr = tagparam = ignor_param = '\0';
break;
case '=': //ïîääåðæêà øàéòàíñêîé êîäèðîâêè ñòðàíèö, ñîõðàí¸ííûõ ÷åðåç ÈÅ7
if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
@ -469,9 +423,57 @@ void TWebBrowser::ParseHTML(dword bword){
strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
break;
case '<':
bword++; //ïğîìîòàåì ñèìâîë <
tag = parametr = tagparam = ignor_param = NULL;
if (ESBYTE[bword] == '!') //ôèëüòğàöèÿ âíóòğè <!-- -->, äåğçêî
{
bword++;
if (ESBYTE[bword] == '-')
{
HH_:
do
{
bword++;
if (buf + filesize <= bword) break 2;
}
while (ESBYTE[bword] <>'-');
bword++;
if (ESBYTE[bword] <>'-') goto HH_;
}
}
while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàğàìåòğû
{
bukva = ESBYTE[bword];
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
if (!ignor_param) && (bukva <>' ')
{
if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
}
else
{
ignor_param = true;
if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
}
bword++;
}
strlwr(#tag);
strlwr(#tagparam);
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
DrawPage();
line=NULL;
if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáğàáîòêà òåãîâ
tag = parametr = tagparam = ignor_param = NULL;
break;
default:
DEFAULT_MARK:
if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break; //óáğàòü 2 ïğîáåëà ïîäğÿä
//
if (stolbec + strlen(#line) > lines.column_max)
{
@ -514,9 +516,6 @@ void TWebBrowser::DrawPage() //
{
if (strlen(#version)+strlen(#line)+2>sizeof(header))
{
//line = 123456789
//header = 1234
//line = 56789
strcpy(#temp, #line);
temp[sizeof(header)-strlen(#version)-2]=0;
strcpy(#header, #temp);
@ -572,7 +571,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
dword hr_color;
dword image;
char temp[4096];
char temp[4096], alt[4096];
int w=0, h=0, img_lines_first=0;
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
@ -782,21 +781,23 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
IMG_TAG:
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
{
if (downloader_id!=0) strcpy(#temp, #history_list[history_current-1].Item);
if (downloader_id) strcpy(#temp, #history_list[history_current-1].Item);
else strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
if (!strcmpn(#temp, "http:", 5)) || (!strcmpn(#options, "http:", 5)) return;
if (strcmpn(#temp, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
{
temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
strcat(#temp, #options);
image=load_image(#temp);
w=DSWORD[image+4];
h=DSWORD[image+8];
}
/*if (!strcmp(#parametr,"alt="))
}
if (!strcmp(#parametr,"alt="))
{
strcpy(#tag, "[Image: ");
strcat(#tag, #options);
strcat(#tag, "]");
}*/
strcpy(#alt, "[");
strcat(#alt, #options);
strcat(#alt, "]");
}
IF(tagparam)
{
@ -804,7 +805,11 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
GOTO IMG_TAG;
}
if (!image) return;
if (!image)
{
if (alt) && (link) strcat(#line, #alt);
return;
}
if (w>width1) w=width1;

View File

@ -7,7 +7,7 @@ char *ITEMS_LIST[]={
"View in Tinypad F3",52,
"WIN F5",REFRESH,
"DOS Ctrl+D",04,
"KOI-8 Ctrl+K",11,
"KOI Ctrl+K",11,
"UTF Ctrl+U",21,
"Line breaks ON" ,01,
"TrueType fonts" ,05,
@ -78,10 +78,9 @@ void menu_rmb()
case evReDraw:
while (ITEMS_LIST[items_num*2]) items_num++;
DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinHeight()+3,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x01,0x10FFFFFF,0);
DefineButton(0, 0, ITEM_WIDTH, ITEM_HEIGHT, 10+BT_HIDE+BT_NOFRAME, 0); //hack
DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinHeight()+3,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x01,0x10FFFFFF,0,0x01fffFFF);
DrawRegion(0,0,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x777777); //îáîäîê
DrawRectangle(0,0,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x777777); //îáîäîê
_ITEMS_DRAW:
for (i=0; i<items_num; i++;)
{
@ -91,6 +90,7 @@ void menu_rmb()
if (ITEMS_LIST[i*2+1]==1) && (pre_text==2) DrawBar(ITEM_WIDTH-18, i*ITEM_HEIGHT+8, 4, 4, 0x444444);
if (ITEMS_LIST[i*2+1]==5) && (use_truetype==1) DrawBar(ITEM_WIDTH-18, i*ITEM_HEIGHT+8, 4, 4, 0x444444);
}
DrawBar(33, cur_encoding+1*ITEM_HEIGHT+8, 4, 4, 0x444444); //ïîêàçûâàåò âûáðàíóþ êîäèðîâêó
}
}

View File

@ -1,4 +1,4 @@
//ェュョッェィ
//<EFBFBD><EFBFBD>
#define BACK 300
#define FORWARD 301
#define REFRESH 302

View File

@ -0,0 +1,33 @@
void DrawRectangle(dword x,y,width,height,color1)
{
DrawBar(x,y,width,1,color1);
DrawBar(x,y+height,width,1,color1);
DrawBar(x,y,1,height,color1);
DrawBar(x+width,y,1,height+1,color1);
}
void DrawRectangle3D(dword x,y,width,height,color1,color2)
{
DrawBar(x,y,width+1,1,color1);
DrawBar(x,y+1,1,height-1,color1);
DrawBar(x+width,y+1,1,height,color2);
DrawBar(x,y+height,width,1,color2);
}
void DrawCaptButton(dword x,y,width,height,id,color,text,text_len)
{
DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF);
WriteText(-text_len*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
}
void DrawCircle(int x, y, r)
{
int i;
float px=0, py=r, ii = r * 3.1415926 * 2;
FOR (i = 0; i < ii; i++)
{
PutPixel(px + x, y - py, 0);
px = py / r + px;
py = -px / r + py;
}
}

View File

@ -71,7 +71,8 @@ void mouse::get()
struct system_colors
{
dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
dword frame,grab,grab_button,grab_button_text,grab_text,
work,work_button,work_button_text,work_text,work_graph;
void get();
};
@ -263,7 +264,7 @@ inline fastcall int GetSystemLanguage()
$int 0x40
}
inline fastcall dword GetSkinHeight()
inline fastcall GetSkinHeight()
{
$push ebx
$mov eax,48
@ -313,9 +314,30 @@ inline fastcall int PlaySpeaker( ESI)
$int 0x40
}
inline fastcall void debug( EDX)
{
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
next_char:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz done
$int 0x40
$inc edx
$jmp next_char
done:
$mov cl, 13
$int 0x40
$mov cl, 10
$int 0x40
$pop ecx
$pop ebx
}
//------------------------------------------------------------------------------
void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI)
void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI, ESI)
{
EAX = 12; // function 12:tell os about windowdraw
EBX = 1;
@ -439,68 +461,3 @@ inline fastcall void DeleteButton( EDX)
EDX += BT_DEL;
$int 0x40;
}
//------------------------------------------------------------------------------
:void DrawRegion(dword x,y,width,height,color1)
{
DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
}
:void DrawRegion_3D(dword x,y,width,height,color1,color2)
{
DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
}
:void DrawFlatButton(dword x,y,width,height,id,color,text)
{
DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
IF (id<>0) DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
//WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
WriteText(width/2+x+1,height/2-3+y,0x80,0,text,0);
}
:void DrawCircle(int x, y, r)
{
int i;
float px=0, py=r, ii = r * 3.1415926 * 2;
FOR (i = 0; i < ii; i++)
{
PutPixel(px + x, y - py, 0);
px = py / r + px;
py = -px / r + py;
}
}
//------------------------------------------------------------------------------
inline fastcall void debug( EDX)
{
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
next_char:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz done
$int 0x40
$inc edx
$jmp next_char
done:
$mov cl, 13
$int 0x40
$mov cl, 10
$int 0x40
$pop ecx
$pop ebx
}

View File

@ -193,7 +193,7 @@ inline fastcall signed int strchr( ESI,BL)
inline fastcall signed int strrchr( ESI,BL)
{
int jj=0, last=-1;
int jj=0, last=0;
do{
jj++;
$lodsb