aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c65
-rw-r--r--readme.md4
2 files changed, 45 insertions, 24 deletions
diff --git a/main.c b/main.c
index 8e6cfbc..2c60813 100644
--- a/main.c
+++ b/main.c
@@ -595,7 +595,7 @@ void update_total_timers(database_st *db) {
int64_t *d4 = &db->total_times[4];
int64_t *d5 = &db->total_times[5];
int64_t *d6 = &db->total_times[6];
- memset(db->total_times, NUM_WEEK_DAYS, sizeof(int64_t));
+ memset(db->total_times, 0, NUM_WEEK_DAYS * sizeof(int64_t));
for (size_t idx = 0; idx < db->count; idx++) {
int64_t *times = db->tasks[idx].times;
@@ -1042,18 +1042,19 @@ int main(int argc, char *argv[]) {
switch(key) {
// When getch() times out.
- case ERR:
+ case ERR: {
break;
+ }
// When terminal is resized.
- case KEY_RESIZE:
+ case KEY_RESIZE: {
clear();
getmaxyx(stdscr, size_y, size_x);
string_buffer = realloc(string_buffer, 511 | MAX_TASK_NAME | size_x); // TODO This realloc sucks.
break;
+ }
- case KEY_F(1):
- {
+ case KEY_F(1): {
// Create new task.
task_st *new_task;
if (create_task(db, &new_task) == false) {
@@ -1072,12 +1073,10 @@ int main(int argc, char *argv[]) {
// Force rename action.
ungetch(KEY_F(2));
-
break;
}
- case KEY_F(2):
- {
+ case KEY_F(2): {
if (selected_task == NULL) {
break;
}
@@ -1099,8 +1098,7 @@ int main(int argc, char *argv[]) {
break;
}
- case KEY_F(3):
- {
+ case KEY_DC: { // Delete
if (selected_task == NULL) {
break;
}
@@ -1108,16 +1106,30 @@ int main(int argc, char *argv[]) {
break;
}
+ case KEY_F(4): {
+ if (selected_task == NULL) {
+ break;
+ }
+
+ add_task(db, selected_task);
+ break;
+ }
+
+ case KEY_F(5): {
+ update_total_timers(db);
+ break;
+ }
+
case 'c':
- case 'C':
+ case 'C': {
if (active_task != NULL) {
db->selected_task = db->active_task;
}
break;
+ }
case '\n':
- case ' ':
- {
+ case ' ': {
if (db != &database) {
break;
}
@@ -1134,7 +1146,7 @@ int main(int argc, char *argv[]) {
break;
}
- case KEY_BACKSPACE:
+ case '\t': {
if (db == &database) {
reset_database(&archive); // TODO Not needed because we never leave things hanging.
import_from_csv(&archive, ar_file_path);
@@ -1146,9 +1158,10 @@ int main(int argc, char *argv[]) {
db = &database;
}
break;
+ }
case 'a':
- case 'A':
+ case 'A': {
if (db != &database || selected_task == NULL || selected_task == active_task) {
break;
}
@@ -1156,9 +1169,10 @@ int main(int argc, char *argv[]) {
delete_task(db, selected_task);
// TODO Maybe save stuff? Shoulw we?
break;
+ }
case 'u':
- case 'U':
+ case 'U': {
if (db != &archive || selected_task == NULL) {
break;
}
@@ -1166,6 +1180,7 @@ int main(int argc, char *argv[]) {
delete_task(db, selected_task);
// TODO Maybe save stuff? Shoulw we?
break;
+ }
case KEY_LEFT:
break;
@@ -1173,43 +1188,49 @@ int main(int argc, char *argv[]) {
case KEY_RIGHT:
break;
- case KEY_HOME:
+ case KEY_HOME: {
if (db->count > 0) {
db->selected_task = 0;
}
break;
+ }
- case KEY_UP:
+ case KEY_UP: {
if (db->selected_task > 0) {
db->selected_task--;
}
break;
+ }
- case KEY_PPAGE:
+ case KEY_PPAGE: {
db->selected_task -= NUM_TABLE_ROWS;
if (db->selected_task < 0) {
db->selected_task = 0;
}
break;
+ }
- case KEY_END:
+ case KEY_END: {
if (db->count > 0) {
db->selected_task = db->count - 1;
}
break;
+ }
- case KEY_DOWN:
+ case KEY_DOWN: {
if (db->selected_task < db->count - 1) {
db->selected_task++;
}
break;
+ }
- case KEY_NPAGE:
+ case KEY_NPAGE: {
db->selected_task += NUM_TABLE_ROWS;
if (db->selected_task >= db->count) {
db->selected_task = db->count - 1;
}
break;
+ }
}
if (size_x >= 60 && size_y >= 3) {
diff --git a/readme.md b/readme.md
index b025f35..b962704 100644
--- a/readme.md
+++ b/readme.md
@@ -30,7 +30,7 @@ Task Time Tracker
- [x] Make sure that only one task is running at each time;
- [x] Mouse selection is broken due to entire TUI update: No, it was fixed by using `erase()` on the `draw_tui` instead of `clear()`;
- [x] I bet the headers are no longer being used all on a single cycle. Let's separate them and include "header_title_archive";
-- [x] rename layout members: title_header, archive_header, total_header, days_headers, column_widths, column_alignments, headers_paddings.
+- [x] Rename layout members: title_header, archive_header, total_header, days_headers, column_widths, column_alignments, headers_paddings.
- [x] using the archive header, we can remove the top-left-corner diamond on the archive.
- [x] Allow to cancel a rename_task operation: you can do it by leaving it blank.
- [x] Make sure we are not using `strcat` and `strcpy`... or that we are using them wisely (famous last words).
@@ -40,7 +40,7 @@ Task Time Tracker
- [x] Allow to archive task using keys: `a` and `A`;
- [x] By default, store files on `~/.config/task_time_tracker/` or `~/.local/share/task_time_tracker` and allow to store elsewhere if passed by argument `--config`.
- [x] Allow usage of `ttt: ./ttt --dpath ./` to change the app folder: To changes app data path change the environment variable HOME (USERPROFILE for windows users).
-- [ ] Clone (replicate) task; If task is active, mark newly created task as inactive;
+- [x] Clone (replicate) task; If task is active, mark newly created task as inactive;
- [ ] Confirm delete_task operation.
- [ ] Change task order (using task_t tmp_task + memcpy);
- [ ] Add/remove time using keys: `F3`;