diary

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

commit 669112c83741aa79b0ebef8fb20bfa44b87549ec
parent ede0dbf9aba91d2a16000d684ddf358b7ac14afe
Author: mbjd <vir.ingens@gmail.com>
Date:   Sat, 19 Nov 2016 15:26:22 +0100

More vim shortcuts

Diffstat:
MREADME.md | 24+++++++++++++++++++-----
Mdiary.c | 26+++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md @@ -9,19 +9,33 @@ This is a text based diary, inspired by [khal](https://github.com/pimutils/khal) ``` export EDITOR=vim ``` - + 2. Compile (requires ncurses): ``` make clean; make; ``` - + 3. Run the diary with the folder for the text files as first argument: ``` ./diary ~/.diary ``` - + The text files in this folder will be named 'yyyy-mm-dd'. - + (Optionally create an alias for convencience: `alias diary="~/.bin/diary ~/.diary")` -4. Use the keypad or VIM-like shortcuts to move between dates. Type 't' for today and 'e' to edit. That's it that's all. +4. Use the keypad or VIM-like shortcuts to move between dates: + + e,enter Edit the current entry + t,n Jump to today + + j go forward by 1 week + k go backward by 1 week + h go left by 1 day + l go right by 1 day + + g go to the first date + G go to the last date + + J Go forward by 1 month + K Go backward by 1 month diff --git a/diary.c b/diary.c @@ -232,6 +232,7 @@ int main(int argc, char** argv) char* ecmd = curs_date_edit_cmd(diary_dir); switch(ch) { + // Basic movements case 'j': case KEY_DOWN: new_date.tm_mday += 7; @@ -252,13 +253,36 @@ int main(int argc, char** argv) new_date.tm_mday--; ret = go_to(cal, aside, timelocal(&new_date), &pad_pos); break; + + // Jump to top/bottom of page + case 'g': + ret = go_to(cal, aside, timelocal(&cal_start), &pad_pos); + break; + case 'G': + ret = go_to(cal, aside, timelocal(&cal_end), &pad_pos); + break; + + // Jump backward/forward by a month + case 'K': + if (new_date.tm_mday == 1) + new_date.tm_mon--; + new_date.tm_mday = 1; + ret = go_to(cal, aside, timelocal(&new_date), &pad_pos); + break; + case 'J': + new_date.tm_mon++; + new_date.tm_mday = 1; + ret = go_to(cal, aside, timelocal(&new_date), &pad_pos); + break; + + // Today shortcut case 't': case 'n': new_date = cur_date; ret = go_to(cal, aside, raw_time, &pad_pos); break; + // Edit/create a diary entry case 'e': - case 'i': case '\n': if (ecmd) { curs_set(1);