diff --git a/programs/network/htmlv/browser/HTMLv.c b/programs/network/htmlv/browser/HTMLv.c index 55198a2d91..3d96830e60 100644 --- a/programs/network/htmlv/browser/HTMLv.c +++ b/programs/network/htmlv/browser/HTMLv.c @@ -4,6 +4,7 @@ //home icon - rachel fu, GPL licence #include "..\lib\kolibri.h" +#include "..\lib\strings.h" #include "..\lib\encoding.h" #include "..\lib\file_system.h" #include "..\lib\mem.h" @@ -18,6 +19,8 @@ #include "img\toolbar_icons.c" #include "img\URLgoto.txt"; +#define DEBUG_ON 0 + //переменные char URL[4096], @@ -76,8 +79,8 @@ void main() //break; };*/ - btn=GetSlot(Form.ID); - IF (btn<>ActiveProcess()) break; //если окно не активно на события мыши не реагируем + btn=GetProcessSlot(Form.ID); + IF (btn<>GetActiveProcess()) break; //если окно не активно на события мыши не реагируем edit_box_mouse stdcall (#edit1); diff --git a/programs/network/htmlv/browser/TWB.h b/programs/network/htmlv/browser/TWB.h index 59397ffec2..b8b0596e7a 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.94d"; +char version[]=" Text-based Browser 0.94e"; struct TWebBrowser { @@ -39,7 +39,7 @@ int stroka, stolbec, tab_len; -char line[330], +char line[500], tag[100], tagparam[10000], parametr[1200], @@ -318,7 +318,9 @@ void TWebBrowser::ParseHTML(dword bword){ if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; - debug("Start parsing"); + #ifdef DEBUG_ON + debug("Start parsing"); + #endif for ( ; buf+filesize > bword; bword++;) {//ESBYTE[bword] bukva = ESBYTE[bword]; @@ -462,8 +464,10 @@ void TWebBrowser::ParseHTML(dword bword){ lines.first=anchor_line_num; ParseHTML(buf); } - - debug("End parsing"); + + #ifdef DEBUG_ON + debug("End parsing"); + #endif DrawScroller(); //рисуем скролл } @@ -472,9 +476,9 @@ char oldtag[100]; void TWebBrowser::WhatTextStyle(int left1, top1, width1) { dword hr_color; - dword image=0; + dword image; char temp[4096]; - int w, h, img_lines_first=0; + int w, h, img_lines_first, line_length; //проверяем тег открывается или закрывается IF(tag[0] == '/') @@ -513,15 +517,17 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { DrawBar(left, top, width-15, 15, bg_color); //закрашиваем первую строку first_line_drawed=1; } + line_length=strlen(#line)*6; 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); + //line_length = get_length stdcall (#line,-1,16,line_length); + //text_out stdcall (#line, -1, 17, text_colors[text_color_index], stolbec * 6 + left1, top1-2); 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]); //зачёркнутый - IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); //подчёркнутый + IF (i_text) Skew(stolbec * 6 + left1, top1, line_length+6, 10); //наклонный текст + IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, line_length, 1, text_colors[text_color_index]); //зачёркнутый + IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, line_length, 1, text_colors[text_color_index]); //подчёркнутый IF (link) { - DefineButton(stolbec * 6 + left1 - 2, top1, strlen(#line) * 6 + 3, 9, blink + BT_HIDE, 0xB5BFC9); // - DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); + DefineButton(stolbec * 6 + left1 - 2, top1, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); // + DrawBar(stolbec * 6 + left1, top1 + 8, line_length, 1, text_colors[text_color_index]); } } diff --git a/programs/network/htmlv/browser/include/menu_rmb.h b/programs/network/htmlv/browser/include/menu_rmb.h index 9639087b77..f56d47aff8 100644 --- a/programs/network/htmlv/browser/include/menu_rmb.h +++ b/programs/network/htmlv/browser/include/menu_rmb.h @@ -29,8 +29,8 @@ void menu_rmb() mm.get(); GetProcessInfo(#MenuForm, SelfInfo); - id1=GetSlot(MenuForm.ID); - if (id1<>ActiveProcess()) ExitProcess(); + id1=GetProcessSlot(MenuForm.ID); + if (id1<>GetActiveProcess()) ExitProcess(); id1=mm.y/ITEM_HEIGHT; if (id1<0) || (id1+1>items_num) || (mm.x<0) || (mm.x>ITEM_WIDTH) break; diff --git a/programs/network/htmlv/lib/kolibri.h b/programs/network/htmlv/lib/kolibri.h index 611c2a7584..350468e2f2 100644 --- a/programs/network/htmlv/lib/kolibri.h +++ b/programs/network/htmlv/lib/kolibri.h @@ -141,8 +141,6 @@ inline fastcall Pause( EBX) $int 0x40 } -//------------------------------------------------------------------------------ - inline fastcall word GetButtonID() { $mov eax,17 @@ -171,14 +169,14 @@ void GetProcessInfo( EBX, ECX) $int 0x40 } -int GetProcessSlot( ECX) //ECX = process ID +inline fastcall int GetProcessSlot( ECX) { EAX = 18; EBX = 21; - $int 0x40; + $int 0x40 } -inline fastcall int ActiveProcess() +inline fastcall int GetActiveProcess() { EAX = 18; EBX = 7; @@ -209,13 +207,6 @@ inline fastcall int GetSystemLanguage() $int 0x40 } -inline fastcall void DrawTitle( ECX) -{ - EAX = 71; - EBX = 1; - $int 0x40; -} - inline fastcall dword GetSkinWidth() { $push ebx @@ -225,7 +216,8 @@ inline fastcall dword GetSkinWidth() $pop ebx } -inline fastcall void SetSystemSkin(ECX){ +inline fastcall void SetSystemSkin( ECX) +{ EAX = 48; EBX = 8; $int 0x40 @@ -240,12 +232,6 @@ inline fastcall dword GetScreenWidth() $and eax,0x0000FFFF } -inline fastcall MoveSize( EBX,ECX,EDX,ESI) -{ - EAX = 67; - $int 0x40 -} - inline fastcall dword LoadLibrary( ECX) { $mov eax, 68 @@ -253,153 +239,15 @@ inline fastcall dword LoadLibrary( ECX) $int 0x40 } -//------------------------------------------------------------------------------ -inline fastcall dword strlen( EDI) -{ - EAX=0; - ECX=-1; - $REPNE $SCASB - EAX-=2+ECX; -} - - -inline fastcall strcpy( EDI, ESI) -{ - $cld -l2: - $lodsb - $stosb - $test al,al - $jnz l2 -} - -inline fastcall strcat( EDI, ESI) -{ - asm { - MOV EBX, EDI - XOR ECX, ECX - XOR EAX, EAX - DEC ECX - REPNE SCASB - DEC EDI - MOV EDX, EDI - MOV EDI, ESI - XOR ECX, ECX - XOR EAX, EAX - DEC ECX - REPNE SCASB - XOR ECX, 0FFFFFFFFH - MOV EDI, EDX - MOV EDX, ECX - MOV EAX, EDI - SHR ECX, 2 - REP MOVSD - MOV ECX, EDX - AND ECX, 3 - REP MOVSB - MOV EAX, EBX - } -} - -char buffer[11]=""; -inline fastcall dword IntToStr( ESI) -{ - $mov edi, #buffer - $mov ecx, 10 - $test esi, esi - $jns f1 - $mov al, '-' - $stosb - $neg esi -f1: - $mov eax, esi - $push -'0' -f2: - $xor edx, edx - $div ecx - $push edx - $test eax, eax - $jnz f2 -f3: - $pop eax - $add al, '0' - $stosb - $jnz f3 - $mov eax, #buffer - $ret -} - - -inline fastcall dword StrToInt() -{ - ESI=EDI=EAX; - IF(DSBYTE[ESI]=='-')ESI++; - EAX=0; - BH=AL; - do{ - BL=DSBYTE[ESI]-'0'; - EAX=EAX*10+EBX; - ESI++; - }while(DSBYTE[ESI]>0); - IF(DSBYTE[EDI]=='-') -EAX; -} - - -inline fastcall int strcmp( ESI, EDI) -{ - loop() - { - IF (DSBYTE[ESI]DSBYTE[EDI]) RETURN 1; - IF (DSBYTE[ESI]=='\0') RETURN 0; - ESI++; - EDI++; - } -} - -inline fastcall unsigned int find_symbol( ESI,BL) -{ - int jj=0, last=-1; - do{ - jj++; - $lodsb - IF(AL==BL) last=jj; - } while(AL!=0); - return last; -} - - -inline fastcall dword upcase( ESI) -{ - do{ - AL=DSBYTE[ESI]; - IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f; - ESI++; - }while(AL!=0); -} - -inline fastcall lowcase( ESI) -{ - do{ - $LODSB - IF(AL>='A')&&(AL<='Z'){ - AL+=0x20; - DSBYTE[ESI-1]=AL; - CONTINUE; - } - }while(AL!=0); -} - byte fastcall TestBit( EAX, CL) { $shr eax,cl $and eax,1 } + //------------------------------------------------------------------------------ - - void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI) { EAX = 12; // function 12:tell os about windowdraw @@ -418,6 +266,18 @@ void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaC $int 0x40 } +inline fastcall MoveSize( EBX,ECX,EDX,ESI) +{ + EAX = 67; + $int 0x40 +} + +inline fastcall void DrawTitle( ECX) +{ + EAX = 71; + EBX = 1; + $int 0x40; +} inline fastcall int CreateThread( ECX,EDX) { @@ -426,21 +286,6 @@ inline fastcall int CreateThread( ECX,EDX) $int 0x40 } -inline fastcall int GetSlot( ECX) -{ - EAX = 18; - EBX = 21; - $int 0x40 -} - -inline fastcall int GetActiveProcess() -{ - EAX = 18; - EBX = 7; - $int 0x40 -} - - void WriteText(dword x,y,byte fontType, dword color, EDX, ESI) { EAX = 4; @@ -503,7 +348,10 @@ inline fastcall void DeleteButton( EDX) $int 0x40; } -:void DrawRegion(dword x,y,width,height,color1) + +//------------------------------------------------------------------------------ + +void DrawRegion(dword x,y,width,height,color1) { DrawBar(x,y,width,1,color1); //Ї®«®б  Ј®а ᢥаег DrawBar(x,y+height,width,1,color1); //Ї®«®б  Ј®а б­Ё§г @@ -511,7 +359,7 @@ inline fastcall void DeleteButton( EDX) DrawBar(x+width,y,1,height+1,color1); //Ї®«®б  ўҐаег бЇа ў  } -:void DrawRegion_3D(dword x,y,width,height,color1,color2) +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); //Ї®«®б  б«Ґў  @@ -525,12 +373,14 @@ void DrawFlatButton(dword x,y,width,height,id,color,text) 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(-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) +void DrawCircle(int x, y, r) { - int i; float px=0, py=r, ii = r * 3.1415926 * 2; + int i; + float px=0, py=r, ii = r * 3.1415926 * 2; FOR (i = 0; i < ii; i++) { PutPixel(px + x, y - py, 0); diff --git a/programs/network/htmlv/lib/strings.h b/programs/network/htmlv/lib/strings.h new file mode 100644 index 0000000000..f2eac23396 --- /dev/null +++ b/programs/network/htmlv/lib/strings.h @@ -0,0 +1,189 @@ +//------------------------------------------------------------------------------ +// strlen( EDI) +// strcpy( EDI, ESI) +// strcat( EDI, ESI) +// IntToStr( ESI) +// StrToInt() +// strcmp( ESI, EDI) +// find_symbol( ESI,BL) +// upcase( ESI) +// lowcase( ESI) +// strstr( EBX, EDX) +//------------------------------------------------------------------------------ + +inline fastcall unsigned int strlen( EDI) +{ + $xor eax, eax + $mov ecx, -1 + $REPNE $SCASB + EAX-=2+ECX; +} + + +inline fastcall strcpy( EDI, ESI) +{ + $cld +l2: + $lodsb + $stosb + $test al,al + $jnz l2 +} + + +inline fastcall strcat( EDI, ESI) +{ + asm { + mov ebx, edi + xor ecx, ecx + xor eax, eax + dec ecx + repne scasb + dec edi + mov edx, edi + mov edi, esi + xor ecx, ecx + xor eax, eax + dec ecx + repne scasb + xor ecx, 0ffffffffh + mov edi, edx + mov edx, ecx + mov eax, edi + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 + rep movsb + mov eax, ebx + } +} + +char buffer[11]=""; +inline fastcall dword IntToStr( ESI) +{ + $mov edi, #buffer + $mov ecx, 10 + $test esi, esi + $jns f1 + $mov al, '-' + $stosb + $neg esi +f1: + $mov eax, esi + $push -'0' +f2: + $xor edx, edx + $div ecx + $push edx + $test eax, eax + $jnz f2 +f3: + $pop eax + $add al, '0' + $stosb + $jnz f3 + $mov eax, #buffer + $ret +} + + +inline fastcall dword StrToInt() +{ + ESI=EDI=EAX; + IF(DSBYTE[ESI]=='-')ESI++; + EAX=0; + BH=AL; + do{ + BL=DSBYTE[ESI]-'0'; + EAX=EAX*10+EBX; + ESI++; + }while(DSBYTE[ESI]>0); + IF(DSBYTE[EDI]=='-') -EAX; +} + + +inline fastcall signed int strcmp( ESI, EDI) +{ + loop() + { + IF (DSBYTE[ESI]DSBYTE[EDI]) RETURN 1; + IF (DSBYTE[ESI]=='\0') RETURN 0; + ESI++; + EDI++; + } +} + +inline fastcall unsigned int find_symbol( ESI,BL) +{ + int jj=0, last=-1; + do{ + jj++; + $lodsb + IF(AL==BL) last=jj; + } while(AL!=0); + return last; +} + + +inline fastcall upcase( ESI) +{ + do{ + AL=DSBYTE[ESI]; + IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f; + ESI++; + }while(AL!=0); +} + +inline fastcall lowcase( ESI) +{ + do{ + $LODSB + IF(AL>='A')&&(AL<='Z'){ + AL+=0x20; + DSBYTE[ESI-1]=AL; + CONTINUE; + } + }while(AL!=0); +} + + +inline fastcall unsigned int strstr( EBX, EDX) +{ + asm { + mov edi, edx + xor ecx, ecx + xor eax, eax + dec ecx + repne scasb + not ecx + dec ecx + je ls2 + mov esi, ecx + xor ecx, ecx + mov edi, ebx + dec ecx + repne scasb + not ecx + sub ecx, esi + jbe ls2 + mov edi, ebx + lea ebx, dsdword[ esi-1] +ls1: mov esi, edx + lodsb + repne scasb + jne ls2 + mov eax, ecx + push edi + mov ecx, ebx + repe cmpsb + pop edi + mov ecx, eax + jne ls1 + lea eax, dsdword[ edi-1] + jmp short ls3 +ls2: xor eax, eax +ls3: + } +} \ No newline at end of file