diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit 45fc1985167609ee39e32f36fa55a77cc8fe12c5
parent 2480f6d6ef611c30d5d7aca3ec81098d3d962cff
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Sun, 17 Jan 2021 13:11:25 +0100

rename year_range to range

This renames the year_range option to simply 'range'.

It is easier to read, faster to comprehend and maps better with the
short command line option '-r'.

Diffstat:
MREADME.md | 2+-
Mdiary.1 | 4++--
Mdiary.c | 18+++++++++---------
Mdiary.cfg | 2+-
Mdiary.h | 4++--
5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/README.md b/README.md @@ -84,6 +84,6 @@ The file `~/.config/diary/diary.cfg` should adhere to a basic `key = value` form | Command Line Option | Config Key | Example Config Value | Default Config Value | Description | | --- | --- | --- | --- | --- | | `--dir`, `-d`, or first non-option argument | `dir` | ~/diary | n/a | Diary directory. Path that holds the journal text files. | -| `--year_range` or `-r` | `year_range` | 10 | 1 | Number of years to show before/after todays date | +| `--range` or `-r` | `range` | 10 | 1 | Number of years to show before/after todays date | | `--first_weekday` or `-w` | `first_weekday` | 0 | 1 | First weekday, `0` = Sunday, `1` = Monday, ..., `6` = Saturday. Use `0` to display week beginning at Sunday ("S-M-T-W-T-F-S"), or `1` for "M-T-W-T-F-S-S" (default) | | `--date_fmt` or `-f` | `date_fmt` | %d_%b_%y | %Y-%m-%d | Date format and file name for the files inside the `dir`. For the format specifiers, see [`man strftime`](https://man7.org/linux/man-pages/man3/strftime.3.html). Be careful: If you change this, you might no longer find your existing diary entries, because the diary assumes to find the journal files under another file name. Hence, a change in FMT shows an empty diary, at first. Rename all files in the DIARY_DIR to migrate to a new FMT. | \ No newline at end of file diff --git a/diary.1 b/diary.1 @@ -22,7 +22,7 @@ Show diary help text \fB\-d\fR, \fB\-\-dir\fR=\fI\,DIARY_DIR\/\fR Diary storage directory DIARY_DIR .TP -\fB\-r\fR, \fB\-\-year_range\fR=\fI\,RANGE\/\fR +\fB\-r\fR, \fB\-\-range\fR=\fI\,RANGE\/\fR RANGE is the number of years to show before/after todays date .TP \fB\-f\fR, \fB\-\-date_weekday\fR=\fI\,DAY\/\fR @@ -79,7 +79,7 @@ Install an example config file with defaults: $ echo '# Path that holds the journal text files #dir = ~/diary # Number of years to show before/after todays date - year_range = 1 + range = 1 # 0 = Sunday, 1 = Monday, ..., 6 = Saturday first_weekday = 1 # Date and file format, change with care diff --git a/diary.c b/diary.c @@ -19,7 +19,7 @@ void setup_cal_timeframe() curs_date = today; cal_start = today; - cal_start.tm_year -= CONFIG.year_range; + cal_start.tm_year -= CONFIG.range; cal_start.tm_mon = 0; cal_start.tm_mday = 1; mktime(&cal_start); @@ -33,7 +33,7 @@ void setup_cal_timeframe() } cal_end = today; - cal_end.tm_year += CONFIG.year_range; + cal_end.tm_year += CONFIG.range; cal_end.tm_mon = 11; cal_end.tm_mday = 31; mktime(&cal_end); @@ -323,8 +323,8 @@ bool read_config(const char* file_path) strcpy(CONFIG.dir, diary_dir_wordexp.we_wordv[0]); } wordfree(&diary_dir_wordexp); - } else if (strcmp("year_range", key_buf) == 0) { - CONFIG.year_range = atoi(value_buf); + } else if (strcmp("range", key_buf) == 0) { + CONFIG.range = atoi(value_buf); } else if (strcmp("first_weekday", key_buf) == 0) { CONFIG.first_weekday = atoi(value_buf); } else if (strcmp("date_fmt", key_buf) == 0) { @@ -347,7 +347,7 @@ void usage() { printf(" -v, --version : Print diary version\n"); printf(" -h, --help : Show diary help text\n"); printf(" -d, --dir DIARY_DIR : Diary storage directory DIARY_DIR\n"); - printf(" -r, --year_range RANGE : RANGE is the number of years to show before/after today's date\n"); + printf(" -r, --range RANGE : RANGE is the number of years to show before/after today's date\n"); printf(" -w, --first_weekday DAY : First day of the week, 0 = Sun, 1 = Mon, ..., 6 = Sat\n"); printf(" -f, --date_fmt FMT : Date and file format, change with care\n"); printf("\n"); @@ -425,7 +425,7 @@ int main(int argc, char** argv) { { "version", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' }, { "dir", required_argument, 0, 'd' }, - { "year_range", required_argument, 0, 'r' }, + { "range", required_argument, 0, 'r' }, { "first_weekday", required_argument, 0, 'w' }, { "date_fmt", required_argument, 0, 'f' }, { 0, 0, 0, 0 } @@ -458,7 +458,7 @@ int main(int argc, char** argv) { break; case 'r': // set year range from option character - CONFIG.year_range = atoi(optarg); + CONFIG.range = atoi(optarg); break; case 'w': // set first week day from option character @@ -508,8 +508,8 @@ int main(int argc, char** argv) { WINDOW* wdays = newwin(1, 3 * 7, 0, ASIDE_WIDTH); draw_wdays(wdays); - WINDOW* aside = newpad((CONFIG.year_range * 2 + 1) * 12 * MAX_MONTH_HEIGHT, ASIDE_WIDTH); - WINDOW* cal = newpad((CONFIG.year_range * 2 + 1) * 12 * MAX_MONTH_HEIGHT, CAL_WIDTH); + WINDOW* aside = newpad((CONFIG.range * 2 + 1) * 12 * MAX_MONTH_HEIGHT, ASIDE_WIDTH); + WINDOW* cal = newpad((CONFIG.range * 2 + 1) * 12 * MAX_MONTH_HEIGHT, CAL_WIDTH); keypad(cal, TRUE); draw_calendar(cal, aside, CONFIG.dir, strlen(CONFIG.dir)); diff --git a/diary.cfg b/diary.cfg @@ -1,7 +1,7 @@ # Path that holds the journal text files #dir = ~/diary # Number of years to show before/after todays date -year_range = 1 +range = 1 # 0 = Sunday, 1 = Monday, ..., 6 = Saturday first_weekday = 1 # Date and file format, change with care diff --git a/diary.h b/diary.h @@ -46,7 +46,7 @@ typedef struct // Path that holds the journal text files char* dir; // Number of years to show before/after todays date - int year_range; + int range; // 0 = Sunday, 1 = Monday, ..., 6 = Saturday int first_weekday; // 2020-12-31 @@ -54,7 +54,7 @@ typedef struct } config; config CONFIG = { - .year_range = 1, + .range = 1, .first_weekday = 1, .date_fmt = "%Y-%m-%d" };