Added URL recognition

This commit is contained in:
Alexander S. Aganichev 2001-10-14 08:12:45 +00:00
parent 11434b5a32
commit 05b352cded
4 changed files with 55 additions and 5 deletions

View File

@ -149,6 +149,7 @@ const word CRC_UNSENTHIGH = 0xB4FD;
const word CRC_QUOTE2 = 0xF400; const word CRC_QUOTE2 = 0xF400;
const word CRC_QUOTE1 = 0xF403; const word CRC_QUOTE1 = 0xF403;
const word CRC_SIGNATURE = 0x1A6E; const word CRC_SIGNATURE = 0x1A6E;
const word CRC_URL = 0x581C;
const word CRC_B = 0x0042; const word CRC_B = 0x0042;
@ -532,6 +533,9 @@ void GetColors(char* value) {
case CRC_SIGNATURE: case CRC_SIGNATURE:
wptr->_Signature = attr; wptr->_Signature = attr;
break; break;
case CRC_URL:
wptr->_URL = attr;
break;
case CRC_UNSENTHIGH: case CRC_UNSENTHIGH:
wptr->_HighlightUnsent = attr; wptr->_HighlightUnsent = attr;
break; break;

View File

@ -654,6 +654,7 @@ struct SaveUtil {
#define _Pagebar c[11] #define _Pagebar c[11]
#define _Signature c[12] #define _Signature c[12]
#define _Quote2 c[13] #define _Quote2 c[13]
#define _URL c[14]
#define _WindowUnsent c[6] #define _WindowUnsent c[6]
#define _WindowUnread c[7] #define _WindowUnread c[7]
@ -711,8 +712,9 @@ struct SaveUtil {
#define C_READT GC_READ_._Tearline #define C_READT GC_READ_._Tearline
#define C_READO GC_READ_._Origin #define C_READO GC_READ_._Origin
#define C_READPB GC_READ_._Pagebar #define C_READPB GC_READ_._Pagebar
#define C_READQ2 GC_READ_._Quote2
#define C_READS GC_READ_._Signature #define C_READS GC_READ_._Signature
#define C_READQ2 GC_READ_._Quote2
#define C_READU GC_READ_._URL
#define C_HEADW GC_HEAD_._Window #define C_HEADW GC_HEAD_._Window
#define C_HEADB GC_HEAD_._Border #define C_HEADB GC_HEAD_._Border
#define C_HEADT GC_HEAD_._Title #define C_HEADT GC_HEAD_._Title

View File

@ -110,11 +110,55 @@ void Container::StyleCodeHighlight(const char* text, int row, int col, bool dohi
prints(row, col+sclen, C_STYLE[colorindex], buf); prints(row, col+sclen, C_STYLE[colorindex], buf);
sclen += strlen(buf); sclen += strlen(buf);
txptr = end; txptr = end;
ptr = end-1;
} }
} }
} }
} }
ptr = end-1; }
}
}
else {
if(not strnicmp(ptr, "http://", 7) or not strnicmp(ptr, "ftp://", 6) or
not strnicmp(ptr, "www.", 4) or not strnicmp(ptr, "ftp.", 4) or
not strnicmp(ptr, "mailto:", 7)) {
const char *end = ptr+4+strcspn(ptr+4, " \t\"\'<>");
strxcpy(buf, txptr, (uint)(ptr-txptr)+1);
prints(row, col+sclen, color, buf);
sclen += strlen(buf);
strxcpy(buf, ptr, (uint)(end-ptr)+1);
prints(row, col+sclen, C_READU, buf);
sclen += strlen(buf);
txptr = end;
ptr = end-1;
}
else if(isascii(*ptr) and not isspace(*ptr) and not ispunct(*ptr)) {
// try to guess e-mail address...
const char *commerce_at = NULL;
if(*ptr == '\"') {
const char *pair_quote = strchr(ptr+1, '\"');
if(pair_quote != NULL) {
commerce_at = pair_quote+1;
}
}
else {
commerce_at = strpbrk(ptr, " \t@");
}
if ((commerce_at != NULL) and (*commerce_at == '@')) {
++commerce_at;
while((*commerce_at != NUL) and (isalnum(*commerce_at) or (*commerce_at == '.') or (*commerce_at == '-'))) {
++commerce_at;
}
strxcpy(buf, txptr, (uint)(ptr-txptr)+1);
prints(row, col+sclen, color, buf);
sclen += strlen(buf);
strxcpy(buf, ptr, (uint)(commerce_at-ptr)+1);
prints(row, col+sclen, C_READU, buf);
sclen += strlen(buf);
txptr = commerce_at;
ptr = commerce_at-1;
} }
} }
} }

View File

