mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-09 16:05:35 +00:00
Renamed pager
This commit is contained in:
@@ -7,11 +7,11 @@ static void action_list()
|
||||
{
|
||||
pit_db_load();
|
||||
if (actions->number_of_records > 0) {
|
||||
PPager ppager = pit_pager_initialize(PAGER_ACTION, 0, actions->number_of_records);
|
||||
PFormat pf = pit_pager_initialize(PAGER_ACTION, 0, actions->number_of_records);
|
||||
for_each_action(pa) {
|
||||
pit_pager_print(ppager, (char *)pa);
|
||||
pit_pager_print(pf, (char *)pa);
|
||||
}
|
||||
pit_pager_flush(ppager);
|
||||
pit_pager_flush(pf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
249
src/format.c
Normal file
249
src/format.c
Normal file
@@ -0,0 +1,249 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "pit.h"
|
||||
|
||||
#define for_each_entry(pf, entry) for (entry = (char **)pf->entries; (char *)*entry; entry++)
|
||||
#define TASK(attr) (((PTask)*pentry)->attr)
|
||||
#define PROJECT(attr) (((PProject)*pentry)->attr)
|
||||
#define ACTION(attr) (((PAction)*pentry)->attr)
|
||||
#define NOTE(attr) (((PNote)*pentry)->attr)
|
||||
|
||||
static void print_notes(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) %%s\n", pf->indent, pf->max.note.id, pf->max.note.username);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format, (NOTE(id) == notes->current ? '*' : ' '), NOTE(id), NOTE(username), NOTE(message));
|
||||
}
|
||||
}
|
||||
|
||||
static void print_actions(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%s (%%-%ds): %%s\n", pf->max.action.username);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format, format_date(ACTION(created_at)), ACTION(username), ACTION(message));
|
||||
}
|
||||
}
|
||||
|
||||
static void print_projects(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%c %%%dd: (%%-%ds) |%%-%ds| %%-%ds (%%d task%%s)\n",
|
||||
pf->max.project.id, pf->max.project.username, pf->max.project.status, pf->max.project.name
|
||||
);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format,
|
||||
(PROJECT(id) == projects->current ? '*' : ' '),
|
||||
PROJECT(id),
|
||||
PROJECT(username),
|
||||
PROJECT(status),
|
||||
PROJECT(name),
|
||||
PROJECT(number_of_tasks),
|
||||
(PROJECT(number_of_tasks) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%-%ds (%%d note%%s)\n",
|
||||
pf-> indent, pf->max.task.id, pf->max.task.username, pf->max.task.status, pf->max.task.priority, pf->max.task.name
|
||||
);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks_with_date(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%-%ds %%-%ds (%%d note%%s)\n",
|
||||
pf->indent, pf->max.task.id, pf->max.task.username, pf->max.task.status, pf->max.task.priority, pf->max.task.date, pf->max.task.name
|
||||
);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
(TASK(date) ? format_date(TASK(date)) : ""),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks_with_time(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%%ds %%-%ds (%%d note%%s)\n",
|
||||
pf->indent, pf->max.task.id, pf->max.task.username, pf->max.task.status, pf->max.task.priority, pf->max.task.time, pf->max.task.name
|
||||
);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
(TASK(time) ? format_time(TASK(time)) : ""),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks_with_date_and_time(PFormat pf)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%-%ds %%%ds %%-%ds (%%d note%%s)\n",
|
||||
pf->indent, pf->max.task.id, pf->max.task.username, pf->max.task.status, pf->max.task.priority, pf->max.task.date, pf->max.task.time, pf->max.task.name
|
||||
);
|
||||
for_each_entry(pf, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
(TASK(date) ? format_date(TASK(date)) : ""),
|
||||
(TASK(time) ? format_time(TASK(time)) : ""),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PFormat pit_pager_initialize(int type, int indent, int number_of_entries)
|
||||
{
|
||||
PFormat pf = calloc(1, sizeof(Pager));
|
||||
|
||||
memset(pf, 0, sizeof(Pager));
|
||||
pf->type = type;
|
||||
pf->indent = indent;
|
||||
pf->entries = calloc(number_of_entries + 1, sizeof(char *));
|
||||
|
||||
return pf;
|
||||
}
|
||||
|
||||
void pit_pager_print(PFormat pf, char *entry)
|
||||
{
|
||||
char str[32];
|
||||
|
||||
char **pentry = (char **)pf->entries + pf->number_of_entries++;
|
||||
*pentry = entry;
|
||||
|
||||
for_each_entry(pf, pentry) {
|
||||
switch(pf->type) {
|
||||
case PAGER_PROJECT:
|
||||
sprintf(str, "%d", PROJECT(id));
|
||||
pf->max.project.id = max(pf->max.project.id, strlen(str));
|
||||
pf->max.project.username = max(pf->max.project.username, strlen(PROJECT(username)));
|
||||
pf->max.project.name = max(pf->max.project.name, strlen(PROJECT(name)));
|
||||
pf->max.project.status = max(pf->max.project.status, strlen(PROJECT(status)));
|
||||
break;
|
||||
case PAGER_TASK:
|
||||
sprintf(str, "%d", TASK(id));
|
||||
pf->max.task.id = max(pf->max.task.id, strlen(str));
|
||||
pf->max.task.username = max(pf->max.task.username, strlen(TASK(username)));
|
||||
pf->max.task.name = max(pf->max.task.name, strlen(TASK(name)));
|
||||
pf->max.task.status = max(pf->max.task.status, strlen(TASK(status)));
|
||||
pf->max.task.priority = max(pf->max.task.priority, strlen(TASK(priority)));
|
||||
if (TASK(date)) {
|
||||
pf->max.task.date = max(pf->max.task.date, strlen(format_date(TASK(date))));
|
||||
}
|
||||
if (TASK(time)) {
|
||||
pf->max.task.time = max(pf->max.task.time, strlen(format_time(TASK(time))));
|
||||
}
|
||||
break;
|
||||
case PAGER_NOTE:
|
||||
sprintf(str, "%d", NOTE(id));
|
||||
pf->max.note.id = max(pf->max.note.id, strlen(str));
|
||||
pf->max.note.username = max(pf->max.note.username, strlen(NOTE(username)));
|
||||
break;
|
||||
case PAGER_ACTION:
|
||||
pf->max.action.username = max(pf->max.action.username, strlen(ACTION(username)));
|
||||
pf->max.action.message = max(pf->max.action.message, strlen(ACTION(message)));
|
||||
break;
|
||||
default:
|
||||
die("invalid pager type: %d\n", pf->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pit_pager_flush(PFormat pf)
|
||||
{
|
||||
switch(pf->type) {
|
||||
case PAGER_TASK:
|
||||
if (!pf->max.task.date && !pf->max.task.time) {
|
||||
print_tasks(pf); /* Neither date nor time. */
|
||||
} else if (pf->max.task.date) {
|
||||
if (pf->max.task.time) {
|
||||
print_tasks_with_date_and_time(pf); /* Both date and time. */
|
||||
} else {
|
||||
print_tasks_with_date(pf); /* Date but no time. */
|
||||
}
|
||||
} else {
|
||||
print_tasks_with_time(pf); /* Time but no date. */
|
||||
}
|
||||
break;
|
||||
|
||||
case PAGER_PROJECT:
|
||||
print_projects(pf);
|
||||
break;
|
||||
|
||||
case PAGER_ACTION:
|
||||
print_actions(pf);
|
||||
break;
|
||||
|
||||
case PAGER_NOTE:
|
||||
print_notes(pf);
|
||||
break;
|
||||
|
||||
default:
|
||||
pit_pager_free(pf);
|
||||
die("invalid pager type: %d\n", pf->type);
|
||||
}
|
||||
pit_pager_free(pf);
|
||||
}
|
||||
|
||||
void pit_pager_free(PFormat pf)
|
||||
{
|
||||
free(pf->entries);
|
||||
free(pf);
|
||||
}
|
||||
|
||||
#undef TASK
|
||||
#undef PROJECT
|
||||
#undef ACTION
|
||||
#undef NOTE
|
||||
@@ -36,11 +36,11 @@ typedef struct _Pager {
|
||||
int username;
|
||||
} note;
|
||||
} max;
|
||||
} Pager, *PPager;
|
||||
} Pager, *PFormat;
|
||||
|
||||
PPager pit_pager_initialize(int type, int indent, int number_of_entries);
|
||||
void pit_pager_print(PPager ppager, char *entry);
|
||||
void pit_pager_flush(PPager ppager);
|
||||
void pit_pager_free(PPager ppager);
|
||||
PFormat pit_pager_initialize(int type, int indent, int number_of_entries);
|
||||
void pit_pager_print(PFormat pf, char *entry);
|
||||
void pit_pager_flush(PFormat pf);
|
||||
void pit_pager_free(PFormat pf);
|
||||
|
||||
#endif
|
||||
@@ -115,14 +115,14 @@ void pit_note_list(PTask pt)
|
||||
if (!notes) pit_db_load();
|
||||
|
||||
if (notes->number_of_records > 0) {
|
||||
PPager ppager = pit_pager_initialize(PAGER_NOTE, pt ? 4 : 0, notes->number_of_records);
|
||||
PFormat pf = pit_pager_initialize(PAGER_NOTE, pt ? 4 : 0, notes->number_of_records);
|
||||
if (!pt) pt = (PTask)pit_table_current(tasks);
|
||||
for_each_note(pn) {
|
||||
if (pt && pn->task_id != pt->id)
|
||||
continue;
|
||||
pit_pager_print(ppager, (char *)pn);
|
||||
pit_pager_print(pf, (char *)pn);
|
||||
}
|
||||
pit_pager_flush(ppager);
|
||||
pit_pager_flush(pf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
249
src/pager.c
249
src/pager.c
@@ -1,249 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "pit.h"
|
||||
|
||||
#define for_each_entry(ppager, entry) for (entry = (char **)ppager->entries; (char *)*entry; entry++)
|
||||
#define TASK(attr) (((PTask)*pentry)->attr)
|
||||
#define PROJECT(attr) (((PProject)*pentry)->attr)
|
||||
#define ACTION(attr) (((PAction)*pentry)->attr)
|
||||
#define NOTE(attr) (((PNote)*pentry)->attr)
|
||||
|
||||
static void print_notes(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) %%s\n", ppager->indent, ppager->max.note.id, ppager->max.note.username);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format, (NOTE(id) == notes->current ? '*' : ' '), NOTE(id), NOTE(username), NOTE(message));
|
||||
}
|
||||
}
|
||||
|
||||
static void print_actions(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%s (%%-%ds): %%s\n", ppager->max.action.username);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format, format_date(ACTION(created_at)), ACTION(username), ACTION(message));
|
||||
}
|
||||
}
|
||||
|
||||
static void print_projects(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%c %%%dd: (%%-%ds) |%%-%ds| %%-%ds (%%d task%%s)\n",
|
||||
ppager->max.project.id, ppager->max.project.username, ppager->max.project.status, ppager->max.project.name
|
||||
);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format,
|
||||
(PROJECT(id) == projects->current ? '*' : ' '),
|
||||
PROJECT(id),
|
||||
PROJECT(username),
|
||||
PROJECT(status),
|
||||
PROJECT(name),
|
||||
PROJECT(number_of_tasks),
|
||||
(PROJECT(number_of_tasks) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%-%ds (%%d note%%s)\n",
|
||||
ppager-> indent, ppager->max.task.id, ppager->max.task.username, ppager->max.task.status, ppager->max.task.priority, ppager->max.task.name
|
||||
);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks_with_date(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%-%ds %%-%ds (%%d note%%s)\n",
|
||||
ppager->indent, ppager->max.task.id, ppager->max.task.username, ppager->max.task.status, ppager->max.task.priority, ppager->max.task.date, ppager->max.task.name
|
||||
);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
(TASK(date) ? format_date(TASK(date)) : ""),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks_with_time(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%%ds %%-%ds (%%d note%%s)\n",
|
||||
ppager->indent, ppager->max.task.id, ppager->max.task.username, ppager->max.task.status, ppager->max.task.priority, ppager->max.task.time, ppager->max.task.name
|
||||
);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
(TASK(time) ? format_time(TASK(time)) : ""),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_tasks_with_date_and_time(PPager ppager)
|
||||
{
|
||||
char **pentry;
|
||||
char format[64];
|
||||
|
||||
sprintf(format, "%%%dc %%%dd: (%%-%ds) |%%-%ds| |%%-%ds| %%-%ds %%%ds %%-%ds (%%d note%%s)\n",
|
||||
ppager->indent, ppager->max.task.id, ppager->max.task.username, ppager->max.task.status, ppager->max.task.priority, ppager->max.task.date, ppager->max.task.time, ppager->max.task.name
|
||||
);
|
||||
for_each_entry(ppager, pentry) {
|
||||
printf(format,
|
||||
(TASK(id) == tasks->current ? '*' : ' '),
|
||||
TASK(id),
|
||||
TASK(username),
|
||||
TASK(status),
|
||||
TASK(priority),
|
||||
(TASK(date) ? format_date(TASK(date)) : ""),
|
||||
(TASK(time) ? format_time(TASK(time)) : ""),
|
||||
TASK(name),
|
||||
TASK(number_of_notes),
|
||||
(TASK(number_of_notes) != 1 ? "s" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PPager pit_pager_initialize(int type, int indent, int number_of_entries)
|
||||
{
|
||||
PPager ppager = calloc(1, sizeof(Pager));
|
||||
|
||||
memset(ppager, 0, sizeof(Pager));
|
||||
ppager->type = type;
|
||||
ppager->indent = indent;
|
||||
ppager->entries = calloc(number_of_entries + 1, sizeof(char *));
|
||||
|
||||
return ppager;
|
||||
}
|
||||
|
||||
void pit_pager_print(PPager ppager, char *entry)
|
||||
{
|
||||
char str[32];
|
||||
|
||||
char **pentry = (char **)ppager->entries + ppager->number_of_entries++;
|
||||
*pentry = entry;
|
||||
|
||||
for_each_entry(ppager, pentry) {
|
||||
switch(ppager->type) {
|
||||
case PAGER_PROJECT:
|
||||
sprintf(str, "%d", PROJECT(id));
|
||||
ppager->max.project.id = max(ppager->max.project.id, strlen(str));
|
||||
ppager->max.project.username = max(ppager->max.project.username, strlen(PROJECT(username)));
|
||||
ppager->max.project.name = max(ppager->max.project.name, strlen(PROJECT(name)));
|
||||
ppager->max.project.status = max(ppager->max.project.status, strlen(PROJECT(status)));
|
||||
break;
|
||||
case PAGER_TASK:
|
||||
sprintf(str, "%d", TASK(id));
|
||||
ppager->max.task.id = max(ppager->max.task.id, strlen(str));
|
||||
ppager->max.task.username = max(ppager->max.task.username, strlen(TASK(username)));
|
||||
ppager->max.task.name = max(ppager->max.task.name, strlen(TASK(name)));
|
||||
ppager->max.task.status = max(ppager->max.task.status, strlen(TASK(status)));
|
||||
ppager->max.task.priority = max(ppager->max.task.priority, strlen(TASK(priority)));
|
||||
if (TASK(date)) {
|
||||
ppager->max.task.date = max(ppager->max.task.date, strlen(format_date(TASK(date))));
|
||||
}
|
||||
if (TASK(time)) {
|
||||
ppager->max.task.time = max(ppager->max.task.time, strlen(format_time(TASK(time))));
|
||||
}
|
||||
break;
|
||||
case PAGER_NOTE:
|
||||
sprintf(str, "%d", NOTE(id));
|
||||
ppager->max.note.id = max(ppager->max.note.id, strlen(str));
|
||||
ppager->max.note.username = max(ppager->max.note.username, strlen(NOTE(username)));
|
||||
break;
|
||||
case PAGER_ACTION:
|
||||
ppager->max.action.username = max(ppager->max.action.username, strlen(ACTION(username)));
|
||||
ppager->max.action.message = max(ppager->max.action.message, strlen(ACTION(message)));
|
||||
break;
|
||||
default:
|
||||
die("invalid pager type: %d\n", ppager->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pit_pager_flush(PPager ppager)
|
||||
{
|
||||
switch(ppager->type) {
|
||||
case PAGER_TASK:
|
||||
if (!ppager->max.task.date && !ppager->max.task.time) {
|
||||
print_tasks(ppager); /* Neither date nor time. */
|
||||
} else if (ppager->max.task.date) {
|
||||
if (ppager->max.task.time) {
|
||||
print_tasks_with_date_and_time(ppager); /* Both date and time. */
|
||||
} else {
|
||||
print_tasks_with_date(ppager); /* Date but no time. */
|
||||
}
|
||||
} else {
|
||||
print_tasks_with_time(ppager); /* Time but no date. */
|
||||
}
|
||||
break;
|
||||
|
||||
case PAGER_PROJECT:
|
||||
print_projects(ppager);
|
||||
break;
|
||||
|
||||
case PAGER_ACTION:
|
||||
print_actions(ppager);
|
||||
break;
|
||||
|
||||
case PAGER_NOTE:
|
||||
print_notes(ppager);
|
||||
break;
|
||||
|
||||
default:
|
||||
pit_pager_free(ppager);
|
||||
die("invalid pager type: %d\n", ppager->type);
|
||||
}
|
||||
pit_pager_free(ppager);
|
||||
}
|
||||
|
||||
void pit_pager_free(PPager ppager)
|
||||
{
|
||||
free(ppager->entries);
|
||||
free(ppager);
|
||||
}
|
||||
|
||||
#undef TASK
|
||||
#undef PROJECT
|
||||
#undef ACTION
|
||||
#undef NOTE
|
||||
@@ -9,7 +9,7 @@ typedef int bool;
|
||||
#include <time.h> /* __USE_XOPEN needed for strptime() */
|
||||
#include "object.h"
|
||||
#include "table.h"
|
||||
#include "pager.h"
|
||||
#include "format.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
|
||||
@@ -66,18 +66,18 @@ static void project_log_delete(int id, char *name, int number_of_tasks)
|
||||
|
||||
static void project_list(POptions po)
|
||||
{
|
||||
PPager ppager;
|
||||
PFormat pf;
|
||||
|
||||
pit_db_load();
|
||||
if (projects->number_of_records > 0) {
|
||||
ppager = pit_pager_initialize(PAGER_PROJECT, 0, projects->number_of_records);
|
||||
pf = pit_pager_initialize(PAGER_PROJECT, 0, projects->number_of_records);
|
||||
for_each_project(pp) {
|
||||
if ((po->project.name && !stristr(pp->name, po->project.name)) ||
|
||||
(po->project.status && !stristr(pp->status, po->project.status)))
|
||||
continue;
|
||||
pit_pager_print(ppager, (char *)pp);
|
||||
pit_pager_print(pf, (char *)pp);
|
||||
}
|
||||
pit_pager_flush(ppager);
|
||||
pit_pager_flush(pf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ void pit_task_list(POptions po, PProject pp)
|
||||
if (!tasks) pit_db_load();
|
||||
|
||||
if (tasks->number_of_records > 0) {
|
||||
PPager ppager = pit_pager_initialize(PAGER_TASK, (pp ? 4 : 0), tasks->number_of_records);
|
||||
PFormat pf = pit_pager_initialize(PAGER_TASK, (pp ? 4 : 0), tasks->number_of_records);
|
||||
if (!pp) pp = (PProject)pit_table_current(projects);
|
||||
|
||||
for_each_task(pt) {
|
||||
@@ -242,9 +242,9 @@ void pit_task_list(POptions po, PProject pp)
|
||||
(po->task.time && pt->time < po->task.time) ||
|
||||
(po->task.time_max && pt->time > po->task.time_max))
|
||||
)) continue;
|
||||
pit_pager_print(ppager, (char *)pt);
|
||||
pit_pager_print(pf, (char *)pt);
|
||||
}
|
||||
pit_pager_flush(ppager);
|
||||
pit_pager_flush(pf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user