forked from KolibriOS/kolibrios
code refactoring #3
HTMLv 0.99.3: use list_box.h git-svn-id: svn://kolibrios.org@4415 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
3953f09968
commit
b0297021f9
@ -1,5 +1,3 @@
|
|||||||
#include "..\lib\list_box.h"
|
|
||||||
|
|
||||||
|
|
||||||
int downloader_id;
|
int downloader_id;
|
||||||
|
|
||||||
@ -11,12 +9,9 @@ dword
|
|||||||
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=";
|
||||||
|
|
||||||
struct lines{
|
|
||||||
int visible, all, first, column_max;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TWebBrowser {
|
struct TWebBrowser {
|
||||||
llist list;
|
llist list; //need #include "..\lib\list_box.h"
|
||||||
void GetNewUrl();
|
void GetNewUrl();
|
||||||
void OpenPage();
|
void OpenPage();
|
||||||
void ReadHtml(byte);
|
void ReadHtml(byte);
|
||||||
@ -73,7 +68,7 @@ void TWebBrowser::DrawPage()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
|
if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
|
||||||
{
|
{
|
||||||
start_x = stolbec * 6 + list.x + magrin_left;
|
start_x = stolbec * 6 + list.x + magrin_left;
|
||||||
start_y = stroka * 10 + list.y + magrin_left;
|
start_y = stroka * 10 + list.y + magrin_left;
|
||||||
@ -172,25 +167,15 @@ void TWebBrowser::OpenPage()
|
|||||||
pre_text =0;
|
pre_text =0;
|
||||||
if (!strcmp(get_URL_part(5),"http:")))
|
if (!strcmp(get_URL_part(5),"http:")))
|
||||||
{
|
{
|
||||||
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
|
KillProcess(downloader_id);
|
||||||
DeleteFile(#download_path);
|
DeleteFile(#download_path);
|
||||||
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
|
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
|
||||||
downloader_id = RunProgram("/sys/network/downloader", #URL);
|
downloader_id = RunProgram("/sys/network/downloader", #URL);
|
||||||
//Browser Hack v2.0
|
IF (downloader_id<0) notify("Error running Downloader. Internet unavilable.");
|
||||||
/*
|
|
||||||
pause(60);
|
|
||||||
if (GetProcessSlot(downloader_id)<>0)
|
|
||||||
{
|
|
||||||
debug("Browser Hack v2.0: Killing downloader and trying to run it one more!");
|
|
||||||
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
|
|
||||||
downloader_id = RunProgram("/sys/network/downloader", #URL);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
|
|
||||||
Draw_Window();
|
Draw_Window();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lines.first = lines.all =0;
|
list.first = list.count =0;
|
||||||
ReadHtml(_WIN);
|
ReadHtml(_WIN);
|
||||||
WB1.ShowPage();
|
WB1.ShowPage();
|
||||||
}
|
}
|
||||||
@ -237,7 +222,7 @@ void TWebBrowser::ParseHTML(dword bword){
|
|||||||
DrawBufFill();
|
DrawBufFill();
|
||||||
strcpy(#page_links,"|");
|
strcpy(#page_links,"|");
|
||||||
strcpy(#header, #version);
|
strcpy(#header, #version);
|
||||||
stroka = -lines.first;
|
stroka = -list.first;
|
||||||
stolbec = 0;
|
stolbec = 0;
|
||||||
line = 0;
|
line = 0;
|
||||||
|
|
||||||
@ -335,13 +320,13 @@ void TWebBrowser::ParseHTML(dword bword){
|
|||||||
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
||||||
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
|
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
|
||||||
|
|
||||||
if (stolbec + strlen(#line) > lines.column_max) //============the same as NEXT_MARK
|
if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK
|
||||||
{
|
{
|
||||||
perenos_num = strrchr(#line, ' ');
|
perenos_num = strrchr(#line, ' ');
|
||||||
if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
|
if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
|
||||||
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
||||||
line[perenos_num] = 0x00;
|
line[perenos_num] = 0x00;
|
||||||
if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
|
if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
|
||||||
DrawPage();
|
DrawPage();
|
||||||
strcpy(#line, #temp);
|
strcpy(#line, #temp);
|
||||||
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||||
@ -363,14 +348,14 @@ void TWebBrowser::ParseHTML(dword bword){
|
|||||||
}
|
}
|
||||||
if (strlen(#line)<sizeof(line)) chrcat(#line, bukva);
|
if (strlen(#line)<sizeof(line)) chrcat(#line, bukva);
|
||||||
|
|
||||||
if (stolbec + strlen(#line) > lines.column_max)
|
if (stolbec + strlen(#line) > list.column_max)
|
||||||
{
|
{
|
||||||
NEXT_MARK:
|
NEXT_MARK:
|
||||||
perenos_num = strrchr(#line, ' ');
|
perenos_num = strrchr(#line, ' ');
|
||||||
if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
|
if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
|
||||||
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
||||||
line[perenos_num] = 0x00;
|
line[perenos_num] = 0x00;
|
||||||
if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
|
if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
|
||||||
DrawPage();
|
DrawPage();
|
||||||
strcpy(#line, #temp);
|
strcpy(#line, #temp);
|
||||||
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||||
@ -381,15 +366,15 @@ void TWebBrowser::ParseHTML(dword bword){
|
|||||||
DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
|
DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
|
||||||
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||||
|
|
||||||
if (lines.visible * 10 + 25 <= list.h)
|
if (list.visible * 10 + 25 <= list.h)
|
||||||
DrawBar(list.x, lines.visible * 10 + list.y + 25, list.w, -lines.visible * 10 + list.h - 25, bg_color);
|
DrawBar(list.x, list.visible * 10 + list.y + 25, list.w, -list.visible * 10 + list.h - 25, bg_color);
|
||||||
if (stroka * 10 + 5 <= list.h)
|
if (stroka * 10 + 5 <= list.h)
|
||||||
DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
|
DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
|
||||||
if (lines.first == 0) lines.all = stroka;
|
if (list.first == 0) list.count = stroka;
|
||||||
if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
|
if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
|
||||||
{
|
{
|
||||||
anchor=NULL;
|
anchor=NULL;
|
||||||
lines.first=anchor_line_num;
|
list.first=anchor_line_num;
|
||||||
ParseHTML(buf);
|
ParseHTML(buf);
|
||||||
}
|
}
|
||||||
DrawScroller();
|
DrawScroller();
|
||||||
@ -432,7 +417,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
|
|
||||||
if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
|
if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
|
||||||
{
|
{
|
||||||
if (!strcmp(#anchor, #options)) anchor_line_num=lines.first+stroka;
|
if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chTag("body"))
|
if (!chTag("body"))
|
||||||
@ -458,7 +443,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr, "href="))
|
if (!strcmp(#parametr, "href="))
|
||||||
{
|
{
|
||||||
if (stroka - 1 > lines.visible) || (stroka < -2) return;
|
if (stroka - 1 > list.visible) || (stroka < -2) return;
|
||||||
|
|
||||||
text_color_index++;
|
text_color_index++;
|
||||||
text_colors[text_color_index] = text_colors[text_color_index-1];
|
text_colors[text_color_index] = text_colors[text_color_index-1];
|
||||||
@ -473,7 +458,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
{
|
{
|
||||||
if (!strcmp(#anchor, #options))
|
if (!strcmp(#anchor, #options))
|
||||||
{
|
{
|
||||||
anchor_line_num=lines.first+stroka;
|
anchor_line_num=list.first+stroka;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(GetNextParam());
|
} while(GetNextParam());
|
||||||
@ -578,7 +563,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
if (rez)
|
if (rez)
|
||||||
{
|
{
|
||||||
TextGoDown(left1, top1, width1);
|
TextGoDown(left1, top1, width1);
|
||||||
if (stroka > -1) && (stroka - 2 < lines.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
|
if (stroka > -1) && (stroka - 2 < list.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -629,9 +614,9 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
|
|
||||||
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
|
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
|
||||||
{
|
{
|
||||||
scroll1.max_area = lines.all;
|
scroll1.max_area = list.count;
|
||||||
scroll1.cur_area = lines.visible;
|
scroll1.cur_area = list.visible;
|
||||||
scroll1.position = lines.first;
|
scroll1.position = list.first;
|
||||||
|
|
||||||
scroll1.all_redraw=1;
|
scroll1.all_redraw=1;
|
||||||
scroll1.start_x = WB1.list.x + WB1.list.w;
|
scroll1.start_x = WB1.list.x + WB1.list.w;
|
||||||
|
@ -42,6 +42,8 @@ void Images(int left1, top1, width1)
|
|||||||
|
|
||||||
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
||||||
{
|
{
|
||||||
|
debug("image options:");
|
||||||
|
debug(#options);
|
||||||
//get path: absolute or relative
|
//get path: absolute or relative
|
||||||
if (options[0]=='/')
|
if (options[0]=='/')
|
||||||
strcpy(#img_path, #options);
|
strcpy(#img_path, #options);
|
||||||
@ -50,6 +52,8 @@ void Images(int left1, top1, width1)
|
|||||||
img_path[strrchr(#img_path, '/')] = '\0';
|
img_path[strrchr(#img_path, '/')] = '\0';
|
||||||
strcat(#img_path, #options);
|
strcat(#img_path, #options);
|
||||||
}
|
}
|
||||||
|
debug("image img_path:");
|
||||||
|
debug(#img_path);
|
||||||
cur_pic=GetOrSetPicNum(#img_path);
|
cur_pic=GetOrSetPicNum(#img_path);
|
||||||
if (!pics[cur_pic].path)
|
if (!pics[cur_pic].path)
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
|
|
||||||
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT };
|
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
|
||||||
enum { _WIN, _DOS, _KOI, _UTF };
|
enum { _WIN, _DOS, _KOI, _UTF };
|
||||||
|
|
||||||
#define ID1 178
|
|
||||||
#define ID2 177
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dword get_URL_part(int len) {
|
dword get_URL_part(int len) {
|
||||||
char temp1[sizeof(URL)];
|
char temp1[sizeof(URL)];
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "..\lib\file_system.h"
|
#include "..\lib\file_system.h"
|
||||||
#include "..\lib\mem.h"
|
#include "..\lib\mem.h"
|
||||||
#include "..\lib\dll.h"
|
#include "..\lib\dll.h"
|
||||||
|
#include "..\lib\list_box.h"
|
||||||
//*.obj libraries
|
//*.obj libraries
|
||||||
#include "..\lib\lib.obj\box_lib.h"
|
#include "..\lib\lib.obj\box_lib.h"
|
||||||
#include "..\lib\lib.obj\libio_lib.h"
|
#include "..\lib\lib.obj\libio_lib.h"
|
||||||
@ -25,10 +26,10 @@
|
|||||||
#include "img\URLgoto.txt";
|
#include "img\URLgoto.txt";
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.11";
|
char version[]=" ’ҐЄбв®ўл© Ўа 㧥а 0.99.3";
|
||||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
?define IMAGES_CACHE_CLEARED "Љни Є авЁ®Є ®зЁйҐ"
|
||||||
#else
|
#else
|
||||||
char version[]=" Text-based Browser 0.99.11";
|
char version[]=" Text-based Browser 0.99.3";
|
||||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -69,8 +70,8 @@ void main()
|
|||||||
|
|
||||||
mem_Init();
|
mem_Init();
|
||||||
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
||||||
if (load_dll2(libio, #libio_init,1)!=0) debug("Error: library doesn't exists - libio"w);
|
if (load_dll2(libio, #libio_init,1)!=0) debug("Error: library doesn't exists - libio");
|
||||||
if (load_dll2(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg"w);
|
if (load_dll2(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg");
|
||||||
|
|
||||||
if (!URL) strcpy(#URL, "/sys/index.htm");
|
if (!URL) strcpy(#URL, "/sys/index.htm");
|
||||||
strcpy(#editURL, #URL);
|
strcpy(#editURL, #URL);
|
||||||
@ -90,9 +91,9 @@ void main()
|
|||||||
/*
|
/*
|
||||||
//not work well, so we are use custom way of processing scroll
|
//not work well, so we are use custom way of processing scroll
|
||||||
scrollbar_v_mouse (#scroll1);
|
scrollbar_v_mouse (#scroll1);
|
||||||
if (lines.first <> scroll1.position)
|
if (WB1.list.first <> scroll1.position)
|
||||||
{
|
{
|
||||||
lines.first = scroll1.position;
|
WB1.list.first = scroll1.position;
|
||||||
WB1.ParseHTML(buf, filesize);
|
WB1.ParseHTML(buf, filesize);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
@ -118,40 +119,27 @@ void main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.vert==65535)
|
if (m.vert)
|
||||||
{
|
{
|
||||||
if (lines.first==0) break;
|
if (WB1.list.MouseScroll(m.vert)) WB1.ParseHTML(buf);
|
||||||
if (lines.first>3) lines.first-=2; ELSE lines.first=1;
|
|
||||||
Scan(ID1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (m.vert==1)
|
|
||||||
{
|
|
||||||
if(lines.visible+lines.first+3>=lines.all) Scan(181);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lines.first+=2;
|
|
||||||
Scan(ID2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m.lkm) scroll_used=0;
|
if (!m.lkm) scroll_used=0;
|
||||||
if (m.x>=scroll1.start_x) && (m.x<=scroll1.start_x+scroll1.size_x)
|
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)
|
&& (m.y>=scroll1.start_y+scroll1.btn_height) && (-scroll1.btn_height+scroll1.start_y+scroll1.size_y>m.y)
|
||||||
&& (lines.all>lines.visible) && (m.lkm)
|
&& (WB1.list.count>WB1.list.visible) && (m.lkm)
|
||||||
{
|
{
|
||||||
scroll_used=1;
|
scroll_used=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scroll_used)
|
if (scroll_used)
|
||||||
{
|
{
|
||||||
half_scroll_size = WB1.list.h - 16 * lines.visible / lines.all - 3 /2;
|
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; //åñëè êóðñîð íàä îêíîì
|
if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y; //åñëè êóðñîð íàä îêíîì
|
||||||
btn=lines.first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
|
btn=WB1.list.first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
|
||||||
lines.first = m.y -half_scroll_size -WB1.list.y * lines.all / WB1.list.h;
|
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
|
||||||
if (lines.visible+lines.first>lines.all) lines.first=lines.all-lines.visible;
|
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||||
if (btn<>lines.first) WB1.ParseHTML(buf); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
|
if (btn<>WB1.list.first) WB1.ParseHTML(buf); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -170,13 +158,13 @@ void main()
|
|||||||
case evKey:
|
case evKey:
|
||||||
key = GetKey();
|
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; }
|
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
|
||||||
|
|
||||||
Scan(key);
|
Scan(key);
|
||||||
|
|
||||||
_EDIT_MARK:
|
_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;
|
break;
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
if (action_buf) { Scan(action_buf); action_buf=0;}
|
if (action_buf) { Scan(action_buf); action_buf=0;}
|
||||||
@ -187,7 +175,7 @@ void main()
|
|||||||
{
|
{
|
||||||
if (GetProcessSlot(downloader_id)<>0) break;
|
if (GetProcessSlot(downloader_id)<>0) break;
|
||||||
downloader_id=0;
|
downloader_id=0;
|
||||||
lines.first = lines.all = 0;
|
WB1.list.first = WB1.list.count = 0;
|
||||||
WB1.ReadHtml(_WIN);
|
WB1.ReadHtml(_WIN);
|
||||||
Draw_Window();
|
Draw_Window();
|
||||||
}
|
}
|
||||||
@ -199,8 +187,8 @@ void SetElementSizes()
|
|||||||
{
|
{
|
||||||
address_box.width = Form.width-266;
|
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 - scroll1.size_x, Form.cheight - 44, 0, 10);
|
||||||
lines.column_max = WB1.list.w - 30 / 6;
|
WB1.list.column_max = WB1.list.w - 30 / 6;
|
||||||
lines.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
|
WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
|
||||||
DrawBufInit();
|
DrawBufInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,14 +223,130 @@ void Draw_Window()
|
|||||||
SetElementSizes();
|
SetElementSizes();
|
||||||
WB1.ShowPage();
|
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+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
|
||||||
DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, ID2+BT_HIDE, 0xE4DFE1);
|
DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Scan(int id)
|
void Scan(int id)
|
||||||
{
|
{
|
||||||
if (id >= 400)
|
if (id >= 400) ProcessLinks(id);
|
||||||
|
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case 011: //Ctrk+K
|
||||||
|
WB1.ReadHtml(_KOI);
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 021: //Ctrl+U
|
||||||
|
WB1.ReadHtml(_UTF);
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 004: //Ctrl+D
|
||||||
|
WB1.ReadHtml(_DOS);
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 002: //free img cache
|
||||||
|
FreeImgCache();
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case BACK:
|
||||||
|
if (!BrowserHistory.GoBack()) return;
|
||||||
|
WB1.OpenPage();
|
||||||
|
return;
|
||||||
|
case FORWARD:
|
||||||
|
if (!BrowserHistory.GoForward()) return;
|
||||||
|
WB1.OpenPage();
|
||||||
|
return;
|
||||||
|
case 052: //F3
|
||||||
|
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL);
|
||||||
|
else RunProgram("/rd/1/tinypad", #download_path);
|
||||||
|
return;
|
||||||
|
case 054: //F5
|
||||||
|
IF(address_box.flags & 0b10) WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case REFRESH:
|
||||||
|
if (GetProcessSlot(downloader_id)<>0)
|
||||||
|
{
|
||||||
|
KillProcess(downloader_id);
|
||||||
|
pause(20);
|
||||||
|
Draw_Window();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
anchor_line_num=WB1.list.first;
|
||||||
|
anchor[0]='|';
|
||||||
|
WB1.OpenPage();
|
||||||
|
return;
|
||||||
|
case 014:
|
||||||
|
case 020:
|
||||||
|
case NEWTAB:
|
||||||
|
MoveSize(190,80,OLD,OLD);
|
||||||
|
RunProgram(#program_path, #URL);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case HOME:
|
||||||
|
strcpy(#editURL, "http://kolibrios.org/en/index.htm");
|
||||||
|
case GOTOURL:
|
||||||
|
case 0x0D: //enter
|
||||||
|
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
|
||||||
|
strcat(#URL, #editURL);
|
||||||
|
WB1.OpenPage();
|
||||||
|
return;
|
||||||
|
case SEARCHWEB:
|
||||||
|
strcpy(#URL, #search_path);
|
||||||
|
strcat(#URL, #editURL);
|
||||||
|
WB1.OpenPage();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 183: //PgDown
|
||||||
|
if (WB1.list.count < WB1.list.visible) return;
|
||||||
|
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
|
||||||
|
WB1.list.first += WB1.list.visible + 2;
|
||||||
|
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 184: //PgUp
|
||||||
|
if (WB1.list.count < WB1.list.visible) return;
|
||||||
|
IF(WB1.list.first == 0) return;
|
||||||
|
WB1.list.first -= WB1.list.visible - 2;
|
||||||
|
IF(WB1.list.first < 0) WB1.list.first = 0;
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 178:
|
||||||
|
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;
|
||||||
|
WB1.list.first++;
|
||||||
|
WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 180: //home
|
||||||
|
if (WB1.list.KeyHome()) WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 181: //end
|
||||||
|
if (WB1.list.count < WB1.list.visible) return;
|
||||||
|
if (WB1.list.KeyEnd()) WB1.ParseHTML(buf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ProcessLinks(int id)
|
||||||
{
|
{
|
||||||
GetURLfromPageLinks(id);
|
GetURLfromPageLinks(id);
|
||||||
|
|
||||||
@ -253,7 +357,7 @@ void Scan(int id)
|
|||||||
|
|
||||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||||
|
|
||||||
lines.first=lines.all-lines.visible;
|
WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||||
WB1.ShowPage();
|
WB1.ShowPage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -261,7 +365,7 @@ void Scan(int id)
|
|||||||
if (strrchr(#URL, '#')<>-1)
|
if (strrchr(#URL, '#')<>-1)
|
||||||
{
|
{
|
||||||
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
||||||
URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
|
URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
|
||||||
}
|
}
|
||||||
|
|
||||||
WB1.GetNewUrl();
|
WB1.GetNewUrl();
|
||||||
@ -276,7 +380,7 @@ void Scan(int id)
|
|||||||
}
|
}
|
||||||
if (!strcmpn(#URL,"mailto:", 7))
|
if (!strcmpn(#URL,"mailto:", 7))
|
||||||
{
|
{
|
||||||
RunProgram("@notify", #URL);
|
notify(#URL);
|
||||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
||||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||||
return;
|
return;
|
||||||
@ -286,102 +390,6 @@ void Scan(int id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
|
|
||||||
{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
|
|
||||||
|
|
||||||
switch (id)
|
|
||||||
{
|
|
||||||
case 011: //Ctrk+K
|
|
||||||
WB1.ReadHtml(_KOI);
|
|
||||||
break;
|
|
||||||
case 021: //Ctrl+U
|
|
||||||
WB1.ReadHtml(_UTF);
|
|
||||||
break;
|
|
||||||
case 004: //Ctrl+D
|
|
||||||
WB1.ReadHtml(_DOS);
|
|
||||||
break;
|
|
||||||
case 002: //free img cache
|
|
||||||
FreeImgCache();
|
|
||||||
break;
|
|
||||||
case BACK:
|
|
||||||
if (!BrowserHistory.GoBack()) return;
|
|
||||||
WB1.OpenPage();
|
|
||||||
return;
|
|
||||||
case FORWARD:
|
|
||||||
if (!BrowserHistory.GoForward()) return;
|
|
||||||
WB1.OpenPage();
|
|
||||||
return;
|
|
||||||
case 052: //F3
|
|
||||||
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
|
|
||||||
return;
|
|
||||||
case 054: //F5
|
|
||||||
IF(address_box.flags & 0b10) break;
|
|
||||||
case REFRESH:
|
|
||||||
if (GetProcessSlot(downloader_id)<>0)
|
|
||||||
{
|
|
||||||
KillProcess(downloader_id);
|
|
||||||
pause(20);
|
|
||||||
Draw_Window();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
|
|
||||||
anchor[0]='|';
|
|
||||||
WB1.OpenPage();
|
|
||||||
return;
|
|
||||||
case 014: //Ctrl+N íîâîå îêíî
|
|
||||||
case 020: //Ctrl+T íîâàÿ âêëàäêà
|
|
||||||
case NEWTAB:
|
|
||||||
MoveSize(190,80,OLD,OLD);
|
|
||||||
RunProgram(#program_path, #URL);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case HOME:
|
|
||||||
strcpy(#editURL, "http://kolibrios.org/en/index.htm");
|
|
||||||
case GOTOURL:
|
|
||||||
case 0x0D: //enter
|
|
||||||
//ïî÷åìó ttp://? Ãîñïîäà, îòëè÷íûé âîïðîñ. Äåëî â òîì, ÷òî ýòî õàê.
|
|
||||||
//strstr() åñëè íå íàøëî âîçâðàùàåò 0 è â ñëó÷àå óñïåõà âîçâðàùàåò 0. Òàê ÷òî ýòî õàê.
|
|
||||||
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
|
|
||||||
strcat(#URL, #editURL);
|
|
||||||
WB1.OpenPage();
|
|
||||||
return;
|
|
||||||
case SEARCHWEB:
|
|
||||||
strcpy(#URL, #search_path);
|
|
||||||
strcat(#URL, #editURL);
|
|
||||||
WB1.OpenPage();
|
|
||||||
return;
|
|
||||||
|
|
||||||
case ID1: //ìîòàåì ââåðõ
|
|
||||||
IF(lines.first <= 0) return;
|
|
||||||
lines.first--;
|
|
||||||
break;
|
|
||||||
case ID2: //ìîòàåì âíèç
|
|
||||||
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;
|
|
||||||
break;
|
|
||||||
case 184: //PgUp
|
|
||||||
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;
|
|
||||||
break;
|
|
||||||
case 181: //end
|
|
||||||
IF (lines.first == lines.all - lines.visible) return;
|
|
||||||
lines.first = lines.all - lines.visible;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WB1.ParseHTML(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
struct llist
|
struct llist
|
||||||
{
|
{
|
||||||
int x, y, w, h, min_h, line_h, text_y;
|
int x, y, w, h, min_h, line_h, text_y;
|
||||||
|
int column_max;
|
||||||
int count, visible, first, current;
|
int count, visible, first, current;
|
||||||
int active;
|
int active;
|
||||||
void ClearList();
|
void ClearList();
|
||||||
|
Loading…
Reference in New Issue
Block a user