Permalink
Browse files

Timestamp display (/set ts <level>, /set utc)

  • Loading branch information...
1 parent 297a90f commit 3d938cf21ba97afe426438db9abe0f7c43b9ea5c ec429 committed Apr 6, 2011
Showing with 204 additions and 7 deletions.
  1. +26 −1 buffer.c
  2. +2 −0 config.cdl
  3. +5 −0 config_check.c
  4. +2 −0 config_def.c
  5. +2 −0 config_globals.h
  6. +4 −0 config_need.c
  7. +6 −0 config_pargs.c
  8. +23 −0 config_rcread.c
  9. +125 −5 config_set.c
  10. +9 −1 genconfig.c
View
27 buffer.c
@@ -418,7 +418,32 @@ int render_line(int buf, int uline)
}
char *proc;int l,i;
init_char(&proc, &l, &i);
- int x=wordline(bufs[buf].ltag[uline], 0, &proc, &l, &i, bufs[buf].lc[uline]);
+ char stamp[32];
+ struct tm *td=(utc?gmtime:localtime)(&bufs[buf].ts[uline]);
+ switch(ts)
+ {
+ case 1:
+ strftime(stamp, 32, "[%H:%M] ", td);
+ break;
+ case 2:
+ strftime(stamp, 32, "[%H:%M:%S] ", td);
+ break;
+ case 3:
+ if(utc)
+ strftime(stamp, 32, "[%H:%M:%S UTC] ", td);
+ else
+ strftime(stamp, 32, "[%H:%M:%S %z] ", td);
+ break;
+ case 4:
+ snprintf(stamp, 32, "[u+%lu] ", (unsigned long)bufs[buf].ts[uline]);
+ break;
+ case 0: // no timestamps
+ default:
+ stamp[0]=0;
+ break;
+ }
+ int x=wordline(stamp, 0, &proc, &l, &i, (colour){.fore=7, .back=0, .hi=false, .ul=false});
+ x=wordline(bufs[buf].ltag[uline], x, &proc, &l, &i, bufs[buf].lc[uline]);
wordline(bufs[buf].lt[uline], x, &proc, &l, &i, bufs[buf].lc[uline]);
bufs[buf].lpl[uline]=0;
bufs[buf].lpt[uline]=NULL;
View
2 config.cdl
@@ -8,3 +8,5 @@ bool:full_width_colour:false:::fwc:fwc:fwc:B:full width colour
bool:hilite_tabstrip:false:::hts:hts:hts:B:highlight tabstrip
bool:tsb:true:::tsb:tsb:tsb:B:top status bar
int:tping:30:15::tping:tping:tping:S:outbound ping time
+int:ts:1:0:4:ts:timestamps:ts:L:timestamping
+bool:utc:false:::utc:utc:utc:B:UTC timestamps
View
5 config_check.c
@@ -36,5 +36,10 @@ int conf_check(void)
asb_failsafe(c_status, "tping set to minimum 15");
tping=15;
}
+ if(ts>4)
+ {
+ asb_failsafe(c_status, "ts set to maximum 4");
+ ts=4;
+ }
return(0);
}
View
2 config_def.c
@@ -9,3 +9,5 @@
hilite_tabstrip=-1;
tsb=-1;
tping=30;
+ ts=1;
+ utc=-1;
View
2 config_globals.h
@@ -9,3 +9,5 @@ bool full_width_colour; // full width colour
bool hilite_tabstrip; // highlight tabstrip
bool tsb; // top status bar
unsigned int tping; // outbound ping time
+unsigned int ts; // timestamping
+bool utc; // UTC timestamps
View
4 config_need.c
@@ -14,3 +14,7 @@
if(strcmp(cmd, "tsb")==0) need=false;
if(strcmp(cmd, "no-tsb")==0) need=false;
if(strcmp(cmd, "tping")==0) need=false;
+ if(strcmp(cmd, "ts")==0) need=false;
+ if(strcmp(cmd, "no-ts")==0) need=false;
+ if(strcmp(cmd, "utc")==0) need=false;
+ if(strcmp(cmd, "no-utc")==0) need=false;
View
6 config_pargs.c
@@ -25,3 +25,9 @@
tsb=false;
else if(strncmp(argv[arg], "--tping=", 8)==0)
sscanf(argv[arg]+8, "%u", &tping);
+ else if(strncmp(argv[arg], "--timestamps=", 13)==0)
+ sscanf(argv[arg]+13, "%u", &ts);
+ else if(strcmp(argv[arg], "--utc")==0)
+ utc=true;
+ else if(strcmp(argv[arg], "--no-utc")==0)
+ utc=false;
View
23 config_rcread.c
@@ -88,3 +88,26 @@
asb_failsafe(c_err, rest);
}
}
+ else if(strcmp(cmd, "no-ts")==0)
+ ts=false;
+ else if(strcmp(cmd, "ts")==0)
+ {
+ unsigned int value;
+ if(rest&&sscanf(rest, "%u", &value))
+ ts=value;
+ else
+ {
+ asb_failsafe(c_err, "Malformed rc entry for ts (value not numeric)");
+ asb_failsafe(c_err, rest);
+ }
+ }
+ else if(strcmp(cmd, "no-utc")==0)
+ utc=false;
+ else if(strcmp(cmd, "utc")==0)
+ {
+ unsigned int value;
+ if(rest&&sscanf(rest, "%u", &value))
+ utc=value;
+ else
+ utc=true;
+ }
View
130 config_set.c
@@ -12,6 +12,10 @@
char smsg[37];
sprintf(smsg, "display width set to %u", width);
add_to_buffer(cbuf, c_status, smsg, "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "height")==0)
{
@@ -26,6 +30,10 @@
char smsg[38];
sprintf(smsg, "display height set to %u", height);
add_to_buffer(cbuf, c_status, smsg, "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "mcc")==0)
{
@@ -45,11 +53,19 @@
}
else
add_to_buffer(cbuf, c_status, "mirc colour compatibility disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "no-mcc")==0)
{
mirc_colour_compat=0;
- add_to_buffer(cbuf, c_status, "mirc colour compatibility disabled", "/set: ");
+ add_to_buffer(cbuf, c_status, "mirc colour compatibility disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "fred")==0)
{
@@ -69,11 +85,19 @@
}
else
add_to_buffer(cbuf, c_status, "force-redraw disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "no-fred")==0)
{
force_redraw=0;
- add_to_buffer(cbuf, c_status, "force-redraw disabled", "/set: ");
+ add_to_buffer(cbuf, c_status, "force-redraw disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "buf")==0)
{
@@ -88,6 +112,10 @@
char smsg[36];
sprintf(smsg, "buffer lines set to %u", buflines);
add_to_buffer(cbuf, c_status, smsg, "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "mnln")==0)
{
@@ -102,6 +130,10 @@
char smsg[39];
sprintf(smsg, "max nick length set to %u", maxnlen);
add_to_buffer(cbuf, c_status, smsg, "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "fwc")==0)
{
@@ -117,11 +149,19 @@
add_to_buffer(cbuf, c_status, "full width colour enabled", "/set: ");
else
add_to_buffer(cbuf, c_status, "full width colour disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "no-fwc")==0)
{
full_width_colour=0;
- add_to_buffer(cbuf, c_status, "full width colour disabled", "/set: ");
+ add_to_buffer(cbuf, c_status, "full width colour disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "hts")==0)
{
@@ -137,11 +177,19 @@
add_to_buffer(cbuf, c_status, "highlight tabstrip enabled", "/set: ");
else
add_to_buffer(cbuf, c_status, "highlight tabstrip disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "no-hts")==0)
{
hilite_tabstrip=0;
- add_to_buffer(cbuf, c_status, "highlight tabstrip disabled", "/set: ");
+ add_to_buffer(cbuf, c_status, "highlight tabstrip disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "tsb")==0)
{
@@ -157,11 +205,19 @@
add_to_buffer(cbuf, c_status, "top status bar enabled", "/set: ");
else
add_to_buffer(cbuf, c_status, "top status bar disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "no-tsb")==0)
{
tsb=0;
- add_to_buffer(cbuf, c_status, "top status bar disabled", "/set: ");
+ add_to_buffer(cbuf, c_status, "top status bar disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
else if(strcmp(opt, "tping")==0)
{
@@ -176,4 +232,68 @@
char smsg[42];
sprintf(smsg, "outbound ping time set to %u", tping);
add_to_buffer(cbuf, c_status, smsg, "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
+ }
+ else if(strcmp(opt, "ts")==0)
+ {
+ if(val)
+ {
+ unsigned int value;
+ sscanf(val, "%u", &value);
+ ts=value;
+ }
+ else
+ ts=1;
+ if(ts)
+ {
+ char lmsg[44];
+ sprintf(lmsg, "timestamping level %u enabled", ts);
+ add_to_buffer(cbuf, c_status, lmsg, "/set: ");
+ }
+ else
+ add_to_buffer(cbuf, c_status, "timestamping disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
+ }
+ else if(strcmp(opt, "no-ts")==0)
+ {
+ ts=0;
+ add_to_buffer(cbuf, c_status, "timestamping disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
+ }
+ else if(strcmp(opt, "utc")==0)
+ {
+ if(val)
+ {
+ unsigned int value;
+ sscanf(val, "%u", &value);
+ utc=value;
+ }
+ else
+ utc=-1;
+ if(utc)
+ add_to_buffer(cbuf, c_status, "UTC timestamps enabled", "/set: ");
+ else
+ add_to_buffer(cbuf, c_status, "UTC timestamps disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
+ }
+ else if(strcmp(opt, "no-utc")==0)
+ {
+ utc=0;
+ add_to_buffer(cbuf, c_status, "UTC timestamps disabled", "/set: ");
+ int buf;
+ for(buf=0;buf<nbufs;buf++)
+ bufs[buf].dirty=true;
+ redraw_buffer();
}
View
10 genconfig.c
@@ -426,13 +426,21 @@ int main(int argc, char **argv)
printf("\t\t\t\t\tadd_to_buffer(cbuf, c_status, smsg, \"/set: \");\n");
break;
}
+ printf("\t\t\t\t\tint buf;\n");
+ printf("\t\t\t\t\tfor(buf=0;buf<nbufs;buf++)\n");
+ printf("\t\t\t\t\t\tbufs[buf].dirty=true;\n");
+ printf("\t\t\t\t\tredraw_buffer();\n");
printf("\t\t\t\t}\n");
if((ents[i].set_type==BOOLEAN)||(ents[i].set_type==LEVEL))
{
printf("\t\t\t\telse if(strcmp(opt, \"no-%s\")==0)\n", ents[i].set_name);
printf("\t\t\t\t{\n");
printf("\t\t\t\t\t%s=0;\n", ents[i].cname);
- printf("\t\t\t\t\t\tadd_to_buffer(cbuf, c_status, \"%s disabled\", \"/set: \");\n", ents[i].set_msg);
+ printf("\t\t\t\t\tadd_to_buffer(cbuf, c_status, \"%s disabled\", \"/set: \");\n", ents[i].set_msg);
+ printf("\t\t\t\t\tint buf;\n");
+ printf("\t\t\t\t\tfor(buf=0;buf<nbufs;buf++)\n");
+ printf("\t\t\t\t\t\tbufs[buf].dirty=true;\n");
+ printf("\t\t\t\t\tredraw_buffer();\n");
printf("\t\t\t\t}\n");
}
}

0 comments on commit 3d938cf

Please sign in to comment.