From 3436069b7c4ea3d5367a6f865fb97a1155cfecb8 Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Tue, 5 Apr 2022 15:04:22 +0200 Subject: [PATCH] Added bold output in report --- Makefile | 3 ++- README.md | 1 + src/tt.h | 2 +- src/ui.cpp | 8 ++++---- src/ui.h | 9 +++++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7d15054..662bd22 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ -include config.out CXX ?= g++ +CPPFLAGS ?= -DFORMATTED_TEXT CXXFLAGS := -std=c++11 -g -Wall -pedantic OBJFLAGS := $(CXXFLAGS) -c LDFLAGS := -lreadline @@ -21,7 +22,7 @@ $(BIN_PATH)/tt: $(OBJ) $(CXX) $(CXXFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(SRC_PATH)/%.o: $(SRC_PATH)/%.cpp - $(CXX) -DPREFIX=$(PREFIX) $(OBJFLAGS) -o $@ $< + $(CXX) -DPREFIX=$(PREFIX) $(CPPFLAGS) $(OBJFLAGS) -o $@ $< makedir: @mkdir -p $(BIN_PATH) diff --git a/README.md b/README.md index 277ae2e..d47d142 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ The following variables can be used to configure the build: * `PREFIX` - install prefix, defaults to `/usr/local` * `USER_NAME` - user name to be mentioned in monthly reports, defaults to `$USER` * `TRACKING_DIR` - directory where tracking files are saved, defaults to `$HOME/track` +* `CPPFLAGS` - set to `-UFORMATTED_TEXT` if your terminal does not support usual Unix escape sequences The user name and tracking directory can also be set after installation by modifying `$PREFIX/etc/tt.conf` diff --git a/src/tt.h b/src/tt.h index 1e1e1f2..ecbad52 100644 --- a/src/tt.h +++ b/src/tt.h @@ -3,7 +3,7 @@ #include -#define TT_VERSION 1.2.0 +#define TT_VERSION 1.2.0_dev #define TT_IO_VERSION 120 // global variables: diff --git a/src/ui.cpp b/src/ui.cpp index f0a161d..54aba52 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -591,13 +591,13 @@ void command_report(std::string date_str, ProjectList* proj_list){ Project *proj = &(proj_list->projects[i]); float wtime_proj = proj->get_total_work_time() / 3600.0; if(wtime_proj >= 0.01){ - std::cout << "Project: " << proj->name << std::endl; + std::cout << "Project: " << TERM_BOLD << proj->name << TERM_RESET << std::endl; for(int j=0; jnum_tasks; j++){ float wtime_task = proj->tasks[j].work_time / 3600.0; if(wtime_task >= 0.01) std::cout << "--- " << proj->tasks[j].name << ": " << std::fixed << std::setprecision(2) << wtime_task << std::endl; } // format: *.xx hours - std::cout << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << std::endl << std::endl; + std::cout << TERM_BOLD << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << TERM_RESET << std::endl << std::endl; } } }else{ @@ -611,13 +611,13 @@ void command_report(std::string date_str, ProjectList* proj_list){ Project *proj = &(list.projects[i]); float wtime_proj = proj->get_total_work_time() / 3600.0; if(wtime_proj >= 0.01){ - std::cout << "Project: " << proj->name << std::endl; + std::cout << "Project: " << TERM_BOLD << proj->name << TERM_RESET << std::endl; for(int j=0; jnum_tasks; j++){ float wtime_task = proj->tasks[j].work_time / 3600.0; if(wtime_task >= 0.01) std::cout << "--- " << proj->tasks[j].name << ": " << std::fixed << std::setprecision(2) << wtime_task << std::endl; } // format: *.xx hours - std::cout << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << std::endl << std::endl; + std::cout << TERM_BOLD << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << TERM_RESET << std::endl << std::endl; } } }else{ diff --git a/src/ui.h b/src/ui.h index 2a5aaf9..69a7073 100644 --- a/src/ui.h +++ b/src/ui.h @@ -1,6 +1,15 @@ #ifndef UI_H #define UI_H +// define terminal format codes +#ifdef FORMATTED_TEXT +#define TERM_BOLD "\033[1m" +#define TERM_RESET "\033[0m" +#else +#define TERM_BOLD "" +#define TERM_RESET "" +#endif + #include #include #include "project.h"