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 |