diary

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

commit 5f6eace2ff80b2b3006e0dcad61bde60c015a287
parent ea093e4323b62430f9c9cf2bd6fbd75b3864aa9b
Author: in0rdr <andreas.gruhler@uzh.ch>
Date:   Sun, 27 Nov 2016 08:33:59 +0800

Jump to date (search feature)

Diffstat:
MREADME.md | 1+
Mdiary.c | 20+++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md @@ -41,6 +41,7 @@ This is a text based diary, inspired by [khal](https://github.com/pimutils/khal) e, Enter Edit the current entry d, x Delete/remove current entry t Jump to today + s Jump to specific day j, down go forward by 1 week k, up go backward by 1 week diff --git a/diary.c b/diary.c @@ -318,7 +318,9 @@ int main(int argc, char** argv) { keypad(cal, TRUE); draw_calendar(cal, aside, diary_dir, strlen(diary_dir)); - int ch, conf_ch, pad_pos = 0; + int ch, conf_ch; + int pad_pos = 0; + int syear = 0, smonth = 0, sday = 0; struct tm new_date; int prev_width = COLS - ASIDE_WIDTH - CAL_WIDTH; int prev_height = LINES - 1; @@ -386,6 +388,22 @@ int main(int argc, char** argv) { mv_valid = go_to(cal, aside, mktime(&new_date), &pad_pos); break; + // search for specific date + case 's': + wclear(header); + curs_set(2); + mvwprintw(header, 0, 0, "Go to date [YYYY-MM-DD]: "); + if (wscanw(header, "%4i-%2i-%2i", &syear, &smonth, &sday) == 3) { + // struct tm.tm_year: years since 1900 + new_date.tm_year = syear - 1900; + // struct tm.tm_mon in range [0, 11] + new_date.tm_mon = smonth - 1; + new_date.tm_mday = sday; + mv_valid = go_to(cal, aside, mktime(&new_date), &pad_pos); + } + curs_set(0); + //update_date(header); + break; // today shortcut case 't': new_date = today;