Text-based Browser 0.9, changes in history.txt

git-svn-id: svn://kolibrios.org@2739 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-06-05 08:25:06 +00:00
parent bf10e3ae53
commit e783cf020c
7 changed files with 306 additions and 84 deletions

View File

@ -1,7 +1,6 @@
//HTML Viewer in C--
//Copyright 2007-2012 by Veliant & Leency
//Asper, Lrz, Nable, lev.
//Asper, lev, Lrz, Barsuk, Nable.
//home icon - rachel fu, GPL licence
#include "..\lib\kolibri.h--"
@ -9,12 +8,12 @@
#include "..\lib\file_system.h--"
#include "img\toolbar_icons.c"
#include "img\URLgoto.txt";
//Asper
#include "..\lib\mem.h--"
#include "..\lib\libio_lib.h--"
#include "..\lib\libimg_lib.h--"
#include "..\lib\edit_box_lib.h--"
#include "..\lib\dll.h--"
#include "..\lib\scroll_bar\scroll_lib.h--"
//ïåðåìåííûå
char URL[4096],
@ -22,15 +21,14 @@ char URL[4096],
page_links[12000],
header[512];
int max_kolvo_strok,
max_kolvo_stolbcov,
count;
int za_kadrom,
scroll_size,
int max_kolvo_strok, //lines_visible
max_kolvo_stolbcov,
count, //lines_all
za_kadrom,
mouse_dd;
edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,248,#editURL,#mouse_dd,2,19,19};
scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; //details in scroll_lib.h--
proc_info Form;
@ -43,20 +41,16 @@ void main()
mouse m;
int btn;
byte key;
int scroll_size;
//Asper [
mem_Init();
$or eax, eax
$jnz loc00
return;
@loc00:
load_dll2(libio, #libio_init,1);
load_dll2(libimg, #libimg_init,1);
load_dll2(boxlib, #edit_box_draw,0);
//] Asper
mem_Init();
load_dll2(libio, #libio_init,1);
load_dll2(libimg, #libimg_init,1);
load_dll2(boxlib, #edit_box_draw,0);
load_dll2(#abox_lib, #boxlib_init,0);
IF (param) copystr(#param,#URL);
ELSE copystr("/sys/index.htm",#URL);
if (param) copystr(#param,#URL);
else copystr("/sys/index.htm",#URL);
copystr(#URL,#editURL);
@ -67,15 +61,28 @@ void main()
SetEventMask(0x27);
loop()
{
switch(WaitEvent())
WaitEventTimeout(1);
switch(EAX & 0xFF)
//switch(WaitEvent())
{
CASE evMouse:
edit_box_mouse stdcall (#edit1);
/*scrollbar_v_mouse (#scroll1); //êîí÷åíûé ñêðîëë ïðèòîðìàæèìàåò, èä¸ì "ñâîèì ïóò¸ì"
if (za_kadrom <> scroll1.position)
{
za_kadrom = scroll1.position;
WB1.ParseHTML(buf, filesize);
//break;
};*/
m.get();
IF (m.vert==65535) //ïðîêðóòêà êîë¸ñèêîì
{
IF (za_kadrom==0) break;
IF (za_kadrom>3) za_kadrom-=2; ELSE za_kadrom=1;
WB1.Scan(ID1);
break;
}
IF (m.vert==1)
{
@ -84,8 +91,11 @@ void main()
za_kadrom+=2;
WB1.Scan(ID2);
}
break;
}
//IF (count<max_kolvo_strok) break;
IF (count<max_kolvo_strok) break;
scroll_size = WB1.height - 16 * max_kolvo_strok / count - 3;
if (m.x>=WB1.width-14) && (m.x<=WB1.width+6)
&& (m.y>WB1.top+16) && (m.y<WB1.top+WB1.height-16)
&& (count>max_kolvo_strok) while (m.lkm)
@ -98,6 +108,7 @@ void main()
IF (btn<>za_kadrom) WB1.ParseHTML(buf, filesize); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
m.get();
}
break;
case evButton:
btn=GetButtonID();
@ -119,8 +130,14 @@ void main()
case evReDraw:
Draw_Window();
break;
default:
if (downloader_id<>0)
{
if (GetProcessSlot(downloader_id)<>0) break;
downloader_id=0;
Draw_Window();
}
}
edit_box_mouse stdcall (#edit1);
}
}
@ -148,15 +165,17 @@ 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_3D(205,14,onLeft(58,205),18,0x94AECE,0x94AECE); //îáîäîê ïîëîñû àäðåñà
DrawRegion_3D(206,15,onLeft(59,205),16,0xE4ECF3,0xE4ECF3);
DrawRegion(205,14,onLeft(58,205),18,0x94AECE); //îáîäîê ïîëîñû àäðåñà
DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3);
edit1.width=Form.width-266;
//edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà //shis is right
WB1.top=44;
WB1.width=Form.width-11;
WB1.width=Form.width-13;
WB1.height=onTop(43,5);
WB1.ShowPage(#URL);
//WB1.ParseHTML(buf, filesize); //shis is right
}

View File

@ -1,3 +1,18 @@
04.06.12 -- v0.90
- новый скроллбар из box_lib (спасибо lev);
- нормальная загрузка страниц без скидывания фокуса с окна;
- гениальный и грязный хак для работы с downloader'ом, который
у меня на машине даёт 99% загрузки страниц вместо 50% ранее;
- масса исправлений в работе с историей посещений и навигацией;
- в теге <font> исправлена регрессия.
27.05.12 -- v0.83
- новая иконка кнопки "домой";
- оптимизация тега <b>;
- улучшения при работе с книгами xml-подобного формата fb2.
13.04.12 -- v0.80
- поддержка <body> "bgcolor=" и "text=";
- обработка перехода вверх "../";
@ -20,7 +35,8 @@
27.02.12 -- v0.75 -- 11.? Кб
- при закрытии HTMLv, downloader тоже завершается;
- невозможно запустить больше одного downloader'a;
- отображение процесса загрузки страницы из Интернета через кнопочку "остановить", надпись "Loading...", возможность прервать процесс;
- отображение процесса загрузки страницы из Интернета через кнопочку
"остановить", надпись "Loading...", возможность прервать процесс;
- обновление страницы из Интернета приводит к её повторной загрузке.

View File

@ -1,8 +1,6 @@
//èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè
//ol - öèôåðêè
//èç õòòï-ëîàä â ðåàäõòìë
int downloader_id;
@ -12,17 +10,14 @@ dword j,
blink = 400;
int i;
char download_path[]="/rd/1/.download";
char download_path[]="/rd/1/.download";
//char search_path[]="http://nova.rambler.ru/search?words=";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.83";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.9";
struct TWebBrowser {
int left,
top,
width,
height;
int left, top, width, height;
void DrawScroller();
void ShowPage();
void ParseHTML(dword, dword);
@ -111,20 +106,12 @@ void TWebBrowser::Scan(dword id) {
utf8rutodos(buf);
break;
case BACK:
BrowserHistory.GoBack();
copystr(#URL, #editURL);
za_kadrom = count = 0;
if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
ShowPage(#URL);
if (!BrowserHistory.GoBack()) return;
OpenPage();
return;
case FORWARD:
BrowserHistory.GoForward();
copystr(#URL, #editURL);
za_kadrom = count = 0;
if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
ShowPage(#URL);
if (!BrowserHistory.GoForward()) return;
OpenPage();
return;
case 054: //F5
IF(edit1.flags == 66) break;
@ -156,17 +143,13 @@ void TWebBrowser::Scan(dword id) {
case GOTOURL:
case 0x0D: //enter
copystr(#editURL, #URL);
if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
za_kadrom = count = 0;
ShowPage(#URL);
OpenPage();
return;
case 173: //ctrl+enter
case SEARCHWEB:
copystr(#search_path, #URL);
copystr(#editURL, #URL + strlen(#URL));
if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
za_kadrom = count = 0;
ShowPage(#URL);
OpenPage();
return;
case ID1: //ìîòàåì ââåðõ
@ -201,6 +184,16 @@ void TWebBrowser::Scan(dword id) {
ParseHTML(buf, filesize);
}
void OpenPage()
{
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
KillProcess(downloader_id);
copystr(#URL, #editURL);
za_kadrom = count = 0;
if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
WB1.ShowPage(#URL);
}
void GetNewUrl(){
IF (!strcmp(get_URL_part(2),"./")) copystr(#URL+2,#URL); //èãíîðèì :)
@ -238,6 +231,11 @@ void HttpLoad()
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
downloader_id = RunProgram("/sys/network/downloader", #URL);
//ýòî ãåíèàëüíî è ýòî ïèçäåö!!!
Pause(60);
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
downloader_id = RunProgram("/sys/network/downloader", #URL);
//
IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
Draw_Window();
}
@ -275,7 +273,7 @@ void TWebBrowser::ShowPage(dword adress) {
if (!filesize)
{
DrawBar(left, top, width+2, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó
DrawBar(left, top, width+4, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó
if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0);
else
{
@ -410,7 +408,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó
}
WriteDebug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè
//WriteDebug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè
copystr(#tag, #line + strlen(#line)); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
break;
default:
@ -595,7 +593,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
/////////////////////////
if (!chTag("font"))
{
IF(stroka < 0) || (stroka - 1 > max_kolvo_strok) return;
IF (stroka - 1 > max_kolvo_strok) return;
COL_MARK:
if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
{
@ -766,7 +764,8 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
}
void TextGoDown(int left1, top1, width1) {
void TextGoDown(int left1, top1, width1)
{
stroka++;
IF(blq_text == 1) stolbec = 8;
ELSE stolbec = 0;
@ -776,23 +775,18 @@ void TextGoDown(int left1, top1, width1) {
//ñêðîëë
void TWebBrowser::DrawScroller() {
dword on_y;
DrawBar(left + width - 15, top + 17, 1, height - 34, 0x94AECE); //ëèíèÿ ñëåâà îò ïðîêðóòêè
DrawFlatButton(left + width - 15, top + height - 17, 16, 16, ID2, 0xE4DFE1, "\x19");
DrawFlatButton(left + width - 15, top, 16, 16, ID1, 0xE4DFE1, "\x18");
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
{
scroll1.max_area = count;
scroll1.cur_area = max_kolvo_strok;
scroll1.position = za_kadrom;
IF(count <= max_kolvo_strok) {
DrawBar(left + width - 14, top+17, 16, height - 34, 0xCED0D0);
return;
}
scroll1.all_redraw=1;
scroll1.start_x=Form.width-28; //left + width - 15
scroll1.size_y=WB1.height;
scroll_size = height - 16 * max_kolvo_strok / count - 3;
IF(scroll_size < 10) scroll_size = 10;
IF(za_kadrom + max_kolvo_strok >= count) on_y = height - scroll_size + top - 17;
ELSE on_y = height - 32 * za_kadrom / count + top + 16;
DrawFlatButton(left + width - 15, on_y, 16, scroll_size, 0, 0xE4DFE1, ""); //ïîëçóíîê
IF(on_y > top + 17) DrawBar(left + width - 14, top + 17, 16, on_y - top - 17, 0xCED0D0); //ïîëå äî ïîëçóíêà
IF(height - scroll_size + top - 17 > on_y)
DrawBar(left + width - 14, on_y + scroll_size + 1, 16, height - scroll_size - on_y + top - 18, 0xCED0D0); //ïîëå ïîñëå ïîëçóíêà
scrollbar_v_draw(#scroll1);
DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, ID1+BT_HIDE, 0xE4DFE1);
DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, ID2+BT_HIDE, 0xE4DFE1);
}

View File

@ -1,8 +1,8 @@
struct UrlsHistory {
dword CurrentUrl();
void AddUrl();
void GoBack();
void GoForward();
byte GoBack();
byte GoForward();
};
UrlsHistory BrowserHistory;
@ -39,17 +39,20 @@ void UrlsHistory::AddUrl() //
}
void UrlsHistory::GoBack()
byte UrlsHistory::GoBack()
{
if (history_current<=1) return;
if (history_current<=1) return 0;
history_current--;
copystr(#history_list[history_current].Item,#URL);
return 1;
}
void UrlsHistory::GoForward()
byte UrlsHistory::GoForward()
{
if (history_current==history_num) return;
if (history_current==history_num) return 0;
history_current++;
copystr(#history_list[history_current].Item,#URL);
return 1;
}

View File

@ -0,0 +1,52 @@
/*******************************************************************************
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
dword generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
:int random(int max)
// get pseudo-random number - ïîëó÷èòü ïñåâäîñëó÷àéíîå ÷èñëî
{
$rdtsc // eax & edx
$xor eax,edx
$not eax
EBX = generator;
$ror ebx,3
$xor ebx,0xdeadbeef
EBX += EAX;
generator = EBX;
EAX += EBX;
EAX = EAX % max;
return EAX;
}
:randomize()
// initialize random number generator - èíèöèàëèçèðîâàòü ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
{
asm
{
mov eax,3
int 0x40
ror eax,16
}
generator = EAX;
}

View File

@ -0,0 +1,43 @@
:int load_dll3(dword dllname, import_table)
{
EAX = 68;
EBX = 19;
ECX = dllname;
$int 0x40
IF(EAX==0) GOTO exit3;
EDX = EAX;
ESI = import_table;
@import_loop3:
$lodsd
IF(EAX==0) GOTO import_done3;
$push edx
@import_find3:
EBX = DSDWORD[EDX];
IF(EBX==0) GOTO exit3;
$push eax
@next3:
CL = DSBYTE[EAX];
$cmp CL,DSBYTE[EBX];
$jnz import_find_next3
IF (CL==0) GOTO import_found3;
EAX++;
EBX++;
goto next3;
@import_find_next3:
$pop eax
EDX = EDX + 8;
goto import_find3;
@import_found3:
$pop ebx
EAX = DSDWORD[EDX+4];
DSDWORD[ESI-4] = EAX;
$pop edx
goto import_loop3;
@import_done3:
return 0;
@exit3:
return -1;
}

View File

@ -0,0 +1,95 @@
//lev
//:dword boxlib = #abox_lib;
:char abox_lib[]="/sys/lib/box_lib.obj";
:char aboxlib_init[] = "lib_init";
:char aScrollbar_v_draw = "scrollbar_v_draw";
:char aScrollbar_v_mouse = "scrollbar_v_mouse";
:char aScrollbar_h_draw = "scrollbar_h_draw";
:char aScrollbar_h_mouse = "scrollbar_h_mouse";
:char aVersion_scrollbar = "version_scrollbar";
dword boxlib_init = #aboxlib_init;
dword scrollbar_v_draw = #aScrollbar_v_draw;
dword scrollbar_v_mouse = #aScrollbar_v_mouse;
dword scrollbar_h_draw = #aScrollbar_h_draw;
dword scrollbar_h_mouse = #aScrollbar_h_mouse;
:dword version_scrollbar = #aVersion_scrollbar;
dword sc_am__ = 0x0;
dword sc_bm__ = 0x0;
struct scroll_bar
{
//scroll_bar:
word size_x,// equ [edi]
start_x,// equ [edi+2]
size_y,// equ [edi+4]
start_y;// equ [edi+6]
dword btn_height, // equ [edi+8]
type,// equ [edi+12]
max_area,// equ [edi+16]
cur_area,// equ [edi+20]
position,// equ [edi+24]
bckg_col,// equ [edi+28]
frnt_col,// equ [edi+32]
line_col,// equ [edi+36]
redraw;// equ [edi+40]
word delta,// equ [edi+44]
delta2,// equ [edi+46]
r_size_x,// equ [edi+48]
r_start_x,// equ [edi+50]
r_size_y,// equ [edi+52]
r_start_y;// equ [edi+54]
dword m_pos,// equ [edi+56]
m_pos_2,// equ [edi+60]
m_keys,// equ [edi+64]
run_size,// equ [edi+68]
position2,// equ [edi+72]
work_size,// equ [edi+76]
all_redraw,// equ [edi+80]
ar_offset;// equ [edi+84]
};
/*scroll_bar scroll1 = {
18,//word size_x,
200, //start_x,
398, //size_y,
44,//start_y;
18,//dword btn_height,
0,//type,
115,//max_area, (100+cur_area)
15,//cur_area,
0,//position,
0xeeeeee,//bckg_col,
0xD2CED0,//frnt_col,
0x555555,//line_col,
0,//redraw;
0,//word delta,
0,//delta2,
0,//r_size_x,
0,//r_start_x,
0,//r_size_y,
0,//r_start_y;
0,//dword m_pos,
0,//m_pos_2,
0,//m_keys,
0,//run_size,
0,//position2,
0,//work_size,
1,//all_redraw,
1//ar_offset;
};*/
//btn_height - ¢ëá®â  ¡®ª®¢ëå ª­®¯®ª («¥¢ ï ¨ ¯à ¢ ï ¤«ï £®à¨§. ¨ ¢¥àå­ïï ¨ ­¨¦­ïï ¤«ï ¢¥àâ.)
//type - type - 0-1-2, ®áâ «ì­ë¥ ¢ë£«ï¤ïâ ª ª 0.
//max_area - ®¡« áâì ¬ ªá¨¬ «ì­ ï,  ªâã «ì­® ª®£¤  ­¥ ¢« §¨â ¢ ®â®¡à ¦ ¥¬ãî ®¡« áâì, â.¥. á«ãç ©  ªâ¨¢­®á⨠ª®¬¯®­¥­â  (¢¥áì ¬ ªá¨¬ «ì­ë© à §¬¥à ¤®ªã¬¥­â )
//cur_area - à §¬¥à ¡¥£ã­ª //®¡« áâì ®â®¡à ¦ ¥¬ ï (ª ª ï ç áâì ¤®ªã¬¥­â  ¢« §¨â ¢ íªà ­)
//position - ¯®§¨æ¨ï ¡¥£ã­ª  ¨§¬¥­ï¥¬ ï ®â 0 ¤® §­ ç¥­¨ï (max_area-cur_area)
//bckg_col - 梥⠢­ãâ७­¨©, ¯à¨¬¥­ï¥âáï ¤«ï ®¡« á⥩ ¬¥¦¤ã ¡¥£ã­ª®¬ ¨ ª­®ª ¬¨
//frnt_col - 梥⠭ à㦭ë©, ¯à¨¬¥­ï¥âáï ¤«ï ®¡« á⥩ ®â«¨ç­ëå ®â ¯à¨¬¥­ï¥¬ëå ¢ bckg_col
//line_col - 梥⠫¨­¨© ¨ áâ५®ª ­  ª­®¯ª å
//redraw - ¨­¤¨ª â®à ­¥®¡å®¤¨¬®á⨠¯¥à¥à¨á®¢ª¨ ã¯à ¢«ï¥¬®© ®¡« á⨠ãç¨âë¢ ï ¨§¬¥­¥­¨¥ position ¨ cur_area
//delta2 - ¨­¤¨ª â®à § å¢ â  䮪ãá  áªà®««¡ à®¬ (㤥ঠ­¨¥ ¡¥£ã­ª )
//all_redraw - ä« £ ãáâ ­ ¢«¨¢ ¥¬ë© ¢ 1 ¤«ï ¯¥à¥à¨á®¢ª¨ ¢á¥£® ª®¬¯®­¥­â , ¥á«¨ ¯®áâ ¢¨âì 0, â® ¯¥à¥à¨á®¢ª  ¯à®¨á室¨â ⮫쪮 ¤«ï ®¡« á⨠¡¥£ã­ª . ‚¢¥¤¥­® ¤«ï ã᪮७¨ï ®âà¨á®¢ª¨, ¯®áª®«ìªã ­¥ ¢® ¢á¥å á«ãç ïå âॡã¥âáï ¯à¨­ã¤¨â¥ì­® ®âà¨á®¢ë¢ âì ¢á¥ ç á⨠ª®¬¯®­¥­â . Š®£¤  ¢ë§ë¢ ¥âáï ¯® ᮡëâ¨î ¬ëè¨ ¢á¥£¤  ®âà¨á®¢ë¢ ¥âáï á ¬¨¬ ª®¬¯®­¥­â®¬ á® §­ ç¥­¨¥¬ 0.
//ar_offset - ¢¥«¨ç¨­  ᬥ饭¨ï ¯à¨ ®¤­®ªà â­®¬ ­ ¦ â¨¨ ¡®ª®¢®© ª­®¯ª¨.