diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index bc6e8035e6..121c22eec7 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -26,8 +26,6 @@ byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, link, ignor_text, cur_encoding, text_align, t_html, t_body; byte condition_text_active, condition_text_val, condition_href, condition_max; -enum { _WIN, _DOS, _KOI, _UTF, _DEFAULT }; - enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; dword text_colors[300]; @@ -100,24 +98,6 @@ void TWebBrowser::DrawPage() //======================================================================= -void BufEncode(int set_new_encoding) -{ - int bufpointer_realsize; - cur_encoding = set_new_encoding; - if (o_bufpointer==0) - { - o_bufpointer = malloc(bufsize); - strcpy(o_bufpointer, bufpointer); - } - else - { - strcpy(bufpointer, o_bufpointer); - } - if (set_new_encoding==_WIN) bufpointer = ChangeCharset("CP1251", "CP866", bufpointer); - if (set_new_encoding==_UTF) bufpointer = ChangeCharset("UTF-8", "CP866", bufpointer); - if (set_new_encoding==_KOI) bufpointer = ChangeCharset("KOI8-RU", "CP866", bufpointer); -} - void TWebBrowser::Prepare(dword bufpos, in_filesize){ bufsize = in_filesize; bufpointer = bufpos; @@ -155,7 +135,6 @@ void TWebBrowser::Parse(){ { pre_text=0; if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; - if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; } for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;) @@ -183,18 +162,6 @@ void TWebBrowser::Parse(){ break; } goto DEFAULT_MARK; - case '=': //quoted printable - if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; - - temp[0] = ESBYTE[bufpos+1]; - temp[1] = ESBYTE[bufpos+2]; - temp[2] = '\0'; - if (bukva = Hex2Symb(#temp)) - { - bufpos+=2; - goto DEFAULT_MARK; - } - break; case '&': //  and so on bufpos++; @@ -313,7 +280,6 @@ void TWebBrowser::SetTextStyle(int left1, top1) { if (isTag("html")) { - IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0; t_html = opened; return; } @@ -362,10 +328,10 @@ void TWebBrowser::SetTextStyle(int left1, top1) { DrawBuf.Fill(bg_color); } } while(GetNextParam()); - if (opened) && (cur_encoding==_DEFAULT) + if (opened) && (cur_encoding==CH_NULL) { debugln("Document has no information about encoding, UTF will be used"); - BufEncode(_UTF); + //BufEncode(CH_UTF8); } return; } @@ -594,12 +560,14 @@ void TWebBrowser::SetTextStyle(int left1, top1) { { strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content= strlwr(#options); - meta_encoding = _DEFAULT; - if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) meta_encoding = _UTF; - if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI; - if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN; - if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = _DOS; - if (cur_encoding==_DEFAULT) BufEncode(meta_encoding); + meta_encoding = CH_NULL; + if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) meta_encoding = CH_UTF8; + else if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = CH_KOI8; + else if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = CH_CP1251; + else if (!strcmp(#options, "windows-1252")) || (!strcmp(#options, "windows1252")) meta_encoding = CH_CP1252; + else if (!strcmp(#options, "iso-8859-5")) || (!strcmp(#options, "iso8859-5")) meta_encoding = CH_ISO8859_5; + else if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = CH_CP866; + if (cur_encoding==CH_NULL) BufEncode(meta_encoding); return; } } while(GetNextParam()); @@ -607,6 +575,24 @@ void TWebBrowser::SetTextStyle(int left1, top1) { } } +void BufEncode(int set_new_encoding) +{ + int bufpointer_realsize; + cur_encoding = set_new_encoding; + if (o_bufpointer==0) + { + o_bufpointer = malloc(bufsize); + strcpy(o_bufpointer, bufpointer); + } + else + { + strcpy(bufpointer, o_bufpointer); + } + debugln(charsets[set_new_encoding]); + bufpointer = ChangeCharset(charsets[set_new_encoding], "CP866", bufpointer); +} + + void TWebBrowser::DrawScroller() { scroll_wv.max_area = list.count; @@ -652,20 +638,3 @@ int isTag(dword text) if (!strcmp(#tag,text)) return 1; else return 0; } - -:dword Hex2Symb(char* htmlcolor) -{ - dword j=0, symbol=0; - char ch=0x00; - for (;j<2;j++) - { - ch=ESBYTE[htmlcolor+j]; - if (ch==0x0d) || (ch=='\9') RETURN 0; - if ((ch>='0') && (ch<='9')) ch -= '0'; - if ((ch>='A') && (ch<='F')) ch -= 'A'-10; - if ((ch>='a') && (ch<='f')) ch -= 'a'-10; - symbol = symbol*0x10 + ch; - } - AL=symbol; -} - diff --git a/programs/cmm/TWB/acid_0.1.htm b/programs/cmm/TWB/acid_0.1.htm index d6924df17c..0cb817d8e0 100644 --- a/programs/cmm/TWB/acid_0.1.htm +++ b/programs/cmm/TWB/acid_0.1.htm @@ -5,9 +5,9 @@ Тест Acid 0.1 -

