HTMLv 0.94c - regressions and bugs fixed

git-svn-id: svn://kolibrios.org@2818 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-06-22 11:38:38 +00:00
parent b14aaf5e03
commit ec6526f177
5 changed files with 85 additions and 42 deletions

View File

@ -6,14 +6,18 @@
#include "..\lib\kolibri.h"
#include "..\lib\encoding.h"
#include "..\lib\file_system.h"
#include "img\toolbar_icons.c"
#include "img\URLgoto.txt";
#include "..\lib\mem.h"
#include "..\lib\dll.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"
#include "..\lib\ttf_fonts.h"
//êàðòèíêè
#include "img\toolbar_icons.c"
#include "img\URLgoto.txt";
//ïåðåìåííûå
char URL[4096],
@ -48,6 +52,7 @@ void main()
load_dll2(libimg, #libimg_init,1);
load_dll2(boxlib, #edit_box_draw,0);
load_dll2(#abox_lib, #boxlib_init,0);
//load_dll2(libtruetype, #truetype,0);
if (param) strcpy(#URL, #param);
else strcpy(#URL, "/sys/index.htm");
@ -105,7 +110,7 @@ void main()
&& (m.y>WB1.top+16) && (m.y<WB1.top+WB1.height-16)
&& (lines.all>lines.visible) while (m.lkm)
{
IF (half_scroll_size/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size/2+WB1.top; //åñëè êóðñîð íàä îêíîì
IF (half_scroll_size+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.top; //åñëè êóðñîð íàä îêíîì
btn=lines.first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
lines.first = m.y -half_scroll_size -WB1.top * lines.all / WB1.height;
IF (lines.visible+lines.first>lines.all) lines.first=lines.all-lines.visible;
@ -174,7 +179,7 @@ void Draw_Window()
DrawBar(200,0,onLeft(200,9),43,0xE4DFE1); //çàêðàøèâàåì ôîí ïîä òóëáàðîì
DrawBar(0,42,onLeft(5,4),1,0xE2DBDC); //âûïóêëîñòü
DrawBar(0,43,onLeft(5,4),1,0xD2CED0); //âûïóêëîñòü
for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0x00E4DFE1);
for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1);
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);
@ -189,6 +194,9 @@ void Draw_Window()
lines.visible = WB1.height - 3 / 10 - 2;
WB1.ShowPage();
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);
}
int onLeft(dword right,left) {return Form.width-right-left;}

View File

@ -1,3 +1,11 @@
22.06.12 - 0.94c
- испрвлена регрессия со ссылками;
- исправлена регрессия с ползунком;
- исправлено затирание первой строки.
19.06.12 - 0.94
- улучшение кода.
14.06.12 -- v0.93
- заработали якоря;
- улучшено меню.

View File

@ -9,7 +9,7 @@ int i;
char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.94b";
char version[]=" Text-based Browser 0.94c";
struct TWebBrowser {
@ -25,7 +25,8 @@ 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, body_present;
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
link, ignor_text, li_tab, first_line_drawed;
dword text_colors[30],
@ -294,7 +295,7 @@ void TWebBrowser::ShowPage()
void TWebBrowser::ParseHTML(dword bword, fsize){
word bukva[1];
int j;
int j, perenos_num;
byte ignor_param = 0;
char temp[768];
@ -304,30 +305,31 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
for (j = 400; j < blink + 1; j++;) DeleteButton(j);
blink = 400;
b_text = i_text = u_text = s_text = pre_text = blq_text = body_present =
b_text = i_text = u_text = s_text = pre_text = blq_text = first_line_drawed =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
link_color = 0x0000FF;
bg_color = 0xFFFFFF;
line = '';
strcpy(#page_links,"|");
strcpy(#header,#version);
if (!strcmp(#URL + strlen(#URL) - 4, ".txt"))
{
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà
}
if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
for (bword = buf; buf + fsize > bword; bword++;) {
debug("Start parsing");
for ( ; buf+fsize > bword; bword++;) {//ESBYTE[bword]
bukva = ESBYTE[bword];
switch (bukva) {
case 0x0a:
IF(pre_text == 1) {
if (pre_text)
{
bukva = '';
temp = '';
goto NEXT_MARK;
}
case '\9':
if (pre_text == 1) //èíà÷å èä¸ì íà 0x0d
if (pre_text) //èíà÷å èä¸ì íà 0x0d
{
tab_len=strlen(#line)/8;
tab_len=tab_len*8;
@ -344,10 +346,14 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
{
bword++;
if (ESBYTE[bword] == '-') {
HH_: do {
HH_:
do
{
bword++;
IF(bword >= buf + fsize) break 1;
} while (ESBYTE[bword] <>'-');
if (bword >= buf + fsize) break 1;
}
while (ESBYTE[bword] <>'-');
bword++;
if (ESBYTE[bword] <>'-') goto HH_;
}
@ -420,25 +426,24 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
break;
default:
DEFAULT_MARK:
IF(ignor_text) break;
IF(!pre_text) && (bukva == ' ') && (!strcmp(#line + strlen(#line) - 1, " ")) continue;
if (ignor_text) break;
if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
//
if (stolbec + strlen(#line) >lines.column_max)
if (stolbec + strlen(#line) > lines.column_max)
{
strcpy(#temp, #line + find_symbol(#line, ' ')); //ïåðåíîñ ïî ñëîâàì
line[find_symbol(#line, ' ')] = 0x00;
perenos_num = find_symbol(#line, ' ');
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
line[perenos_num] = 0x00;
NEXT_MARK:
IF(stroka - 1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
strcpy(#line, #temp);
}
if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) CONTINUE;
if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break;
strcat(#line, #bukva);
}
}
if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (!body_present)
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó åñëè êàêîé-òî ðàõèò íå ñîçäàë òåã áîäè
if (lines.visible * 10 + 25 <= height)
DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
@ -453,6 +458,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
ParseHTML(buf, filesize);
}
debug("End parsing");
DrawScroller(); //ðèñóåì ñêðîëë
}
@ -541,7 +547,13 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
//âûâîä íà ýêðàí
if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
{
if (stroka==0) && (stolbec==0)
{
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
first_line_drawed=1;
}
WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
//text_out stdcall (#line, -1, 16, text_colors[text_color_index], stolbec * 6 + left1, top1);
IF (b_text) { $add ebx, 1<<16 $int 0x40 }
IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //íàêëîííûé òåêñò
IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, strlen(#line) * 6, 1, text_colors[text_color_index]); //çà÷¸ðêíóòûé
@ -585,9 +597,6 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
GOTO BODY_MARK;
}
body_present = 1; //åñëè êàëè÷ íå ñîçäàë òåã áîäè íóæíî èçâðàùàòüñÿ
if (rez) DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
return;
}
//////////////////////////
@ -794,10 +803,15 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
void TextGoDown(int left1, top1, width1)
{
if (!stroka) && (!stolbec) && (!first_line_drawed)
{
DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
first_line_drawed=1;
}
stroka++;
IF(blq_text == 1) stolbec = 8;
if (blq_text) stolbec = 8;
ELSE stolbec = 0;
IF(li_text == 1) stolbec = li_tab * 5;
if (li_text) stolbec = li_tab * 5;
IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
}
@ -814,7 +828,4 @@ void TWebBrowser::DrawScroller() //
scroll1.size_y=WB1.height;
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

@ -491,12 +491,8 @@ void DrawBar(dword x,y,w,h,EDX)
void DefineButton(dword x,y,w,h,EDX,ESI)
{
EAX = 8;
$push edx
EDX += BT_DEL; //âíà÷àëå óäàëÿåì êíîïó ñ ýòè èä, ïîòîì ñîçäà¸ì
$int 0x40;
EBX = x<<16+w;
ECX = y<<16+h;
$pop edx
$int 0x40
}

View File

@ -0,0 +1,20 @@
//ýòî âñòàâèòü ïîñëå çàãðóçêè îñíîâíûõ áèáëèîòåê
dword libtruetype = #att;
char att[23] = "/sys/lib/truetype.obj\0"; //"truetype.obj\0";
dword truetype = #att_truetype;
dword get_length = #att_get_length;
dword get_width = #att_get_width;
dword text_out = #att_text_out;
dword am3__ = 0x0;
dword bm3__ = 0x0;
char att_truetype[10] = "truetype\0";
char att_get_length[12] = "get_length\0";
char att_get_width[11] = "get_width\0";
char att_text_out[10] = "text_out\0";