From 10c7631aa84c9eebb8e2dedd2f23ba813b2961e5 Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Sat, 29 Oct 2005 03:05:31 +0000 Subject: [PATCH] New config file token ColorName --- cfgs/config/advanced.cfg | 5 +++++ cfgs/config/advanced.rus | 4 ++++ docs/notework.txt | 4 ++++ golded3/gccfgg.h | 1 + golded3/gccfgg0.cpp | 1 + golded3/gccfgg2.cpp | 36 ++++++++++++++++++++++++++++++++++++ golded3/gcprot.h | 2 +- golded3/geall.h | 2 ++ golded3/gecfgg.h | 1 + golded3/gedoss.cpp | 1 + golded3/gemlst.cpp | 31 ++++++++++++++++++++++++++----- golded3/geprot.h | 2 ++ golded3/geutil2.cpp | 32 ++++++++++++++++++++++++++++++++ golded3/geview.cpp | 22 ++++++++++++++++++---- 14 files changed, 134 insertions(+), 10 deletions(-) diff --git a/cfgs/config/advanced.cfg b/cfgs/config/advanced.cfg index 92872ed..c8b8718 100644 --- a/cfgs/config/advanced.cfg +++ b/cfgs/config/advanced.cfg @@ -1224,6 +1224,11 @@ COLORSET DETECT ; Select based on screencard and intense value. // Include a color setup from another file. INCLUDE GEDCOLOR.CFG +// ColorName +// This is used to define special color for some names and/or addresses. +// Color must be an integer. +;ColorName John Doe 7:654/321.* 15 + ---------------------------------------------------------------------- -- EXTERNAL UTILITIES diff --git a/cfgs/config/advanced.rus b/cfgs/config/advanced.rus index c57f2cf..b1849bb 100644 --- a/cfgs/config/advanced.rus +++ b/cfgs/config/advanced.rus @@ -1396,6 +1396,10 @@ ColorSet Detect ; // Подключить файл с цветовыми настройками. Include gedcolor.cfg +// ColorName +// Этим можно назначить особый цвет для некоторых имен и/или адресов. +// Color должен быть целое число. +;ColorName John Doe 7:654/321.* 15 ---------------------------------------------------------------------- -- ВНЕШНИЕ УТИЛИТЫ diff --git a/docs/notework.txt b/docs/notework.txt index 142824c..25fd7ee 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,6 +10,10 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ ++ New config file token: ColorName . + This is used to define special color for some names and/or addresses. + Color must be an integer. + + Menu Action->Forward will work on marked messages. + Improved false quote detection. diff --git a/golded3/gccfgg.h b/golded3/gccfgg.h index d0e269e..18e2038 100644 --- a/golded3/gccfgg.h +++ b/golded3/gccfgg.h @@ -106,6 +106,7 @@ const word CRC_BEEPNOISES = 0x84D5; const word CRC_BEEPYOURMAIL = 0x0F72; const word CRC_CARBONCOPYLIST = 0x8290; const word CRC_COLOR = 0x9F15; +const word CRC_COLORNAME = 0x8181; const word CRC_COLORSET = 0x874C; const word CRC_CONFIRMFILE = 0x1963; const word CRC_CONFIRMRESPONSE = 0x3D82; diff --git a/golded3/gccfgg0.cpp b/golded3/gccfgg0.cpp index 6cb35a0..ce41747 100644 --- a/golded3/gccfgg0.cpp +++ b/golded3/gccfgg0.cpp @@ -256,6 +256,7 @@ SwitchC: switch(crc) { case CRC_CARBONCOPYLIST : CfgCarboncopylist (); break; case CRC_COLOR : CfgColor (); break; + case CRC_COLORNAME : CfgColorname (); break; case CRC_COLORSET : CfgColorset (); break; case CRC_CONFIRMFILE : CfgConfirmfile (); break; case CRC_CONFIRMRESPONSE : CfgConfirmresponse (); break; diff --git a/golded3/gccfgg2.cpp b/golded3/gccfgg2.cpp index 2f66052..02d6f9e 100644 --- a/golded3/gccfgg2.cpp +++ b/golded3/gccfgg2.cpp @@ -260,6 +260,42 @@ void CfgColor() { // ------------------------------------------------------------------ +void CfgColorname() +{ + char* ptr = strrchr(val, ' '); + if (!ptr) return; + ptr = strskip_wht(ptr); + + Node cn; + int color = atoi(ptr); + + // color was given + *ptr = NUL; + strbtrim(val); + + ptr = strrchr(val, ' '); + if (!ptr) ptr = val; + ptr = strskip_wht(ptr); + + if (isdigit(*ptr)) + { + cn.addr.set(ptr); + + if (cn.addr.net) + { + // Address was given + *ptr = NUL; + strbtrim(val); + } + } + + strxcpy(cn.name, val, sizeof(cn.name)); + + CFG->colorname.push_back(std::pair(cn, color)); +} + +// ------------------------------------------------------------------ + void CfgColorset() { if(strieql(val, "Normal")) { diff --git a/golded3/gcprot.h b/golded3/gcprot.h index 2adb5bd..e424a87 100644 --- a/golded3/gcprot.h +++ b/golded3/gcprot.h @@ -106,8 +106,8 @@ void CfgBeepfactor (); void CfgBeepyourmail (); void CfgCarboncopylist (); void CfgColor (); +void CfgColorname (); void CfgColorset (); -void CfgColor (); void CfgConfirmfile (); void CfgConfirmresponse (); void CfgCookiepath (); diff --git a/golded3/geall.h b/golded3/geall.h index ec5dcc6..606f3bf 100644 --- a/golded3/geall.h +++ b/golded3/geall.h @@ -562,6 +562,8 @@ struct MLst { time32_t arrived; time32_t received; char goldmark; + int colorby; + int colorto; }; diff --git a/golded3/gecfgg.h b/golded3/gecfgg.h index 9288f17..e8fb557 100644 --- a/golded3/gecfgg.h +++ b/golded3/gecfgg.h @@ -189,6 +189,7 @@ public: int beepyourmail; int carboncopylist; // cclist; Win color[16]; + std::vector< std::pair > colorname; Path confirmfile; // goldedcfm; int confirmresponse; Path cookiepath; diff --git a/golded3/gedoss.cpp b/golded3/gedoss.cpp index 75deb53..a495110 100644 --- a/golded3/gedoss.cpp +++ b/golded3/gedoss.cpp @@ -108,6 +108,7 @@ void Cleanup(void) { CFG->addressmacro.clear(); CFG->aka.clear(); CFG->akamatch.clear(); + CFG->colorname.clear(); CFG->event.clear(); CFG->externutil.clear(); CFG->filealias.clear(); diff --git a/golded3/gemlst.cpp b/golded3/gemlst.cpp index 2878982..040e40c 100644 --- a/golded3/gemlst.cpp +++ b/golded3/gemlst.cpp @@ -208,6 +208,11 @@ void GMsgList::ReadMlst(int n) { strcpy(ml->by, msg.By()); strcpy(ml->to, msg.To()); strcpy(ml->re, msg.re); + + ml->colorby = GetColorName(msg.orig); + if (ml->colorby == -1) ml->colorby = GetColorName(ml->by); + ml->colorto = AA->isnet() ? GetColorName(msg.dest) : -1; + if (ml->colorto == -1) ml->colorto = GetColorName(ml->to); } @@ -338,12 +343,21 @@ void GMsgList::print_line(uint idx, uint pos, bool isbar) { window.prints(pos, 0, wattr_, buf); - if(ml->high & (MLST_HIGH_BOOK|MLST_HIGH_MARK)) + if (ml->high & (MLST_HIGH_BOOK|MLST_HIGH_MARK)) window.prints(pos, 5, mattr_, ml->marks); - if(ml->high & MLST_HIGH_FROM) - window.printns(pos, bycol, hattr_, ml->by, bysiz); - if((ml->high & MLST_HIGH_TO) and not AA->Msglistwidesubj()) - window.printns(pos, tocol, hattr_, ml->to, tosiz); + + if ((ml->high & MLST_HIGH_FROM) || (ml->colorby != -1)) + { + int color = ((ml->colorby != -1) && !isbar) ? ml->colorby : hattr_; + window.printns(pos, bycol, color, ml->by, bysiz); + } + + if (((ml->high & MLST_HIGH_TO) || (ml->colorto != -1)) && + !AA->Msglistwidesubj()) + { + int color = ((ml->colorto != -1) && !isbar) ? ml->colorto : hattr_; + window.printns(pos, tocol, color, ml->to, tosiz); + } goldmark = ml->goldmark; } @@ -930,6 +944,13 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) { break; } + if (!isbar) + { + int colorname = GetColorName(msg.orig); + if (colorname == -1) colorname = GetColorName(msg.By()); + if (colorname != -1) attr = colorname; + } + if (CFG->replylinkfloat && isbar) { int l1 = strlen(buf2); diff --git a/golded3/geprot.h b/golded3/geprot.h index 3e3d64a..b2231c4 100644 --- a/golded3/geprot.h +++ b/golded3/geprot.h @@ -416,6 +416,8 @@ char* strtmp(const char* str); int quotecolor(const char* line); void doinvalidate(char* text, const char* find, const char* replace, bool is_tearline = false); bool find(const std::vector &vec, const char *str); +int GetColorName(Addr &addr); +int GetColorName(char *name); // ------------------------------------------------------------------ diff --git a/golded3/geutil2.cpp b/golded3/geutil2.cpp index 70def74..6d70de9 100644 --- a/golded3/geutil2.cpp +++ b/golded3/geutil2.cpp @@ -330,3 +330,35 @@ void ScreenBlankIdle() { // ------------------------------------------------------------------ +int GetColorName(Addr &addr) +{ + std::vector< std::pair >::iterator it; + + for (it = CFG->colorname.begin(); it != CFG->colorname.end(); it++) + { + if (addr.match(it->first.addr)) + return it->second; + } + + return -1; +} + + +// ------------------------------------------------------------------ + +int GetColorName(char *name) +{ + std::vector< std::pair >::iterator it; + + for (it = CFG->colorname.begin(); it != CFG->colorname.end(); it++) + { + if (strieql(it->first.name, name)) + return it->second; + } + + return -1; +} + + +// ------------------------------------------------------------------ + diff --git a/golded3/geview.cpp b/golded3/geview.cpp index 0dc9d55..0b51b2b 100644 --- a/golded3/geview.cpp +++ b/golded3/geview.cpp @@ -100,6 +100,7 @@ void GMsgHeaderView::Paint() { int namewidth = CFG->disphdrnodeset.pos - CFG->disphdrnameset.pos; int nodewidth = CFG->disphdrdateset.pos - CFG->disphdrnodeset.pos; int datewidth = MinV(width - CFG->disphdrdateset.pos, CFG->disphdrdateset.len); + int colorname = -1; #if defined(GUTLOS_FUNCS) g_set_ostitle_name(struplow(strtmp(area->echoid())), 0); @@ -191,7 +192,10 @@ void GMsgHeaderView::Paint() { // Generate from info bool nodegenerated = false; 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 if(msg->orig.net) msg->orig.make_string(buf); @@ -209,10 +213,14 @@ void GMsgHeaderView::Paint() { strxcpy(buf, msg->iorig, (namewidth+nodewidth)); else strxcpy(buf, msg->By(), (namewidth+nodewidth)); + + if (colorname == -1) colorname = GetColorName(buf); strsetsz(buf, nodegenerated ? namewidth : (namewidth+nodewidth)); window.prints(2, 0, window_color, LNG->From); - window.prints(2, CFG->disphdrnameset.pos, ((msg->foundwhere&GFIND_FROM) or msg->attr.fmu() or (msg->attr.loc() and CFG->switches.get(displocalhigh))) ? highlight_color : from_color, buf); + 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); + colorname = -1; if(datewidth > 0) { if(msg->written) @@ -226,7 +234,10 @@ void GMsgHeaderView::Paint() { // Generate dest node data nodegenerated = false; 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()) { msg->dest.make_string(buf); if(msg->odest.net) { @@ -247,10 +258,13 @@ void GMsgHeaderView::Paint() { strxcpy(buf, msg->idest, (namewidth+nodewidth)); else strxcpy(buf, msg->To(), (namewidth+nodewidth)); + + if (colorname == -1) colorname = GetColorName(buf); strsetsz(buf, nodegenerated ? namewidth : (namewidth+nodewidth)); window.prints(3, 0, window_color, LNG->To); - window.prints(3, CFG->disphdrnameset.pos, ((msg->foundwhere&GFIND_TO) or msg->attr.tou()) ? highlight_color : to_color, buf); + color = ((msg->foundwhere&GFIND_TO) or msg->attr.tou()) ? highlight_color : to_color; + window.prints(3, CFG->disphdrnameset.pos, (colorname != -1) ? colorname : color , buf); if(datewidth > 0) { if(msg->arrived)