Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4415 → Rev 4416

/programs/cmm/TWB/TWB.c
6,14 → 6,24
filesize,
blink;
 
#define URL param
 
int mouse_twb;
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
scroll_bar scroll_wv = { 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};
 
char editURL[sizeof(URL)],
page_links[12000],
header[2048];
 
 
 
char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s=";
 
 
struct TWebBrowser {
llist list; //need #include "..\lib\list_box.h"
void GetNewUrl();
void OpenPage();
void ReadHtml(byte);
void ShowPage();
void ParseHTML(dword);
45,6 → 55,7
options[4096],
anchor[256];
 
#include "..\TWB\history.h"
#include "..\TWB\colors.h"
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
157,30 → 168,6
}
 
 
void TWebBrowser::OpenPage()
{
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
KillProcess(downloader_id);
strcpy(#editURL, #URL);
BrowserHistory.AddUrl();
strcpy(#header, #version);
pre_text =0;
if (!strcmp(get_URL_part(5),"http:")))
{
KillProcess(downloader_id);
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
downloader_id = RunProgram("/sys/network/downloader", #URL);
IF (downloader_id<0) notify("Error running Downloader. Internet unavilable.");
Draw_Window();
return;
}
list.first = list.count =0;
ReadHtml(_WIN);
WB1.ShowPage();
}
 
 
void TWebBrowser::ShowPage()
{
address_box.size = address_box.pos = strlen(#editURL);
189,7 → 176,7
 
if (!filesize)
{
DrawBar(list.x, list.y, list.w+scroll1.size_x+1, list.h, 0xFFFFFF); //fill all
DrawBar(list.x, list.y, list.w+scroll_wv.size_x+1, list.h, 0xFFFFFF); //fill all
if (GetProcessSlot(downloader_id)<>0) WriteText(list.x + 10, list.y + 18, 0x80, 0, "Loading...");
else
{
614,14 → 601,14
 
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
{
scroll1.max_area = list.count;
scroll1.cur_area = list.visible;
scroll1.position = list.first;
scroll_wv.max_area = list.count;
scroll_wv.cur_area = list.visible;
scroll_wv.position = list.first;
 
scroll1.all_redraw=1;
scroll1.start_x = WB1.list.x + WB1.list.w;
scroll1.size_y=WB1.list.h;
scroll_wv.all_redraw=1;
scroll_wv.start_x = WB1.list.x + WB1.list.w;
scroll_wv.size_y=WB1.list.h;
 
scrollbar_v_draw(#scroll1);
scrollbar_v_draw(#scroll_wv);
}
 
/programs/cmm/TWB/history.h
0,0 → 1,59
struct UrlsHistory {
dword CurrentUrl();
void AddUrl();
byte GoBack();
byte GoForward();
};
 
UrlsHistory BrowserHistory;
 
struct path_string {
char Item[4096];
};
 
#define MAX_HISTORY_NUM 40
path_string history_list[MAX_HISTORY_NUM];
int history_num;
int history_current;
 
dword UrlsHistory::CurrentUrl()
{
return #history_list[history_current].Item;
}
 
void UrlsHistory::AddUrl() //òóò íóæåí ââîäèìûé ýëåìåíò - äëÿ óíèâåðñàëüíîñòè
{
int i;
if (history_num>0) && (!strcmp(#URL,#history_list[history_current].Item)) return;
 
if (history_current>=MAX_HISTORY_NUM-1)
{
history_current/=2;
for (i=0; i<history_current; i++;)
{
strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(history_list[0].Item));
}
}
history_current++;
strlcpy(#history_list[history_current].Item, #URL, sizeof(history_list[0].Item));
history_num=history_current;
}
 
 
byte UrlsHistory::GoBack()
{
if (history_current<=1) return 0;
history_current--;
strlcpy(#URL, #history_list[history_current].Item, sizeof(URL));
return 1;
}
 
 
byte UrlsHistory::GoForward()
{
if (history_current==history_num) return 0;
history_current++;
strlcpy(#URL, #history_list[history_current].Item, sizeof(URL));
return 1;
}
/programs/cmm/TWB/img_cache.h
24,7 → 24,6
if (pics[num_of_pics].image) img_destroy stdcall (pics[num_of_pics].image);
pics[num_of_pics].path = NULL;
}
notify(IMAGES_CACHE_CLEARED);
}
 
 
42,8 → 41,6
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
{
debug("image options:");
debug(#options);
//get path: absolute or relative
if (options[0]=='/')
strcpy(#img_path, #options);
52,8 → 49,6
img_path[strrchr(#img_path, '/')] = '\0';
strcat(#img_path, #options);
}
debug("image img_path:");
debug(#img_path);
cur_pic=GetOrSetPicNum(#img_path);
if (!pics[cur_pic].path)
{
/programs/cmm/browser/history.h
File deleted
\ No newline at end of file
/programs/cmm/browser/HTMLv.c
26,38 → 26,25
#include "img\URLgoto.txt";
 
#ifdef LANG_RUS
char version[]=" ’ҐЄбв®ўл© Ўа г§Ґа 0.99.3";
?define IMAGES_CACHE_CLEARED "Љни Є авЁ­®Є ®зЁйҐ­"
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.31";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
#else
char version[]=" Text-based Browser 0.99.3";
char version[]=" Text-based Browser 0.99.31";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
#endif
 
 
#define URL param
char fontlol[64];
 
char editURL[sizeof(URL)],
page_links[12000],
header[2048];
 
 
int mouse_dd;
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#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};
 
 
proc_info Form;
#define WIN_W 640
#define WIN_H 480
 
char search_path[]="http://nigma.ru/index.php?s=";
 
char stak[4096];
mouse m;
 
int action_buf;
 
#include "history.h"
 
 
#include "..\TWB\TWB.c"
#include "menu_rmb.h"
 
79,7 → 66,7
Form.width=WIN_W;
Form.height=WIN_H;
SetElementSizes();
WB1.OpenPage();
OpenPage();
 
SetEventMask(0x27);
loop()
90,10 → 77,10
CASE evMouse:
/*
//not work well, so we are use custom way of processing scroll
scrollbar_v_mouse (#scroll1);
if (WB1.list.first <> scroll1.position)
scrollbar_v_mouse (#scroll_wv);
if (WB1.list.first <> scroll_wv.position)
{
WB1.list.first = scroll1.position;
WB1.list.first = scroll_wv.position;
WB1.ParseHTML(buf, filesize);
};
*/
125,8 → 112,8
}
if (!m.lkm) scroll_used=0;
if (m.x>=scroll1.start_x) && (m.x<=scroll1.start_x+scroll1.size_x)
&& (m.y>=scroll1.start_y+scroll1.btn_height) && (-scroll1.btn_height+scroll1.start_y+scroll1.size_y>m.y)
if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x)
&& (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
&& (WB1.list.count>WB1.list.visible) && (m.lkm)
{
scroll_used=1;
135,11 → 122,11
if (scroll_used)
{
half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y; //åñëè êóðñîð íàä îêíîì
btn=WB1.list.first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y;
btn=WB1.list.first;
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
if (btn<>WB1.list.first) WB1.ParseHTML(buf); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
if (btn<>WB1.list.first) WB1.ParseHTML(buf);
}
 
break;
158,13 → 145,13
case evKey:
key = GetKey();
if (address_box.flags & 0b10) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
if (address_box.flags & 0b10) SWITCH(key)
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
 
Scan(key);
_EDIT_MARK:
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} //àäðåñíàÿ ñòðîêà
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
break;
case evReDraw:
if (action_buf) { Scan(action_buf); action_buf=0;}
186,7 → 173,7
void SetElementSizes()
{
address_box.width = Form.width-266;
WB1.list.SetSizes(0, 44, Form.width - 10 - scroll1.size_x, Form.cheight - 44, 0, 10);
WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10);
WB1.list.column_max = WB1.list.w - 30 / 6;
WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
DrawBufInit();
223,8 → 210,8
SetElementSizes();
WB1.ShowPage();
 
DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1);
DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+scroll_wv.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1);
}
 
 
251,16 → 238,17
 
case 002: //free img cache
FreeImgCache();
notify(IMAGES_CACHE_CLEARED);
WB1.ParseHTML(buf);
return;
 
case BACK:
if (!BrowserHistory.GoBack()) return;
WB1.OpenPage();
OpenPage();
return;
case FORWARD:
if (!BrowserHistory.GoForward()) return;
WB1.OpenPage();
OpenPage();
return;
case 052: //F3
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL);
280,7 → 268,7
}
anchor_line_num=WB1.list.first;
anchor[0]='|';
WB1.OpenPage();
OpenPage();
return;
case 014:
case 020:
295,12 → 283,12
case 0x0D: //enter
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
strcat(#URL, #editURL);
WB1.OpenPage();
OpenPage();
return;
case SEARCHWEB:
strcpy(#URL, #search_path);
strcat(#URL, #editURL);
WB1.OpenPage();
OpenPage();
return;
 
case 183: //PgDown
320,15 → 308,15
return;
 
case 178:
case BTN_UP: //мотаем вверх
IF(WB1.list.first <= 0) return;
case BTN_UP: //ìîòàåì ââåðõ
if (WB1.list.first <= 0) return;
WB1.list.first--;
WB1.ParseHTML(buf);
return;
 
case 177:
case BTN_DOWN: //мотаем вниз
IF(WB1.list.visible + WB1.list.first >= WB1.list.count) return;
case BTN_DOWN: //ìîòàåì âíèç
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
WB1.list.first++;
WB1.ParseHTML(buf);
return;
365,7 → 353,7
if (strrchr(#URL, '#')<>-1)
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
URL[strrchr(#URL, '#')-1] = 0x00;
}
WB1.GetNewUrl();
386,12 → 374,33
return;
}
 
WB1.OpenPage();
OpenPage();
return;
}
 
void OpenPage()
{
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
KillProcess(downloader_id);
strcpy(#editURL, #URL);
BrowserHistory.AddUrl();
strcpy(#header, #version);
pre_text =0;
if (!strcmp(get_URL_part(5),"http:")))
{
KillProcess(downloader_id);
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
downloader_id = RunProgram("/sys/network/downloader", #URL);
IF (downloader_id<0) notify("Error running Downloader. Internet unavilable.");
Draw_Window();
return;
}
WB1.list.first = WB1.list.count =0;
WB1.ReadHtml(_WIN);
WB1.ShowPage();
}
 
 
 
 
stop: