auto_non_billable config option

If this is set to a string, then any new entry that contains this string will
be marked as efl_nonbillable=1 automatically.
This commit is contained in:
Felicity Tarnell 2014-03-05 15:02:26 +00:00
parent 62762f7590
commit 7a0aca347e
2 changed files with 18 additions and 4 deletions

17
tts.c
View file

@ -460,6 +460,7 @@ static int show_billable = 0;
static int delete_advance = 1; static int delete_advance = 1;
static int mark_advance = 1; static int mark_advance = 1;
static int bill_advance = 0; static int bill_advance = 0;
static char *auto_nonbillable;
#define VTYPE_INT 1 #define VTYPE_INT 1
#define VTYPE_BOOL 2 #define VTYPE_BOOL 2
@ -475,7 +476,8 @@ static variable_t variables[] = {
{ WIDE("delete_advance"), VTYPE_BOOL, &delete_advance }, { WIDE("delete_advance"), VTYPE_BOOL, &delete_advance },
{ WIDE("mark_advance"), VTYPE_BOOL, &mark_advance }, { WIDE("mark_advance"), VTYPE_BOOL, &mark_advance },
{ WIDE("billable_advance"), VTYPE_BOOL, &bill_advance }, { WIDE("billable_advance"), VTYPE_BOOL, &bill_advance },
{ WIDE("show_billable"), VTYPE_BOOL, &show_billable } { WIDE("show_billable"), VTYPE_BOOL, &show_billable },
{ WIDE("auto_non_billable"), VTYPE_STRING, &auto_nonbillable }
}; };
static variable_t *find_variable(const WCHAR *name); static variable_t *find_variable(const WCHAR *name);
@ -774,6 +776,10 @@ entry_t *en;
return; return;
} }
en = entry_new(name); en = entry_new(name);
if (auto_nonbillable && STRSTR(name, auto_nonbillable))
en->en_flags.efl_nonbillable = 1;
entry_start(en); entry_start(en);
curent = en; curent = en;
save(); save();
@ -2535,6 +2541,7 @@ c_set(argc, argv)
WCHAR **argv; WCHAR **argv;
{ {
variable_t *var; variable_t *var;
int val;
if (argc != 3) { if (argc != 3) {
cmderr(WIDE("Usage: set <variable> <value>")); cmderr(WIDE("Usage: set <variable> <value>"));
@ -2547,8 +2554,7 @@ variable_t *var;
} }
switch (var->va_type) { switch (var->va_type) {
case VTYPE_BOOL: { case VTYPE_BOOL:
int val;
if (STRCMP(argv[2], WIDE("true")) == 0 || if (STRCMP(argv[2], WIDE("true")) == 0 ||
STRCMP(argv[2], WIDE("yes")) == 0 || STRCMP(argv[2], WIDE("yes")) == 0 ||
STRCMP(argv[2], WIDE("on")) == 0 || STRCMP(argv[2], WIDE("on")) == 0 ||
@ -2566,7 +2572,10 @@ variable_t *var;
*(int *)var->va_addr = val; *(int *)var->va_addr = val;
break; break;
}
case VTYPE_STRING:
*(char **)var->va_addr = STRDUP(argv[2]);
break;
} }
} }

View file

@ -17,6 +17,11 @@
# If set, show billable time in each daily summary. # If set, show billable time in each daily summary.
#set show_billable 1 #set show_billable 1
# If this is set, and a newly added entry contains this string, the entry wil
# be automatically marked as non-billable. The string can only be a single
# word and must not be put in quotes.
#set auto_non_billable [INT]
#### Bindings #### Bindings
# #
# Use the 'bind' command to (re)define keybindings. Type '?' while TTS is # Use the 'bind' command to (re)define keybindings. Type '?' while TTS is