HTMLv 0.81: improvements for fb2-files (books)

git-svn-id: svn://kolibrios.org@2660 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-05-12 23:11:58 +00:00
parent 79b35ed28f
commit b24027dc11
4 changed files with 167 additions and 114 deletions

View File

@ -3,6 +3,7 @@
//Asper, Lrz, Nable, lev.
#include "..\lib\kolibri.h--"
#include "..\lib\encoding.h--"
#include "..\lib\file_system.h--"
#include "img\toolbar_icons.c"
#include "img\URLgoto.txt";

View File

@ -15,7 +15,7 @@ dword j,
char download_path[]="/rd/1/.download";
//char search_path[]="http://nova.rambler.ru/search?words=";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.80";
char version[]=" Text-based Browser 0.81";
struct TWebBrowser {
@ -38,7 +38,7 @@ byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ign
dword text_colors[10],
text_color_index,
link_color,
bg_color=0xFFFFFF;
bg_color;
int stroka,
stolbec,
@ -106,6 +106,10 @@ void TWebBrowser::Scan(dword id) {
ReadHtml();
koitodos(buf);
break;
case 021: //Ctrl+U
ReadHtml();
utf8rutodos(buf);
break;
case BACK:
BrowserHistory.GoBack();
@ -310,7 +314,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà
}
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
for (; buf + fsize > bword; bword++;) {
for (bword = buf; buf + fsize > bword; bword++;) {
bukva = ESBYTE[bword];
switch (bukva) {
case 0x0a:
@ -503,7 +507,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
return;
}
IF(!chTag("script")) || (!chTag("style")) ignor_text = rez;
IF(!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez;
if(!chTag("title")) && (!rez)
{
@ -633,7 +637,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
return;
}
////////////////////////////
IF(!chTag("i")) || (!chTag("em")) {
IF(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
i_text = rez;
return;
}

View File

@ -0,0 +1,157 @@
void wintodos(dword ESI)
{
while (BL=ESBYTE[ESI])
{
IF (BL>=192)
{
IF (BL>=240) ESBYTE[ESI] = BL - 16;
ELSE ESBYTE[ESI] = BL - 64;
}
ELSE
{
IF (BL==178) ESBYTE[ESI] = 73; //I
IF (BL==179) ESBYTE[ESI] = 105; //i
IF (BL==175) ESBYTE[ESI] = 244; //J
IF (BL==191) ESBYTE[ESI] = 245; //j
IF (BL==170) ESBYTE[ESI] = 242; //E
IF (BL==186) ESBYTE[ESI] = 243; //e
IF (BL==168) ESBYTE[ESI] = 240; //ð
IF (BL==184) ESBYTE[ESI] = 'e'; //e
IF (BL==180) ESBYTE[ESI] = 254; //ã
IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
}
ESI++;
}
}
byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ<C5BE>„…”ƒ•ˆ‰ŠŒ<E280B9>Ž<EFBFBD>Ÿ<EFBFBD>“†œ˜<E280A1>™—š";
void koitodos(dword EDI)
{
WHILE (BL=ESBYTE[EDI])
{
IF (BL >= 0xC0)
{
BL -= 0xC0;
ESBYTE[EDI] = mas[BL];
}
//IF (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
EDI++;
}
}
//Asper, lev
//uncomplete
int utf8rutodos(dword ESI) //-
{
EDI=ESI;
while (BL=ESBYTE[ESI])
{
IF (BL == 0xD0) || (BL == 0xD1) EDI--;
else IF (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //ø
else IF (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //ì
//0xE2 0x80 - ñãðóïïèðîâàòü
else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80)
SWITCH (ESBYTE[ESI+2])
{
case 0x93: //long defis
CASE 0x94:
{
ESBYTE[EDI] = '-';
ESI+=2;
BREAK;
}
CASE 0xA2: //central point
{
ESBYTE[EDI] = '*';
ESI+=2;
BREAK;
}
CASE 0xA6: //ìíîãîòî÷èå
{
ESBYTE[EDI] = ESBYTE[EDI+1] = ESBYTE[EDI+2] = '.';
EDI+=2;
ESI+=2;
break;
}
}
//0xC2 ñãðóïïèðîâàòü
else IF (BL == 0xC2) //òàáëèöó ïåðåêîäèðîâîê?
SWITCH(ESBYTE[ESI+1]) {
case 0xAB: //"
CASE 0xBB: //"
{
ESBYTE[EDI] = '\"';
ESI++;
BREAK;
}
CASE 0xB7: // _
{
ESBYTE[EDI] = '_';
ESI++;
BREAK;
}
CASE 0xA0: // Alt+160 - íåðàçáèâàþùèé ïðîáåë
{
ESBYTE[EDI] = ' ';
ESI++;
BREAK;
}
CASE 0xB0: // ãðàäóñ
{
ESBYTE[EDI] = '\29';
ESI++;
BREAK;
}
CASE 0xA9: // (c)
{
ESWORD[EDI] = 'c(';
// ESBYTE[EDI] = '(';
// ESBYTE[EDI+1] = 'c';
ESBYTE[EDI+2] = ')';
EDI+=2;
ESI++;
BREAK;
}
CASE 0xAE: // (r)
{
ESWORD[EDI] = 'r(';
ESBYTE[EDI+2] = ')';
EDI+=2;
ESI++;
break;
}
}
ELSE IF (BL >= 0x90) && (BL <= 0xAF)
{
BL -= 0x10;
ESBYTE[EDI] = BL;
}
ELSE IF (BL >= 0x80) && (BL <= 0x8F)
{
BL += 0x60;
ESBYTE[EDI] = BL;
}
ELSE IF (BL >= 0xB0) && (BL <= 0xBF)
{
BL -= 0x10;
ESBYTE[EDI] = BL;
}
ELSE ESBYTE[EDI] = BL;
ESI++;
EDI++;
}
WHILE (EDI<ESI)
{
ESBYTE[EDI] = ' ';
EDI++;
}
}
//------------------------------------------------------------------------------

View File

@ -353,34 +353,6 @@ inline fastcall lowcase(ESI)
}
inline fastcall wintodos (dword ESI)
{
while (BL=ESBYTE[ESI])
{
IF (BL>=192)
{
IF (BL>=240) ESBYTE[ESI] = BL - 16;
ELSE ESBYTE[ESI] = BL - 64;
}
ELSE
{
IF (BL==178) ESBYTE[ESI] = 73; //I
IF (BL==179) ESBYTE[ESI] = 105; //i
IF (BL==175) ESBYTE[ESI] = 244; //J
IF (BL==191) ESBYTE[ESI] = 245; //j
IF (BL==170) ESBYTE[ESI] = 242; //E
IF (BL==186) ESBYTE[ESI] = 243; //e
IF (BL==168) ESBYTE[ESI] = 240; //ð
IF (BL==184) ESBYTE[ESI] = 'e'; //e
IF (BL==180) ESBYTE[ESI] = 254; //ã
IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
}
ESI++;
}
}
dword Hex2Symb(char* htmlcolor)
{
dword j=0, symbol=0;
@ -414,87 +386,6 @@ int hex2char(dword c)
return (c - 10 + 'a');
}*/
byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ<C5BE>„…”ƒ•ˆ‰ŠŒ<E280B9>Ž<EFBFBD>Ÿ<EFBFBD>“†œ˜<E280A1>™—š";
inline fastcall void koitodos(dword EDI)
{
WHILE (BL=ESBYTE[EDI])
{
IF (BL >= 0xC0)
{
BL -= 0xC0;
ESBYTE[EDI] = mas[BL];
}
//IF (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
EDI++;
}
}
//Asper
//uncomplete
inline fastcall int utf8rutodos(dword ESI) //-
{
EDI=ESI;
while (BL=ESBYTE[ESI])
{
IF (BL == 0xD0) || (BL == 0xD1) EDI--;
else IF (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //è
else IF (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //¬
else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0x94) //long defis
{
ESBYTE[EDI] = '-';
ESI+=2;
}
else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0xA2) //central point
{
ESBYTE[EDI] = '*';
ESI+=2;
}
else IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xA9) // (c)
{
ESBYTE[EDI] = '(';
ESBYTE[EDI+1] = 'c';
ESBYTE[EDI+2] = ')';
EDI+=2;
ESI++;
}
ELSE IF (BL == 0xC2) && ((ESBYTE[ESI+1]==0xAB) || (ESBYTE[ESI+1]==0xBB)) // "
{
ESBYTE[EDI] = '\"';
ESI++;
}
ELSE IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xB7) // _
{
ESBYTE[EDI] = '_';
ESI++;
}
ELSE IF (BL >= 0x90) && (BL <= 0xAF)
{
BL -= 0x10;
ESBYTE[EDI] = BL;
}
ELSE IF (BL >= 0x80) && (BL <= 0x8F)
{
BL += 0x60;
ESBYTE[EDI] = BL;
}
ELSE IF (BL >= 0xB0) && (BL <= 0xBF)
{
BL -= 0x10;
ESBYTE[EDI] = BL;
}
ELSE ESBYTE[EDI] = BL;
ESI++;
EDI++;
}
WHILE (EDI<ESI)
{
ESBYTE[EDI] = ' ';
EDI++;
}
}
//------------------------------------------------------------------------------
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)