Improved ColorName matching

This commit is contained in:
Ianos Gnatiuc 2005-11-08 12:35:23 +00:00
parent de7d1ae282
commit da4989aaa1
5 changed files with 22 additions and 42 deletions

View File

@ -10,6 +10,10 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/ Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________ ______________________________________________________________________
+ Improved ColorName matching. Case insensitive wildcard matching will be
used for ColorName names. Also, search will be stopped on first matched
name or address.
- Relative path usage is fixed. Now a Real UID is used to parse "~/" always. - Relative path usage is fixed. Now a Real UID is used to parse "~/" always.
+ Several unicode charset convertion tables is included into distribution of + Several unicode charset convertion tables is included into distribution of

View File

@ -209,10 +209,8 @@ void GMsgList::ReadMlst(int n) {
strcpy(ml->to, msg.To()); strcpy(ml->to, msg.To());
strcpy(ml->re, msg.re); strcpy(ml->re, msg.re);
ml->colorby = GetColorName(msg.orig); ml->colorby = GetColorName(ml->by, msg.orig, -1);
if (ml->colorby == -1) ml->colorby = GetColorName(ml->by); ml->colorto = GetColorName(ml->to, AA->isnet() ? msg.dest : Addr(), -1);
ml->colorto = AA->isnet() ? GetColorName(msg.dest) : -1;
if (ml->colorto == -1) ml->colorto = GetColorName(ml->to);
} }
@ -944,11 +942,7 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
} }
if (!isbar) if (!isbar)
{ attr = GetColorName(msg.By(), msg.orig, attr);
int colorname = GetColorName(msg.orig);
if (colorname == -1) colorname = GetColorName(msg.By());
if (colorname != -1) attr = colorname;
}
else if (CFG->replylinkfloat) else if (CFG->replylinkfloat)
{ {
size_t bylen = strlen(msg.By()); size_t bylen = strlen(msg.By());

View File

@ -418,8 +418,7 @@ char* strtmp(const char* str);
int quotecolor(const char* line); int quotecolor(const char* line);
void doinvalidate(char* text, const char* find, const char* replace, bool is_tearline = false); void doinvalidate(char* text, const char* find, const char* replace, bool is_tearline = false);
bool find(const std::vector<const char *> &vec, const char *str); bool find(const std::vector<const char *> &vec, const char *str);
int GetColorName(Addr &addr); int GetColorName(const char *name, Addr &addr, int color);
int GetColorName(char *name);
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -330,35 +330,24 @@ void ScreenBlankIdle() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int GetColorName(Addr &addr) int GetColorName(const char *name, Addr &addr, int color)
{ {
if (addr.invalid()) return -1; bool addr_valid = addr.valid();
bool name_valid = (name != NULL);
if (!addr_valid && !name_valid)
return color;
std::vector< std::pair<Node, int> >::iterator it; std::vector< std::pair<Node, int> >::iterator it;
for (it = CFG->colorname.begin(); it != CFG->colorname.end(); it++) for (it = CFG->colorname.begin(); it != CFG->colorname.end(); it++)
{ {
if (addr.match(it->first.addr)) if (addr_valid && addr.match(it->first.addr))
return it->second;
if (name_valid && gwildmat(name, it->first.name))
return it->second; return it->second;
} }
return -1; return color;
}
// ------------------------------------------------------------------
int GetColorName(char *name)
{
if (!name) return -1;
std::vector< std::pair<Node, int> >::iterator it;
for (it = CFG->colorname.begin(); it != CFG->colorname.end(); it++)
{
if (strieql(it->first.name, name))
return it->second;
}
return -1;
} }

View File

@ -100,7 +100,6 @@ void GMsgHeaderView::Paint() {
int namewidth = CFG->disphdrnodeset.pos - CFG->disphdrnameset.pos; int namewidth = CFG->disphdrnodeset.pos - CFG->disphdrnameset.pos;
int nodewidth = CFG->disphdrdateset.pos - CFG->disphdrnodeset.pos; int nodewidth = CFG->disphdrdateset.pos - CFG->disphdrnodeset.pos;
int datewidth = MinV(width - CFG->disphdrdateset.pos, CFG->disphdrdateset.len); int datewidth = MinV(width - CFG->disphdrdateset.pos, CFG->disphdrdateset.len);
int colorname = -1;
#if defined(GUTLOS_FUNCS) #if defined(GUTLOS_FUNCS)
g_set_ostitle_name(struplow(strtmp(area->echoid())), 0); g_set_ostitle_name(struplow(strtmp(area->echoid())), 0);
@ -194,8 +193,6 @@ void GMsgHeaderView::Paint() {
if(not area->isinternet()) { if(not area->isinternet()) {
if(area->isecho() or not (*msg->ifrom and (*msg->realby or *msg->iorig))) if(area->isecho() or not (*msg->ifrom and (*msg->realby or *msg->iorig)))
{ {
colorname = GetColorName(msg->orig);
// Generate orig node data // Generate orig node data
if(msg->orig.net) if(msg->orig.net)
msg->orig.make_string(buf); msg->orig.make_string(buf);
@ -214,13 +211,12 @@ void GMsgHeaderView::Paint() {
else else
strxcpy(buf, msg->By(), (namewidth+nodewidth)); strxcpy(buf, msg->By(), (namewidth+nodewidth));
if (colorname == -1) colorname = GetColorName(buf);
strsetsz(buf, nodegenerated ? namewidth : (namewidth+nodewidth)); strsetsz(buf, nodegenerated ? namewidth : (namewidth+nodewidth));
window.prints(2, 0, window_color, LNG->From); window.prints(2, 0, window_color, LNG->From);
int color = ((msg->foundwhere&GFIND_FROM) or msg->attr.fmu() or (msg->attr.loc() and CFG->switches.get(displocalhigh))) ? highlight_color : from_color; int color = ((msg->foundwhere&GFIND_FROM) or msg->attr.fmu() or (msg->attr.loc() and CFG->switches.get(displocalhigh))) ? highlight_color : from_color;
window.prints(2, CFG->disphdrnameset.pos, (colorname != -1) ? colorname : color, buf); color = GetColorName(msg->By(), msg->orig, color);
colorname = -1; window.prints(2, CFG->disphdrnameset.pos, color, buf);
if(datewidth > 0) { if(datewidth > 0) {
if(msg->written) if(msg->written)
@ -236,8 +232,6 @@ void GMsgHeaderView::Paint() {
if(not area->isinternet()) { if(not area->isinternet()) {
if(not (*msg->ito and (*msg->realto or *msg->idest))) if(not (*msg->ito and (*msg->realto or *msg->idest)))
{ {
if (area->isnet()) colorname = GetColorName(msg->dest);
if(msg->dest.net and area->isnet()) { if(msg->dest.net and area->isnet()) {
msg->dest.make_string(buf); msg->dest.make_string(buf);
if(msg->odest.net) { if(msg->odest.net) {
@ -259,12 +253,12 @@ void GMsgHeaderView::Paint() {
else else
strxcpy(buf, msg->To(), (namewidth+nodewidth)); strxcpy(buf, msg->To(), (namewidth+nodewidth));
if (colorname == -1) colorname = GetColorName(buf);
strsetsz(buf, nodegenerated ? namewidth : (namewidth+nodewidth)); strsetsz(buf, nodegenerated ? namewidth : (namewidth+nodewidth));
window.prints(3, 0, window_color, LNG->To); window.prints(3, 0, window_color, LNG->To);
color = ((msg->foundwhere&GFIND_TO) or msg->attr.tou()) ? highlight_color : to_color; color = ((msg->foundwhere&GFIND_TO) or msg->attr.tou()) ? highlight_color : to_color;
window.prints(3, CFG->disphdrnameset.pos, (colorname != -1) ? colorname : color , buf); color = GetColorName(msg->To(), area->isnet() ? msg->dest : Addr(), color);
window.prints(3, CFG->disphdrnameset.pos, color, buf);
if(datewidth > 0) { if(datewidth > 0) {
if(msg->arrived) if(msg->arrived)