Это тестовая страница для проверки HTML Viewer

+

Это тестовая страница для проверки WebViewer


-

HTMLv является текстовым браузером и поддерживает все популярные кодировки (cp1251, koi-8, cp866, unicode) +

WebViewer является текстовым браузером и поддерживает все популярные кодировки (cp1251, koi-8, cp866, unicode) и некоторые теги. Поддержка таблииц (<table>), CSS, Javascript'a и Контактика пока не реализована :)


@@ -55,7 +55,7 @@
-logo
Открыть

+logo
Открыть



diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 318ac9fd93..60770802db 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -333,12 +333,6 @@ void Draw_Window() } -void ChangeCharset1(byte new_charset) -{ - BufEncode(new_charset); - WB1.Parse(); -} - void Scan(int id) { action_buf=0; @@ -350,39 +344,36 @@ void Scan(int id) switch (id) { case 011: //Ctrk+K - ChangeCharset1(_KOI); + BufEncode(CH_KOI8); + WB1.Parse(); return; - case 021: //Ctrl+U - ChangeCharset1(_UTF); + BufEncode(CH_UTF8); + WB1.Parse(); return; - case 004: //Ctrl+D - ChangeCharset1(_DOS); + BufEncode(CH_CP866); + WB1.Parse(); return; - case 005: //Win encoding - ChangeCharset1(_WIN); + BufEncode(CH_CP1251); + WB1.Parse(); return; - case 009: //free img cache ImgCache.Free(); notify(IMAGES_CACHE_CLEARED); WB1.Parse(); return; - case 003: //history strcpy(#URL, URL_SERVICE_HISTORY); OpenPage(); return; - case 006: //download manager if (!downloader_opened) { strncpy(#DL_URL, "http://",7); CreateThread(#Downloader,#downloader_stak+4092); } return; - case ASCII_KEY_BS: case BACK: if (!BrowserHistory.GoBack()) return; @@ -576,7 +567,7 @@ void SetPageDefaults() pre_text = 0; WB1.list.count = WB1.list.first = 0; stroka = 0; - cur_encoding = _DEFAULT; + cur_encoding = CH_NULL; if (o_bufpointer) o_bufpointer = free(o_bufpointer); anchor_line_num=WB1.list.first; anchor[0]='|'; diff --git a/programs/cmm/browser/menu_rmb.h b/programs/cmm/browser/menu_rmb.h index 0e858d91a9..c1dcf625c4 100644 --- a/programs/cmm/browser/menu_rmb.h +++ b/programs/cmm/browser/menu_rmb.h @@ -80,10 +80,10 @@ void DrawMenuList() } WriteText(18,N*menu.line_h+8,0x80,0x000000,ITEMS_LIST[N*2]); } - if (cur_encoding!=_DEFAULT) + if (cur_encoding!=CH_NULL) WriteText(5, cur_encoding*menu.line_h+7, 0x80, 0x777777, "\x10"); //show current encoding else - WriteText(5, _DOS*menu.line_h+7, 0x80, 0x777777, "\x10"); //show current encoding + WriteText(5, CH_CP866*menu.line_h+7, 0x80, 0x777777, "\x10"); //show current encoding if (WB1.DrawBuf.zoom == 2) DrawBar(6, 4*menu.line_h+8, 6, 6, 0x777777); } diff --git a/programs/cmm/lib/obj/iconv.h b/programs/cmm/lib/obj/iconv.h index f107e4fd8f..b13c1184f5 100644 --- a/programs/cmm/lib/obj/iconv.h +++ b/programs/cmm/lib/obj/iconv.h @@ -57,16 +57,8 @@ dword ChangeCharset(dword from_chs, to_chs, conv_buf) } -:char *charsets[] = { " ", "UTF-8", "KOI8-RU", "CP1251", "CP1252", "ISO8859-5", "CP866"}; :int cur_charset; -enum { - CH_NULL, - CH_UTF8, - CH_KOI8, - CH_CP1251, - CH_CP1252, - CH_ISO8859_5, - CH_CP866 -}; +:char *charsets[] = { " ", "UTF-8", "KOI8-RU", "CP1251", "CP1252", "ISO8859-5", "CP866" }; +enum { CH_NULL, CH_UTF8, CH_KOI8, CH_CP1251, CH_CP1252, CH_ISO8859_5, CH_CP866 }; #endif \ No newline at end of file