/programs/cmm/TWB/TWB.c |
---|
4,12 → 4,14 |
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
struct _style { |
byte |
bool |
b, u, s, h, |
pre, |
blq, |
li, |
li_tab, |
button, |
image, |
align; |
}; |
30,7 → 32,7 |
} WB1; |
byte |
bool |
link, |
ignor_text, |
cur_encoding, |
91,6 → 93,14 |
stolbec_len = strlen(#line) * zoom; |
line_length = stolbec_len * list.font_w; |
if (style.image) { |
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xF9DBCB); |
} |
if (style.button) { |
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
} |
DrawBuf.WriteText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line); |
if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
239,7 → 249,10 |
char new_line_text[4096]; |
if (strlen(#line)*zoom + stolbec < list.column_max) return; |
perenos_num = strrchr(#line, ' '); |
if (!perenos_num) && (strlen(#line)*zoom>list.column_max) perenos_num=list.column_max/zoom; |
if (!perenos_num) && (strlen(#line)*zoom>list.column_max) { |
perenos_num=list.column_max/zoom; |
if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt |
} |
strcpy(#new_line_text, #line + perenos_num); |
line[perenos_num] = 0x00; |
DrawStyle(); |
248,9 → 261,10 |
} |
//============================================================================================ |
void TWebBrowser::SetStyle() { |
char img_path[4096]; |
int left1 = body_magrin + list.x; |
byte opened; |
byte meta_encoding; |
bool opened; |
int meta_encoding; |
if (tag[0] == '/') |
{ |
opened = 0; |
291,8 → 305,9 |
} |
} while(GetNextParam()); |
if (opened) && (cur_encoding==CH_NULL) { |
cur_encoding = CH_UTF8; |
debugln("Document has no information about encoding, UTF will be used"); |
cur_encoding = CH_CP866; |
//BufEncode(CH_UTF8); |
debugln("Document has no information about encoding!"); |
} |
if (opened) { |
if (strcmp(#header, #version) != 0) { |
349,12 → 364,33 |
if (istag("br")) { NewLine(); return; } |
if (istag("tr")) { if (opened) NewLine(); return; } |
if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
if (istag("button")) { style.button = opened; stolbec++; return; } |
if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
if (istag("dd")) { stolbec += 5; return; } |
if (istag("blockquote")) { style.blq = opened; return; } |
if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
if (istag("img")) { ImgCache.Images( left1, draw_y, WB1.list.w); return; } |
if (istag("img")) { |
do{ |
if (isattr("src=")) strcpy(#img_path, #val); |
if (isattr("alt=")) sprintf(#line, "[%s]", #val); |
} while(GetNextParam()); |
style.image = true; |
text_color_index++; |
text_colors[text_color_index] = 0x9A6F29; |
if (!line) { |
if (!strncmp(#img_path, "data:", 5)) img_path=0; |
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
line[50]= NULL; |
} |
if (strlen(#line) + stolbec > list.column_max) Perenos(); |
DrawStyle(); |
line=0; |
text_color_index--; |
style.image = false; |
//ImgCache.Images( left1, draw_y, WB1.list.w); |
return; |
} |
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) { |
style.h = opened; |
if (opened) |
366,9 → 402,11 |
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
list.item_h = basic_line_h * 2; |
if (istag("h1")) style.b = true; |
} |
else |
{ |
if (istag("h1")) style.b = false; |
NewLine(); |
WB1.zoom=1; |
WB1.list.font_type = 10011000b; |
388,7 → 426,8 |
if (opened) |
{ |
NewLine(); |
strcpy(#line, "\31 \0"); |
strcpy(#line, "\31 "); |
stolbec-=2; |
} |
return; |
} |
441,8 → 480,8 |
{ |
strcpy(bufpointer, o_bufpointer); |
} |
debugval("cur_encoding ", cur_encoding); |
debugval("set_new_encoding", set_new_encoding); |
//debugval("cur_encoding ", cur_encoding); |
//debugval("set_new_encoding", set_new_encoding); |
cur_encoding = set_new_encoding; |
bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); |
} |
462,9 → 501,17 |
void TWebBrowser::NewLine() |
{ |
dword onleft, ontop; |
static int empty_line=0; |
if (!stolbec) && (draw_y==body_magrin) return; |
if (!stolbec) { |
if (empty_line<1) empty_line++; |
else return; |
} else { |
empty_line=0; |
} |
onleft = list.x + body_magrin; |
ontop = draw_y + list.y; |
if (t_html) && (!t_body) return; |
/programs/cmm/TWB/absolute_url.h |
---|
12,7 → 12,7 |
if (check_is_the_url_absolute(in_URL)) return; |
IF (!strcmpn(in_URL,"//", 2)) |
IF (!strncmp(in_URL,"//", 2)) |
{ |
//strcpy(#newurl, "http:"); |
//strcat(#newurl, in_URL); |
21,7 → 21,7 |
return; |
} |
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2; |
IF (!strncmp(in_URL,"./", 2)) in_URL+=2; |
if (!http.transfer) |
{ |
strcpy(#newurl, history.current()); |
/programs/cmm/TWB/img_cache.h |
---|
37,28 → 37,13 |
void ImageCache::Images(dword left1, top1, width1) |
{ |
dword image; |
char img_path[4096], alt[4096]=0; |
dword imgw=0, imgh=0, img_lines_first=0, cur_pic=0; |
do{ |
if (isattr("src=")) |
{ |
strcpy(#img_path, #val); |
GetAbsoluteURL(#img_path); |
cur_pic = GetImage(#img_path); |
} |
if (isattr("alt=")) |
{ |
strcpy(#alt, "["); |
strcat(#alt, #val); |
strcat(#alt, "]"); |
} |
//GetAbsoluteURL(#img_path); |
//cur_pic = GetImage(#img_path); |
} while(GetNextParam()); |
if (!pics[cur_pic].image) |
{ |
if (alt) strcat(#line, #alt); |
//cur_pic = GetImage("/sys/network/noimg.png"); |
return; |
} |
67,7 → 52,7 |
imgh = DSWORD[pics[cur_pic].image+8]; |
if (imgw > width1) imgw = width1; |
draw_y += imgh + 5; |
//draw_y += imgh + 5; TEMPORARY TURN OFF!!! |
if (top1+imgh<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //if all image is out of visible area |
if (top1<WB1.list.y) //if image partly visible (at the top) |
{ |
/programs/cmm/TWB/links.h |
---|
75,12 → 75,12 |
} |
if (mouse.mkm) && (mouse.up) { |
open_in_a_new_window = true; |
ClickLink(); |
EventClickLink(); |
return false; |
} |
if (mouse.lkm) && (mouse.up) { |
CursorPointer.Restore(); |
ClickLink(); |
EventClickLink(); |
return false; |
} |
if (mouse.pkm) && (mouse.up) { |
/programs/cmm/TWB/unicode_tags.h |
---|
33,6 → 33,7 |
"rsquo", "'", |
"#39", "'", |
"#039", "'", |
"#96", "'", |
"#8217", "'", |
/programs/cmm/browser/WebView.c |
---|
31,7 → 31,7 |
char homepage[] = FROM "html\\homepage.htm""\0"; |
#ifdef LANG_RUS |
char version[]="¥ªáâ®¢ë© ¡à 㧥à 1.83"; |
char version[]="¥ªáâ®¢ë© ¡à 㧥à 1.84"; |
?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
char loading[] = " £à㧪 áâà ¨æë...<br>"; |
46,7 → 46,7 |
"®¯¨à®¢ âì áá뫪ã |
ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
#else |
char version[]="Text-based Browser 1.83"; |
char version[]="Text-based Browser 1.84"; |
?define IMAGES_CACHE_CLEARED "Images cache cleared" |
?define T_LAST_SLIDE "This slide is the last" |
char loading[] = "Loading...<br>"; |
162,9 → 162,20 |
case evKey: |
GetKeys(); |
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY); |
if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE); |
if (key_scancode == SCAN_CODE_KEY_T) |
|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL); |
if (key_scancode == SCAN_CODE_KEY_W) ExitProcess(); |
if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER); |
} |
if (address_box.flags & ed_focus) |
{ |
if (key_ascii == ASCII_KEY_ENTER) ProcessEvent(key_scancode); else { |
if (key_scancode == SCAN_CODE_ENTER) { |
ProcessEvent(key_scancode); |
} |
else { |
EAX = key_editbox; |
edit_box_key stdcall(#address_box); |
} |
215,6 → 226,7 |
strcpy(#editURL, #URL); |
DrawEditBoxWebView(); |
OpenPage(); |
//ProcessLink(history.current()); |
} |
break; |
} |
297,20 → 309,7 |
return; |
case GOTOURL_BUTTON: |
case SCAN_CODE_ENTER: |
if (!editURL[0]) { |
strcpy(#URL, URL_SERVICE_HOME); |
} |
else if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) |
{ |
strcpy(#URL, #editURL); |
} |
else |
{ |
strlcpy(#URL,"http://",7); |
strcat(#URL, #editURL); |
} |
OpenPage(); |
EventSubmitOmnibox(); |
return; |
case REFRESH_BUTTON: |
if (http.transfer > 0) |
467,52 → 466,64 |
} |
} |
DrawEditBoxWebView() |
void ProcessAnchor() |
{ |
int skin_x_offset; |
DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
//address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
//address_box.offset = 0; |
EditBox_UpdateText(#address_box, address_box.flags); |
edit_box_draw stdcall(#address_box); |
if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51; |
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
} |
char anchor[256]; |
int anchor_pos; |
anchor_pos = strrchr(#URL, '#')-1; |
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)); |
URL[anchor_pos] = 0x00; |
void ShowPage() |
//#1 |
if (URL[0] == NULL) |
{ |
DrawEditBoxWebView(); |
if (!bufsize) |
{ |
if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
if (anchor[1] == NULL) { |
WB1.list.first = 0; |
} |
else { |
if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
} |
strcpy(#URL, history.current()); |
} |
//liner.ru#1 |
else |
{ |
WB1.Prepare(); |
GetAbsoluteURL(#URL); |
OpenPage(); |
if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
} |
WB1.DrawPage(); |
strcpy(#editURL, #URL); |
strcat(#editURL, #anchor); |
DrawEditBoxWebView(); |
} |
byte UrlExtIs(dword ext) |
void EventSubmitOmnibox() |
{ |
if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
return false; |
if (!editURL[0]) return; |
if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) |
{ |
strcpy(#URL, #editURL); |
} |
else |
{ |
strlcpy(#URL,"http://",7); |
strcat(#URL, #editURL); |
} |
ProcessLink(); |
} |
void DrawProgress() |
void EventClickLink() |
{ |
dword persent; |
if (http.transfer == 0) return; |
if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; |
DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color); |
strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
GetAbsoluteURL(#URL); |
ProcessLink(); |
} |
void ClickLink() |
char anchor[256]; |
int anchor_pos; |
void ProcessLink() |
{ |
if (http.transfer > 0) |
{ |
519,40 → 530,13 |
StopLoading(); |
history.back(); |
} |
strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
ReplaceSpaceInUrl(); |
//#1 |
if (URL[0] == '#') |
{ |
if (URL[1] == NULL) { |
WB1.list.first = 0; |
} |
else { |
if (anchors.get_anchor_pos(#URL+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#URL+1); |
} |
strlcpy(#anchor, #URL, sizeof(anchor)); |
strcpy(#URL, history.current()); |
strcpy(#editURL, #URL); |
strcat(#editURL, #anchor); |
DrawEditBoxWebView(); |
WB1.DrawPage(); |
if (strrchr(#URL, '#')!=0) { |
ProcessAnchor(); |
return; |
} |
//liner.ru#1 |
else if (strrchr(#URL, '#')!=0) |
{ |
anchor_pos = strrchr(#URL, '#')-1; |
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)); |
URL[anchor_pos] = 0x00; |
OpenPage(); |
strcat(#editURL, #anchor); |
DrawEditBoxWebView(); |
if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); |
WB1.DrawPage(); |
return; |
} |
if (!strncmp(#URL,"mailto:", 7)) |
if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4)) |
{ |
notify(#URL); |
strcpy(#editURL, history.current()); |
560,7 → 544,10 |
return; |
} |
GetAbsoluteURL(#URL); |
if (!strncmp(#URL,"WebView:",8)) { |
OpenPage(); |
return; |
} |
if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0) |
{ |
606,6 → 593,48 |
open_in_a_new_window = false; |
} |
void DrawEditBoxWebView() |
{ |
int skin_x_offset; |
DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
//address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
//address_box.offset = 0; |
EditBox_UpdateText(#address_box, address_box.flags); |
edit_box_draw stdcall(#address_box); |
if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51; |
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
} |
void ShowPage() |
{ |
DrawEditBoxWebView(); |
if (!bufsize) |
{ |
if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
} |
else |
{ |
WB1.Prepare(); |
} |
} |
byte UrlExtIs(dword ext) |
{ |
if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
return false; |
} |
void DrawProgress() |
{ |
dword persent; |
if (http.transfer == 0) return; |
if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; |
DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color); |
} |
void EventShowPageMenu(dword _left, _top) |
{ |
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); |
626,7 → 655,7 |
} |
} |
DrawStatusBar(dword _status_text) |
void DrawStatusBar(dword _status_text) |
{ |
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10; |
status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
/programs/cmm/browser/history.h |
---|
10,19 → 10,26 |
strcat(history_pointer, "<br><b>Visited pages</b><br>"); |
for (i=0; i<history.items.count; i++) |
{ |
strcat(history_pointer, " <a href='"); |
strcat(history_pointer, "<a href='"); |
strcat(history_pointer, history.items.get(i)); |
strcat(history_pointer, "'>"); |
strcat(history_pointer, history.items.get(i)); |
strcat(history_pointer, "</a><br>"); |
} |
strcat(history_pointer, "<br><b>Cached images</b>"); |
strcat(history_pointer, "<br><b>Cached images</b><br>"); |
for (i=1; i<ImgCache.pics_count; i++) |
{ |
strcat(history_pointer, "<a href='"); |
strcat(history_pointer, #pics[i].path); |
strcat(history_pointer, "'>"); |
strcat(history_pointer, #pics[i].path); |
strcat(history_pointer, "</a><br>"); |
/* |
strcat(history_pointer, "<img src='"); |
strcat(history_pointer, #pics[i].path); |
strcat(history_pointer, "'><br>"); |
strcat(history_pointer, #pics[i].path); |
*/ |
} |
strcat(history_pointer, "</body></html>"); |
WB1.LoadInternalPage(history_pointer, strlen(history_pointer)); |
/programs/cmm/codeview/codeview.c |
---|
242,7 → 242,7 |
} |
void DrawStatusBar() {return;}; |
void ClickLink() {return;}; |
void EventClickLink() {return;}; |
void EventShowLinkMenu() {return;}; |
char anchor[256]; |
/programs/cmm/lib/keyboard.h |
---|
75,6 → 75,7 |
#define SCAN_CODE_KEY_D 032 |
#define SCAN_CODE_KEY_E 018 |
#define SCAN_CODE_KEY_F 033 |
#define SCAN_CODE_KEY_J 036 |
#define SCAN_CODE_KEY_H 035 |
#define SCAN_CODE_KEY_I 023 |
#define SCAN_CODE_KEY_L 038 |
88,6 → 89,7 |
#define SCAN_CODE_KEY_T 020 |
#define SCAN_CODE_KEY_U 022 |
#define SCAN_CODE_KEY_V 047 |
#define SCAN_CODE_KEY_W 017 |
#define SCAN_CODE_KEY_X 045 |
#define SCAN_CODE_KEY_Y 021 |
#define SCAN_CODE_KEY_Z 044 |
/programs/cmm/lib/patterns/http_downloader.h |
---|
174,6 → 174,8 |
if(!strncmp(_in,"http:",5)) return true; |
if(!strncmp(_in,"https:",6)) return true; |
if(!strncmp(_in,"mailto:",7)) return true; |
if(!strncmp(_in,"tel:",4)) return true; |
if(!strncmp(_in,"#",1)) return true; |
if(check_is_the_adress_local(_in)) return true; |
return false; |
} |
/programs/cmm/lib/strings.h |
---|
936,9 → 936,4 |
ESBYTE[in_str+length]=0; |
} |
#define strnmov strmovn |
#define stricmp strcmpi |
#define strcmpn strncmp |
#endif |
/programs/cmm/liza/mail_box.c |
---|
416,6 → 416,6 |
} |
void ClickLink() { |
void EventClickLink() { |
RunProgram("/sys/network/WebView", PageLinks.GetURL(PageLinks.active)); |
} |
/programs/cmm/pixie2/pixie.c |
---|
76,8 → 76,8 |
int player_run_id; |
int notify_run_id; |
bool repeat; |
bool shuffle; |
bool repeat=false; |
bool shuffle=false; |
int current_playing_file_n=0; |