Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2810 → Rev 2811

/programs/network/htmlv/browser/HTMLv.c--
File deleted
/programs/network/htmlv/browser/HTMLv.c
0,0 → 1,198
//HTML Viewer in C--
//Copyright 2007-2012 by Veliant & Leency
//Asper, lev, Lrz, Barsuk, Nable.
//home icon - rachel fu, GPL licence
 
#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\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],
editURL[4096],
page_links[12000],
header[512];
 
struct lines{
int visible, all, first, column_max;
};
 
int 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;
dword stak[100]; //ìåíþ ÏÊÌ
mouse m;
 
#include "TWB.h"
#include "include\menu_rmb.h"
 
 
void main()
{
int btn;
byte key;
int half_scroll_size;
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) strcpy(#URL, #param);
else strcpy(#URL, "/sys/index.htm");
strcpy(#editURL, #URL);
WB1.OpenPage();
 
SetEventMask(0x27);
loop()
{
WaitEventTimeout(2);
switch(EAX & 0xFF)
{
CASE evMouse:
/*scrollbar_v_mouse (#scroll1); //êîí÷åíûé ñêðîëë ïðèòîðìàæèìàåò, èä¸ì "ñâîèì ïóò¸ì"
if (lines.first <> scroll1.position)
{
lines.first = scroll1.position;
WB1.ParseHTML(buf, filesize);
//break;
};*/
btn=GetSlot(Form.ID);
IF (btn<>ActiveProcess()) break; //åñëè îêíî íå àêòèâíî íà ñîáûòèÿ ìûøè íå ðåàãèðóåì
 
edit_box_mouse stdcall (#edit1);
 
m.get();
if (m.pkm) && (m.y>WB1.top) && (m.y<Form.height) && (filesize)
{
CreateThread(#menu_rmb,#stak);
}
 
IF (m.vert==65535) //ïðîêðóòêà êîë¸ñèêîì
{
IF (lines.first==0) break;
IF (lines.first>3) lines.first-=2; ELSE lines.first=1;
WB1.Scan(ID1);
break;
}
IF (m.vert==1)
{
IF(lines.visible+lines.first+3>=lines.all) WB1.Scan(181);
ELSE {
lines.first+=2;
WB1.Scan(ID2);
}
break;
}
IF (lines.all<lines.visible) break;
half_scroll_size = WB1.height - 16 * lines.visible / lines.all - 3 /2;
if (m.x>=WB1.width-14) && (m.x<=WB1.width+6)
&& (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; //åñëè êóðñîð íàä îêíîì
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;
IF (btn<>lines.first) WB1.ParseHTML(buf, filesize); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
m.get();
}
 
break;
case evButton:
btn=GetButtonID();
IF (btn==1)
{
KillProcess(downloader_id);
ExitProcess();
}
ELSE
{
WB1.Scan(btn);
}
break;
case evKey:
key = GetKey();
if (edit1.flags == 66) || (edit1.flags == 98) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
 
WB1.Scan(key);
_EDIT_MARK:
IF (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //àäðåñíàÿ ñòðîêà
break;
case evReDraw:
Draw_Window();
break;
default:
if (downloader_id<>0)
{
if (GetProcessSlot(downloader_id)<>0) break;
downloader_id=0;
lines.first = lines.all = 0;
WB1.ReadHtml(_WIN);
Draw_Window();
}
}
}
}
 
 
void Draw_Window()
{
int j;
DefineAndDrawWindow(215,100,640,480,0x73,0x00E4DFE1,0,0,0);
 
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) //åñëè ñâåðíóòî â çàãîëîâîê, íè÷åãî íå ðèñóåì
{
DrawTitle(#header);
return;
}
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
if (GetProcessSlot(downloader_id)<>0) PutImage(#stop_btn,24,24,88,10);
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);
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(205,14,onLeft(58,205),18,0x94AECE); //îáîäîê ïîëîñû àäðåñà
DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3);
 
edit1.width=Form.width-266;
WB1.top=44;
WB1.width=Form.width-13;
WB1.height=onTop(43,5);
lines.column_max = WB1.width - 30 / 6;
lines.visible = WB1.height - 3 / 10 - 2;
 
WB1.ShowPage();
}
int onLeft(dword right,left) {return Form.width-right-left;}
int onTop(dword down,up) {return Form.height-GetSkinWidth()-down-up;}
 
 
stop:
/programs/network/htmlv/browser/TWB.h
9,16 → 9,18
 
char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.94";
char version[]=" Text-based Browser 0.94b";
 
 
struct TWebBrowser {
int left, top, width, height;
void DrawScroller();
void Scan(int);
void OpenPage();
void ReadHtml(byte);
void ShowPage();
void ParseHTML(dword, dword);
void Scan(int);
void WhatTextStyle(int left1, top1, width1);
void DrawScroller();
};
 
TWebBrowser WB1;
64,8 → 66,8
strcpy(#URL, BrowserHistory.CurrentUrl());
lines_first=lines_all-lines_visible;
ShowPage(#URL);
lines.first=lines.all-lines.visible;
ShowPage();
return;
}
//liner.ru#1
88,18 → 90,16
return;
}
IF(lines_all < lines_visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
switch (id)
{
case 011: //Ctrk+K
ReadHtml();
koitodos(buf);
ReadHtml(_KOI);
break;
case 021: //Ctrl+U
ReadHtml();
utf8rutodos(buf);
ReadHtml(_UTF);
break;
case BACK:
if (!BrowserHistory.GoBack()) return;
125,7 → 125,7
Draw_Window();
return;
}
anchor_line_num=lines_first; //âåñ¸ëûé êîñòûëü :Ð
anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
anchor[0]='|';
OpenPage();
return;
151,30 → 151,30
return;
 
case ID1: //ìîòàåì ââåðõ
IF(lines_first <= 0) return;
lines_first--;
IF(lines.first <= 0) return;
lines.first--;
break;
case ID2: //ìîòàåì âíèç
IF(lines_visible + lines_first >= lines_all) return;
lines_first++;
IF(lines.visible + lines.first >= lines.all) return;
lines.first++;
break;
case 183: //PgDown
IF(lines_first == lines_all - lines_visible) return;
lines_first += lines_visible + 2;
IF(lines_visible + lines_first > lines_all) lines_first = lines_all - lines_visible;
IF(lines.first == lines.all - lines.visible) return;
lines.first += lines.visible + 2;
IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
BREAK;
case 184: //PgUp
IF(lines_first == 0) RETURN;
lines_first -= lines_visible - 2;
IF(lines_first < 0) lines_first = 0;
IF(lines.first == 0) RETURN;
lines.first -= lines.visible - 2;
IF(lines.first < 0) lines.first = 0;
BREAK;
case 180: //home
IF(lines_first == 0) RETURN;
lines_first = 0;
IF(lines.first == 0) RETURN;
lines.first = 0;
BREAK;
case 181: //end
IF (lines_first == lines_all - lines_visible) RETURN;
lines_first = lines_all - lines_visible;
IF (lines.first == lines.all - lines.visible) RETURN;
lines.first = lines.all - lines.visible;
BREAK;
default:
RETURN;
214,7 → 214,7
 
 
void ReadHtml()
void TWebBrowser::ReadHtml(byte dest)
{
if (!strcmp(get_URL_part(5),"http:")))
file_size stdcall (#download_path);
230,10 → 230,14
ReadFile(0, filesize, buf, #download_path);
else
ReadFile(0, filesize, buf, #URL);
if (dest==_WIN) wintodos(buf);
if (dest==_UTF) utf8rutodos(buf);
if (dest==_KOI) koitodos(buf);
}
 
 
void OpenPage()
void TWebBrowser::OpenPage()
{
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
KillProcess(downloader_id);
258,14 → 262,13
Draw_Window();
return;
}
lines_first = lines_all = 0;
ReadHtml();
if (filesize) wintodos(buf);
WB1.ShowPage(#URL);
lines.first = lines.all = 0;
ReadHtml(_WIN);
WB1.ShowPage();
}
 
 
void TWebBrowser::ShowPage(dword adress)
void TWebBrowser::ShowPage()
{
edit1.size = edit1.pos = strlen(#editURL);
edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
295,7 → 298,7
byte ignor_param = 0;
char temp[768];
stroka = -lines_first;
stroka = -lines.first;
stolbec = 0;
for (j = 400; j < blink + 1; j++;) DeleteButton(j);
420,12 → 423,12
IF(ignor_text) break;
IF(!pre_text) && (bukva == ' ') && (!strcmp(#line + strlen(#line) - 1, " ")) continue;
//
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;
NEXT_MARK:
IF(stroka - 1 > lines_visible) && (lines_first <>0) break 1; //óõîäèì...
IF(stroka - 1 > 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);
437,16 → 440,16
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);
if (lines.visible * 10 + 25 <= height)
DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
if (stroka * 10 + 15 <= height)
DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
if (lines_first == 0) lines_all = stroka;
if (lines.first == 0) lines.all = stroka;
if (anchor)
{
anchor='';
lines_first=anchor_line_num;
lines.first=anchor_line_num;
ParseHTML(buf, filesize);
}
 
536,7 → 539,7
IF(!chTag("q")) strcat(#line, "\"");
//âûâîä íà ýêðàí
if (stroka >= 0) && (stroka - 2 < lines_visible) && (line) && (!anchor)
if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
{
WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
IF (b_text) { $add ebx, 1<<16 $int 0x40 }
556,7 → 559,7
{
if (!strcmp(#anchor, #options))
{
anchor_line_num=lines_first+stroka;
anchor_line_num=lines.first+stroka;
}
}
 
595,7 → 598,7
_A_MARK:
if (!strcmp(#parametr, "href="))
{
if (stroka - 1 > lines_visible) || (stroka < -2) return;
if (stroka - 1 > lines.visible) || (stroka < -2) return;
if (link == 1) text_color_index--; //åñëè êàêîé-òî äîëáî¸á íå çàêðûë òýã
link = 1;
blink++;
608,7 → 611,7
{
if (!strcmp(#anchor, #options))
{
anchor_line_num=lines_first+stroka;
anchor_line_num=lines.first+stroka;
}
}
if (tagparam)
626,7 → 629,7
/////////////////////////
if (!chTag("font"))
{
IF (stroka - 1 > lines_visible) return;
IF (stroka - 1 > lines.visible) return;
COL_MARK:
if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
{
689,7 → 692,7
li_text = rez;
IF(rez == 0) return;
TextGoDown(left1, top1, width1);
IF(stroka > -1) && (stroka - 2 < lines_visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
return;
}
////////////////////////////
746,7 → 749,7
top1=WB1.top;
}
if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < lines_visible)
if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < lines.visible)
{
h=WB1.top+WB1.height-top1-15;
}
775,21 → 778,10
{
strcpy(#options, #options[find_symbol(#options, '=')]); //ïîèñê â content=
 
IF (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))
{
ReadHtml();
utf8rutodos(buf);
if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF);
if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI);
if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS);
}
IF(!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))
{
ReadHtml();
koitodos(buf);
}
IF(!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))
{
ReadHtml();
}
}
if (tagparam)
{
GetNextParam();
806,7 → 798,7
IF(blq_text == 1) stolbec = 8;
ELSE stolbec = 0;
IF(li_text == 1) stolbec = li_tab * 5;
IF(stroka >= 0) && (stroka - 2 < lines_visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
}
 
 
813,9 → 805,9
//ñêðîëë
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
{
scroll1.max_area = lines_all;
scroll1.cur_area = lines_visible;
scroll1.position = lines_first;
scroll1.max_area = lines.all;
scroll1.cur_area = lines.visible;
scroll1.position = lines.first;
 
scroll1.all_redraw=1;
scroll1.start_x=Form.width-28; //left + width - 15
/programs/network/htmlv/browser/compile.bat
1,6 → 1,6
..\C--\c-- HTMLv.c--
..\C--\c-- HTMLv.c
del HTMLv
rename HTMLv.com HTMLv
rem ..\C--\kpack HTMLv
pause
del warning.txt
pause
/programs/network/htmlv/browser/include/some_code.h
9,10 → 9,10
#define ID1 178
#define ID2 177
 
#define WINDOWS 0
#define DOS 1
#define KOI 2
#define UTF 3
#define _WIN 0
#define _DOS 1
#define _KOI 2
#define _UTF 3
 
dword get_URL_part(byte len) {