aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-12-15 00:25:58 +0000
committerdam <dam@gudinoff>2022-12-15 00:25:58 +0000
commit8663d6db7fcec2b796d2fbcce0b55f9c10d896e1 (patch)
treed0b296dd9ebada5e6026869491c79893b1503323
parent627f0f4cf3cbe1c983d1fd240298411cba84352f (diff)
downloadtask-time-tracker-8663d6db7fcec2b796d2fbcce0b55f9c10d896e1.tar.zst
task-time-tracker-8663d6db7fcec2b796d2fbcce0b55f9c10d896e1.zip
Tweaked theme colors and command key bindings.
-rw-r--r--main.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/main.c b/main.c
index 2557afe..6cf24a5 100644
--- a/main.c
+++ b/main.c
@@ -770,13 +770,12 @@ void set_active_task(database_st *db, task_st *task) {
#define L_DAYS_IDX 1
#define L_TOTAL_IDX 8
-typedef enum { // TODO Improve theme names.
- THEME_A = 1,
- THEME_B,
- THEME_C,
- THEME_D,
- THEME_E,
-} themes_et;
+typedef enum {
+ STYLE_SELECTED = 1,
+ STYLE_SELECTED_INVERTED,
+ STYLE_ACTIVE,
+ STYLE_ACTIVE_SELECTED,
+} styles_et;
typedef enum {
L_NORMAL,
@@ -866,11 +865,11 @@ void initialize_tui() {
// Initialize pairs of colors.
start_color();
- init_pair(THEME_A, COLOR_BLUE, COLOR_BLACK);
- init_pair(THEME_B, COLOR_BLACK, COLOR_CYAN);
- init_pair(THEME_C, COLOR_WHITE, COLOR_BLUE);
- init_pair(THEME_D, COLOR_CYAN, COLOR_BLACK);
- init_pair(THEME_E, COLOR_BLUE, COLOR_BLACK);
+ use_default_colors(); // Using default (-1) instead of COLOR_BLACK.
+ init_pair(STYLE_SELECTED, COLOR_BLACK, COLOR_CYAN);
+ init_pair(STYLE_SELECTED_INVERTED, COLOR_CYAN, -1);
+ init_pair(STYLE_ACTIVE, COLOR_BLUE, -1);
+ init_pair(STYLE_ACTIVE_SELECTED, COLOR_WHITE, COLOR_BLUE);
}
void update_layout() {
@@ -945,10 +944,10 @@ void draw_tui(database_st *db, layout_st *layout) {
// Apply theme.
if (idx == now_week_day && active_task != NULL) {
- attron(COLOR_PAIR(THEME_E) | A_BOLD);
+ attron(COLOR_PAIR(STYLE_ACTIVE) | A_BOLD);
}
else if (idx == now_week_day) {
- attron(COLOR_PAIR(THEME_D) | A_BOLD);
+ attron(COLOR_PAIR(STYLE_SELECTED_INVERTED) | A_BOLD);
}
col = &layout->columns[L_DAYS_IDX + idx];
@@ -983,13 +982,13 @@ void draw_tui(database_st *db, layout_st *layout) {
// Apply theme.
if (task == active_task && task == selected_task) {
- attron(COLOR_PAIR(THEME_C) | A_BOLD);
+ attron(COLOR_PAIR(STYLE_ACTIVE_SELECTED) | A_BOLD);
}
else if (task == selected_task) {
- attron(COLOR_PAIR(THEME_B));
+ attron(COLOR_PAIR(STYLE_SELECTED));
}
else if (task == active_task) {
- attron(COLOR_PAIR(THEME_A) | A_BOLD);
+ attron(COLOR_PAIR(STYLE_ACTIVE) | A_BOLD);
}
// Task title.
@@ -1049,10 +1048,10 @@ void draw_tui(database_st *db, layout_st *layout) {
// Apply theme.
if (idx == now_week_day && active_task != NULL) {
- attron(COLOR_PAIR(THEME_E) | A_BOLD);
+ attron(COLOR_PAIR(STYLE_ACTIVE) | A_BOLD);
}
else if (idx == now_week_day) {
- attron(COLOR_PAIR(THEME_D) | A_BOLD);
+ attron(COLOR_PAIR(STYLE_SELECTED_INVERTED) | A_BOLD);
}
mvaddstr(y, x, string_buffer);
@@ -1170,7 +1169,6 @@ int main(int argc, char *argv[]) {
bool is_exit_requested = false;
for (unsigned idx = 1; idx < argc; idx++) {
if (is_equal_to_any(argv[idx], "--help", "-h")) {
- // TODO Maybe rearrange the order of the command... or chose other hot-keys?
fprintf(stdout,
"Usage: ttt [OPTION]... [FILE]...\n"
" -i, --import-csv [FILE] Import CSV file to database (discard first row).\n"
@@ -1182,7 +1180,7 @@ int main(int argc, char *argv[]) {
"In app commands\n"
" a, A Archive selected task (except if active).\n"
" u, U Unarchive selected task.\n"
- " c, C Select currently active task (if any).\n"
+ " t, T Select currently active task (if any).\n"
" d, D Duplicate selected task.\n"
" n, N Create new task.\n"
" m, M Move selected task to position.\n"
@@ -1299,7 +1297,7 @@ int main(int argc, char *argv[]) {
task_st *active_task = get_active_task(db);
task_st *selected_task = get_selected_task(db);
int selected_task_row = is_terminal_too_small ? 0 : (db->selected_task % layout_tasks_rows) + NUM_HEADER_ROWS;
- int selected_task_theme = selected_task == active_task ? THEME_E : THEME_D;
+ int selected_task_theme = selected_task == active_task ? STYLE_ACTIVE : STYLE_SELECTED_INVERTED;
timeout(INPUT_AWAIT_INF);
update_times(&database);
@@ -1615,8 +1613,8 @@ int main(int argc, char *argv[]) {
break;
}
- case 'c':
- case 'C': {
+ case 't':
+ case 'T': {
if (active_task == NULL) {
break;
}