HTMLv 0.94z: overflow checking, small improve in menu, restore editbox line while opening image

git-svn-id: svn://kolibrios.org@2840 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-07-02 19:02:06 +00:00
parent c96f15b38e
commit 09b1b8dc7e
5 changed files with 39 additions and 164 deletions

View File

@ -13,20 +13,18 @@
#include "..\lib\libio_lib.h" #include "..\lib\libio_lib.h"
#include "..\lib\libimg_lib.h" #include "..\lib\libimg_lib.h"
#include "..\lib\edit_box_lib.h" #include "..\lib\edit_box_lib.h"
#include "..\lib\scroll_bar\scroll_lib.h" #include "..\lib\scroll_lib.h"
#include "..\lib\ttf_fonts.h" #include "..\lib\ttf_fonts.h"
//êàðòèíêè //êàðòèíêè
#include "img\toolbar_icons.c" #include "img\toolbar_icons.c"
#include "img\URLgoto.txt"; #include "img\URLgoto.txt";
#define DEBUG_ON 0
//ïåðåìåííûå //ïåðåìåííûå
char URL[4096], char URL[4096],
editURL[4096], editURL[4096],
page_links[12000], page_links[12000],
header[512]; header[300];
struct lines{ struct lines{
int visible, all, first, column_max; int visible, all, first, column_max;
@ -88,6 +86,7 @@ void main()
if (m.pkm) && (m.y>WB1.top) && (m.y<Form.height) && (filesize) if (m.pkm) && (m.y>WB1.top) && (m.y<Form.height) && (filesize)
{ {
SwitchToAnotherThread();
CreateThread(#menu_rmb,#stak); CreateThread(#menu_rmb,#stak);
} }

View File

@ -9,7 +9,7 @@ int i;
char download_path[]="/rd/1/.download"; char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s="; char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.94u"; char version[]=" Text-based Browser 0.94z";
struct TWebBrowser { struct TWebBrowser {
@ -85,6 +85,7 @@ void TWebBrowser::Scan(int id)
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
{ {
RunProgram("/sys/media/kiv", #URL); RunProgram("/sys/media/kiv", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl()); strcpy(#URL, BrowserHistory.CurrentUrl());
return; return;
} }
@ -320,14 +321,16 @@ void TWebBrowser::ParseHTML(dword bword){
debug("Start parsing"); debug("Start parsing");
for ( ; buf+filesize > bword; bword++;) {//ESBYTE[bword] for ( ; buf+filesize > bword; bword++;)
bukva = ESBYTE[bword]; {
switch (bukva) { bukva = ESBYTE[bword];
if (ignor_text) && (bukva<>'<') continue;
switch (bukva)
{
case 0x0a: case 0x0a:
if (pre_text) if (pre_text)
{ {
bukva = ''; bukva = temp = '';
temp = '';
goto NEXT_MARK; goto NEXT_MARK;
} }
case '\9': case '\9':
@ -364,11 +367,14 @@ void TWebBrowser::ParseHTML(dword bword){
{ {
bukva = ESBYTE[bword]; bukva = ESBYTE[bword];
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
if (!ignor_param) && (bukva <>' ') strcat(#tag, #bukva); if (!ignor_param) && (bukva <>' ')
{
if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
}
else else
{ {
ignor_param = true; ignor_param = true;
strcat(#tagparam, #bukva); if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
} }
bword++; bword++;
} }
@ -401,7 +407,6 @@ void TWebBrowser::ParseHTML(dword bword){
break; break;
case '&': //îáðàáîòêà òåãîâ òèïà &nbsp; case '&': //îáðàáîòêà òåãîâ òèïà &nbsp;
if (ignor_text) break;
bword++; bword++;
tag=''; tag='';
for (j=0; (ESBYTE[bword] <>';') && (j < 7); j++, bword++;) for (j=0; (ESBYTE[bword] <>';') && (j < 7); j++, bword++;)
@ -431,7 +436,6 @@ void TWebBrowser::ParseHTML(dword bword){
break; break;
default: default:
DEFAULT_MARK: DEFAULT_MARK:
if (ignor_text) break;
if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break; if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
// //
if (stolbec + strlen(#line) > lines.column_max) if (stolbec + strlen(#line) > lines.column_max)
@ -501,7 +505,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
return; return;
} }
IF (ignor_text == 1) return; IF (ignor_text) return;
IF(!chTag("q")) strcat(#line, "\""); IF(!chTag("q")) strcat(#line, "\"");
@ -559,7 +563,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
return; return;
} }
//////////////////////////
if (!chTag("a")) if (!chTag("a"))
{ {
if (rez) if (rez)
@ -597,7 +601,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
} }
return; return;
} }
/////////////////////////
if (!chTag("font")) if (!chTag("font"))
{ {
if (rez) if (rez)
@ -619,7 +623,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
if (text_color_index > 0) text_color_index--; if (text_color_index > 0) text_color_index--;
return; return;
} }
//////////////////////////
if(!chTag("tr")) || (!chTag("br")) { if(!chTag("tr")) || (!chTag("br")) {
TextGoDown(left1, top1, width1); TextGoDown(left1, top1, width1);
return; return;
@ -634,7 +638,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
IF(rez) TextGoDown(left1, top1 + 10, width1); IF(rez) TextGoDown(left1, top1 + 10, width1);
return; return;
} }
////////////////////////////
if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
TextGoDown(left1, top1, width1); TextGoDown(left1, top1, width1);
IF(rez) TextGoDown(left1, top1 + 10, width1); IF(rez) TextGoDown(left1, top1 + 10, width1);

View File

@ -10,17 +10,23 @@ void GetNextParam()
i--; i--;
} }
IF (kavichki) if (kavichki)
{ {
i=strrchr(#tagparam, kavichki); i=strrchr(#tagparam, kavichki);
strcpy(#options, #tagparam + i); if (i>sizeof(options))
strcpy(#options, #tagparam + sizeof(options));
else
strcpy(#options, #tagparam + i);
} }
ELSE else
{ {
WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1; WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1;
i++; i++;
if (i>sizeof(options))
strcpy(#options, #tagparam + sizeof(options));
else
strcpy(#options, #tagparam + i);
strcpy(#options, #tagparam + i); //êîïèðóåì îïöèþ
WHILE (options[0] == ' ') strcpy(#options, #options+1); WHILE (options[0] == ' ') strcpy(#options, #options+1);
} }
tagparam[i] = 0x00; tagparam[i] = 0x00;
@ -31,6 +37,10 @@ void GetNextParam()
tagparam[i + 1] = 0x00; tagparam[i + 1] = 0x00;
} }
strcpy(#parametr, #tagparam + i + 1); //êîïèðóåì ïàðàìåòð if (i>sizeof(parametr))
strcpy(#parametr, #tagparam + sizeof(parametr));
else
strcpy(#parametr, #tagparam + i + 1);
tagparam[i] = 0x00; tagparam[i] = 0x00;
} }

View File

@ -1,43 +0,0 @@
: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

@ -1,95 +0,0 @@
//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 - ¢¥«¨ç¨­  ᬥ饭¨ï ¯à¨ ®¤­®ªà â­®¬ ­ ¦ â¨¨ ¡®ª®¢®© ª­®¯ª¨.