From ec6526f17744a5aff91c13e9659d14fabed7ff7c Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 22 Jun 2012 11:38:38 +0000 Subject: [PATCH] HTMLv 0.94c - regressions and bugs fixed git-svn-id: svn://kolibrios.org@2818 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/htmlv/browser/HTMLv.c | 18 +++-- programs/network/htmlv/browser/History.txt | 8 +++ programs/network/htmlv/browser/TWB.h | 77 ++++++++++++---------- programs/network/htmlv/lib/kolibri.h | 4 -- programs/network/htmlv/lib/ttf_fonts.h | 20 ++++++ 5 files changed, 85 insertions(+), 42 deletions(-) create mode 100644 programs/network/htmlv/lib/ttf_fonts.h diff --git a/programs/network/htmlv/browser/HTMLv.c b/programs/network/htmlv/browser/HTMLv.c index e98881c62f..e1301dca0a 100644 --- a/programs/network/htmlv/browser/HTMLv.c +++ b/programs/network/htmlv/browser/HTMLv.c @@ -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.ylines.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;} diff --git a/programs/network/htmlv/browser/History.txt b/programs/network/htmlv/browser/History.txt index caf80c4c53..23ea764517 100644 --- a/programs/network/htmlv/browser/History.txt +++ b/programs/network/htmlv/browser/History.txt @@ -1,3 +1,11 @@ +22.06.12 - 0.94c +- испрвлена регрессия со ссылками; +- исправлена регрессия с ползунком; +- исправлено затирание первой строки. + +19.06.12 - 0.94 +- улучшение кода. + 14.06.12 -- v0.93 - заработали якоря; - улучшено меню. diff --git a/programs/network/htmlv/browser/TWB.h b/programs/network/htmlv/browser/TWB.h index 2408de5426..1ef2fa3171 100644 --- a/programs/network/htmlv/browser/TWB.h +++ b/programs/network/htmlv/browser/TWB.h @@ -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); @@ -452,7 +457,8 @@ void TWebBrowser::ParseHTML(dword bword, fsize){ lines.first=anchor_line_num; 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); } \ No newline at end of file diff --git a/programs/network/htmlv/lib/kolibri.h b/programs/network/htmlv/lib/kolibri.h index 6944a1a6ed..611c2a7584 100644 --- a/programs/network/htmlv/lib/kolibri.h +++ b/programs/network/htmlv/lib/kolibri.h @@ -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 } diff --git a/programs/network/htmlv/lib/ttf_fonts.h b/programs/network/htmlv/lib/ttf_fonts.h new file mode 100644 index 0000000000..70a86b7651 --- /dev/null +++ b/programs/network/htmlv/lib/ttf_fonts.h @@ -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"; \ No newline at end of file