New config file token ColorName

This commit is contained in:
Ianos Gnatiuc 2005-10-29 03:05:31 +00:00
parent 8a89360fc8
commit 10c7631aa8
14 changed files with 134 additions and 10 deletions

View File

@ -1224,6 +1224,11 @@ COLORSET DETECT ; Select based on screencard and intense value.
// Include a color setup from another file.
INCLUDE GEDCOLOR.CFG
// ColorName <name/address> <color>
// 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

View File

@ -1396,6 +1396,10 @@ ColorSet Detect ;
// <20>®¤ª«îç¨âì ä ©« á 梥⮢묨 ­ áâனª ¬¨.
Include gedcolor.cfg
// ColorName <name/address> <color>
// ťâ¨¬ ¬®¦­® ­ §­ ç¨âě ®á®ˇë© ć˘Ąâ ¤«ď ­ĄŞ®â®ŕëĺ ¨¬Ą­ ¨/¨«¨  ¤ŕĄá®˘.
// Color ¤®«¦Ą­ ˇëâě 楫®Ą ç¨á«®.
;ColorName John Doe 7:654/321.* 15
----------------------------------------------------------------------
-- <>˜<E280A6>ˆ… “’ˆ‹ˆ’›

View File

@ -10,6 +10,10 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________
+ New config file token: ColorName <name/address> <color>.
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.

View File

@ -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;

View File

@ -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;

View File

@ -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<Node, int>(cn, color));
}
// ------------------------------------------------------------------
void CfgColorset() {
if(strieql(val, "Normal")) {

View File

@ -106,8 +106,8 @@ void CfgBeepfactor ();
void CfgBeepyourmail ();
void CfgCarboncopylist ();
void CfgColor ();
void CfgColorname ();
void CfgColorset ();
void CfgColor ();
void CfgConfirmfile ();
void CfgConfirmresponse ();
void CfgCookiepath ();

View File

@ -562,6 +562,8 @@ struct MLst {
time32_t arrived;
time32_t received;
char goldmark;
int colorby;
int colorto;
};

View File

@ -189,6 +189,7 @@ public:
int beepyourmail;
int carboncopylist; // cclist;
Win color[16];
std::vector< std::pair<Node, int> > colorname;
Path confirmfile; // goldedcfm;
int confirmresponse;
Path cookiepath;

View File

@ -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();

View File

@ -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);

View File

@ -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<const char *> &vec, const char *str);
int GetColorName(Addr &addr);
int GetColorName(char *name);
// ------------------------------------------------------------------

View File

@ -330,3 +330,35 @@ void ScreenBlankIdle() {
// ------------------------------------------------------------------
int GetColorName(Addr &addr)
{
std::vector< std::pair<Node, int> >::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<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,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)