@ -109,7 +109,7 @@ Win gold_color1[16] = {
{5, { 31, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1 {5, { 31, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1
{0, { 15, 14, 14, 7, 12, 7, 7, 9, 7, 7, 7, 14}, 0}, // Brag 2 {0, { 15, 14, 14, 7, 12, 7, 7, 9, 7, 7, 7, 14}, 0}, // Brag 2
{0, { 7, 9, 14, 31, 15, 7, 7, 7, 7, 7, 7, 9}, 0}, // Area 3 {0, { 7, 9, 14, 31, 15, 7, 7, 7, 7, 7, 7, 9}, 0}, // Area 3
{0, { 7, 7, 15, 14, 113, 8, 15, 79, 15, 15, 8, 7, 8, 15}, 5}, // Read 4 {0, { 7, 7, 15, 14, 113, 8, 15, 79, 15, 15, 8, 7, 8, 15, 15}, 5}, // Read 4
{0, { 7, 9, 14, 7, 15, 7, 15, 113, 7, 7, 7, 9}, 0}, // Head 5 {0, { 7, 9, 14, 7, 15, 7, 15, 113, 7, 7, 7, 9}, 0}, // Head 5
{0, { 7, 12, 14, 31, 15, 8, 7, 7, 7, 7, 7, 12}, 0}, // Ask 6 {0, { 7, 12, 14, 31, 15, 8, 7, 7, 7, 7, 7, 12}, 0}, // Ask 6
{0, { 7, 12, 14, 31, 15, 8, 7, 2, 12, 15, 7, 12}, 0}, // Menu 7 {0, { 7, 12, 14, 31, 15, 8, 7, 2, 12, 15, 7, 12}, 0}, // Menu 7
@ -130,7 +130,7 @@ Win gold_color2[16] = {
{5, { 143, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1 {5, { 143, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1
{0, { 15, 14, 14, 7, 12, 7, 7, 9, 7, 7, 7, 14}, 0}, // Brag 2 {0, { 15, 14, 14, 7, 12, 7, 7, 9, 7, 7, 7, 14}, 0}, // Brag 2
{0, { 240, 241, 244, 143, 244, 7, 7, 7, 7, 7, 7, 241}, 0}, // Area 3 {0, { 240, 241, 244, 143, 244, 7, 7, 7, 7, 7, 7, 241}, 0}, // Area 3
{0, { 241, 240, 242, 244, 64, 248, 240, 64, 240, 240, 248, 240, 248, 241}, 5}, // Read 4 {0, { 241, 240, 242, 244, 64, 248, 240, 64, 240, 240, 248, 240, 248, 241, 249}, 5}, // Read 4
{0, { 135, 142, 142, 135, 143, 7, 143, 64, 135, 135, 7, 142}, 0}, // Head 5 {0, { 135, 142, 142, 135, 143, 7, 143, 64, 135, 135, 7, 142}, 0}, // Head 5
{0, { 224, 230, 232, 143, 228, 231, 7, 7, 7, 7, 7, 230}, 0}, // Ask 6 {0, { 224, 230, 232, 143, 228, 231, 7, 7, 7, 7, 7, 230}, 0}, // Ask 6
{0, { 112, 126, 116, 143, 126, 120, 117, 113, 125, 121, 7, 126}, 0}, // Menu 7 {0, { 112, 126, 116, 143, 126, 120, 117, 113, 125, 121, 7, 126}, 0}, // Menu 7
@ -151,7 +151,7 @@ Win gold_mono1[16] = {
{5, { 112, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1 {5, { 112, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1
{0, { 15, 7, 15, 7, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Brag 2 {0, { 15, 7, 15, 7, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Brag 2
{0, { 7, 7, 15, 112, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Area 3 {0, { 7, 7, 15, 112, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Area 3
{0, { 7, 7, 15, 15, 112, 15, 7, 7, 7, 7, 15, 7, 7, 15}, 5}, // Read 4 {0, { 7, 7, 15, 15, 112, 15, 7, 7, 7, 7, 15, 7, 7, 15, 7}, 5}, // Read 4
{0, { 7, 7, 15, 7, 15, 7, 112, 15, 7, 7, 7, 7}, 0}, // Head 5 {0, { 7, 7, 15, 7, 15, 7, 112, 15, 7, 7, 7, 7}, 0}, // Head 5
{0, { 112, 112, 112, 15, 15, 7, 7, 7, 7, 7, 7, 112}, 0}, // Ask 6 {0, { 112, 112, 112, 15, 15, 7, 7, 7, 7, 7, 7, 112}, 0}, // Ask 6
{0, { 7, 7, 112, 112, 15, 7, 15, 15, 15, 15, 7, 7}, 0}, // Menu 7 {0, { 7, 7, 112, 112, 15, 7, 15, 15, 15, 15, 7, 7}, 0}, // Menu 7