New config file token LatinToLocal

This commit is contained in:
Ianos Gnatiuc 2005-10-31 11:05:16 +00:00
parent f15607a27e
commit 4b3e5d0df1
12 changed files with 91 additions and 0 deletions

View File

@ -1423,6 +1423,11 @@ XLATEXPORT IBMPC
;XLATLOCALSET CP850
XLATLOCALSET IBMPC
// Used to translate latin A-Za-z to local charset if one of neighbours
// is from local charset too.
// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
;LatinToLocal ABCDEFG<46>IJKLMNOPQRSTUVWXYZabcdefghijklmnoàqrstuvwxãz ;cp866 - H,p,y
----------------------------------------------------------------------
-- MESSAGE ATTRIBUTE DEFAULTS

View File

@ -1669,6 +1669,13 @@ XlatCharSet CP850 ASCII 850_ASC.chs
;XlatLocalSet KOI8-R
XlatLocalSet CP866
// <20>â®â ª¥©¢®à¤ ¯®§¢®«ï¥â ¤¥« âì ®¡à â­ãî § ¬¥­ã « â¨­áª¨å ¡ãª¢ ­  àãá᪨¥.
// ‡ ¬¥­  ¡ã¤¥â ¤¥« âìáï ⮫쪮 â¥å « â¨­áª¨å ¡ãª¢, çâ® ¨¬¥îâ ¯® á®á¥¤áâ¢ã
// ¡ãª¢ë «®ª «ì­®© ª®¤¨à®¢ª¨.
// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
;LatinToLocal ABCDEFG<46>IJKLMNOPQRSTUVWXYZabcdefghijklmnoàqrstuvwxãz ;cp866 - H,p,y
----------------------------------------------------------------------
-- €<E282AC>ˆ<EFBFBD> ŽŽ<C5BD>™…<E284A2>ˆ

View File

@ -10,6 +10,10 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________
+ New config file token LatinToLocal.
Used to translate latin A-Za-z to local charset if one of neighbours
is from local charset too.
+ New config file token AreaRecycleBin <area>. GoldEd will move deleted
messages to <area>, if this token is defined.

View File

@ -739,6 +739,7 @@ CfgGed::CfgGed() {
internetrfcbody = 0;
internetviagate = false;
keybmode = KEYB_POLL;
latin2local = false;
logformat = 0;
locationdelimiter = " \x1A ";
menumarked = MODE_DONT;

View File

@ -240,6 +240,7 @@ const word CRC_KEYBMODE = 0xE8F2;
const word CRC_KEYBSTACK = 0x5F23;
const word CRC_KLUDGE = 0xA600;
const word CRC_KLUDGECHRS = 0x0EEF;
const word CRC_LATINTOLOCAL = 0x9397;
const word CRC_LOADLANGUAGE = 0x9F1B;
const word CRC_LOCATIONALIAS = 0x1B5F;
const word CRC_LOCATIONDELIMITER= 0x5083;

View File

@ -412,6 +412,7 @@ SwitchK:
SwitchL:
switch(crc) {
case CRC_LATINTOLOCAL : CfgLatintolocal (); break;
case CRC_LOADLANGUAGE : CfgLoadlanguage (); break;
case CRC_LOCATIONALIAS : CfgLocationalias (); break;
case CRC_LOCATIONDELIMITER: CfgLocationdelimiter(); break;

View File

@ -308,6 +308,20 @@ void CfgKludge() {
// ------------------------------------------------------------------
void CfgLatintolocal()
{
memset(CFG->latintolocal, 0, sizeof(CFG->latintolocal));
CFG->latin2local = true;
char *ptr = val, chr;
for (chr = 'A'; chr <= 'Z'; chr++, ptr++)
CFG->latintolocal[chr] = *ptr;
for (chr = 'a'; chr <= 'z'; chr++, ptr++)
CFG->latintolocal[chr] = *ptr;
}
// ------------------------------------------------------------------
void CfgLoadlanguage() {
Path buf;

View File

@ -229,6 +229,7 @@ void CfgKeybmode ();
void CfgKeybstack ();
void CfgKludge ();
void CfgKludgechrs ();
void CfgLatintolocal ();
void CfgLoadlanguage ();
void CfgLocationalias ();
void CfgLocationdelimiter();

View File

@ -256,6 +256,8 @@ public:
int keybmode;
char keybstack[80]; // keybuf[80];
gstrarray kludge;
bool latin2local;
char latintolocal[256];
Path loadlanguage;
GStrBag2 locationalias;
std::string locationdelimiter;

View File

@ -1680,6 +1680,51 @@ void ScanKludges(GMsg* msg, int getvalue) {
}
// ------------------------------------------------------------------
void Latin2Local(char *str)
{
if (!CFG->latin2local) return;
for (size_t i = 0; str[i]; i++)
{
byte chr = str[i];
byte xch = CFG->latintolocal[chr];
if (xch && (xch != chr))
{
byte left = i ? str[i-1] : 0;
byte right = str[i+1];
if (((left >= 0x80) && (toupper(left) != tolower(left))) ||
((right >= 0x80) && (toupper(right) != tolower(right))))
{
str[i] = xch;
for (size_t j = i-1; j < i; j--)
{
chr = str[j];
xch = CFG->latintolocal[chr];
if (xch && (xch != chr))
{
left = j ? str[j-1] : 0;
right = str[j+1];
if (((left >= 0x80) && (toupper(left) != tolower(left))) ||
((right >= 0x80) && (toupper(right) != tolower(right))))
{
str[j] = xch;
}
else
break;
}
}
}
}
}
}
// ------------------------------------------------------------------
char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded, bool i51) {

View File

@ -107,6 +107,15 @@ int Area::LoadMsg(GMsg* msg, uint32_t msgno, int margin, int mode) {
if(not (msg->attr.uns() and not msg->attr.rcv()))
return true;
}
if (!mode && !AA->attr().hex())
{
Latin2Local(msg->by);
Latin2Local(msg->to);
Latin2Local(msg->re);
Latin2Local(msg->txt);
}
msg->TextToLines(margin);
return true;
}

View File

@ -180,6 +180,7 @@ Line* InsertLine(Line* newline, Line* oldline, int pos);
Line* LastLine(Line* line);
void MakeLineIndex(GMsg* msg, int rmargin, bool getvalue, bool header_recode);
void MsgLineReIndex(GMsg* msg, int viewhidden=-1, int viewkludge=-1, int viewquote=-1);
void Latin2Local(char *str);
char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded=false, bool i51=false);
char* mime_header_decode(char* decoded, const char* encoded, char* charset = NULL);
char* strxmimecpy(char* dest, const char* source, int level, int size, bool detect = false);