Skip to content

Commit

Permalink
feat: add calendar tab (#37)
Browse files Browse the repository at this point in the history
* feat: boilerplate code for new tab

* feat: more boilerplate

* feat: working calendar view with view mode selection

* refactor: remove calendar modes

* feat: better calendar controls (frees tab for pane focus)

* refactor: export calendar to widgets

* feat: timeline view based on selected date

* feat: mark days with tasks on calendars

* fix: crash on empty vault

* refactor: rename Timeline tab to Calendar

* feat: only show 3 months in calendar

* style: make clippy happy

* fix: Wrong year when selecting January or December

* fix: reload vault in calendar

* feat: show days with tasks even when selected or previewed (underlined)

* chore: small changes to example files

* feat: add cli command to open calendar view

* feat: populate footer

* feat: add calendar legend

* feat: display selected date

* fix: tab switching didn't take calendar into account

* chore: add vhs to flake

* docs: update examples

* docs: add calendar to readme

* docs: typo

* docs: add demo description

* feat: goto today command

* docs: add goto today command
  • Loading branch information
louis-thevenet authored Jan 1, 2025
1 parent 95b166a commit 20120cd
Show file tree
Hide file tree
Showing 37 changed files with 760 additions and 89 deletions.
38 changes: 38 additions & 0 deletions .config/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
[keybindings.Calendar]
# App
"<q>" = "Quit"
"<Ctrl-c>" = "Quit"
"<Ctrl-z>" = "Suspend"
"<?>" = "Help"
# Tabs
"<Shift-Right>" = "TabRight"
"<Shift-l>" = "TabRight"
"<Shift-Left>" = "TabLeft"
"<shift-h>" = "TabLeft"
# Scrolling
"<Ctrl-u>" = "ViewUp"
"<Ctrl-k>" = "ViewUp"
"<Ctrl-Up>" = "ViewUp"
"<PageUp>" = "ViewPageUp"
"<Ctrl-j>" = "ViewDown"
"<Ctrl-d>" = "ViewDown"
"<Ctrl-Down>" = "ViewDown"
"<PageDown>" = "ViewPageDown"
# Navigation
"<r>" = "ReloadVault"
"<t>" = "GotoToday"
"<j>" = "Down"
"<Down>" = "Down"
"<k>" = "Up"
"<Up>" = "Up"
"<h>" = "Left"
"<Left>" = "Left"
"<l>" = "Right"
"<Right>" = "Right"
"<Shift-j>" = "NextMonth"
"<Shift-Down>" = "NextMonth"
"<Shift-k>" = "PreviousMonth"
"<Shift-Up>" = "PreviousMonth"
"<n>" = "NextYear"
"<Shift-n>" = "PreviousYear"

[keybindings.Explorer]
# App
"<q>" = "Quit"
Expand Down
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ futures = "0.3.31"
human-panic = "2.0.2"
lazy_static = "1.5.0"
libc = "0.2.167"
ratatui = {version = "0.29.0", features = ["serde", "macros"]}
ratatui = {version = "0.29.0", features = ["serde", "macros", "widget-calendar"]}
signal-hook = "0.3.17"
strip-ansi-escapes = "0.2.0"
tokio = {version = "1.41.1", features = ["full"]}
tokio-util = "0.7.12"
tracing-error = "0.2.1"
tracing-subscriber = {version = "0.3.19", features = ["env-filter", "serde"]}
chrono = "0.4.38"
chrono = {version="0.4.38"}
tui-widget-list = "0.13.0"
tui-input = "0.11.1"
edit = "0.1.5"
Expand All @@ -46,6 +46,7 @@ strum_macros = "0.26.4"
notify-rust = "4.11.3"
lexical-sort = "0.3.1"
winnow = "0.6.20"
time = "0.3.37"

[dev-dependencies]
insta = {version = "1.41.1", features = ["yaml"]}
Expand Down
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
onfig Vault-tasks
# Vault-tasks

`vault-tasks` is a TUI Markdown task manager.

It will parse any Markdown file or vault and display the tasks it contains.

## Demo using `./test-vault`

```
test-vault
├── chocolate_lava_cake.md
├── daily_workout.md
├── diy_bookshelf.md
├── study_plan.md
└── test.md
```

![Demo](./examples/demo_full.gif)

## Why
Expand All @@ -24,13 +35,13 @@ I also spend most of my writing time in the terminal (Helix) and do not rely on
- priority
- Navigate vault
- Search through tasks (sort and filter)
- Calendar view and timeline
- Edit tasks or open in default editor
- Time Management tab (Pomodoro & Flowtime)

## Planned Features

- `new` action in Explorer Tab to create a new child on selected entry
- A Timeline tab with a calendar and a chronological view. (I'd also like to be able to import calendar files)

## Installation

Expand Down Expand Up @@ -162,6 +173,29 @@ Check the key map within the app with `?`

![](./examples/demo_filter.gif)

#### Calendar Tab

##### Navigation

| Key | Alternate Key | Action |
| --------- | ------------- | -------- |
| `h` | `` | +1 day |
| `l` | `` | -1 day |
| `j` | `` | +7 days |
| `k` | `` | -7 days |
| `Shift-j` | `Shift-↓` | +1 month |
| `Shift-k` | `Shift-↑` | -1 month |
| `n` | | +1 year |
| `Shift-n` | | -1 year |

##### Commands

| Key | Action |
| --- | ---------- |
| `t` | Goto Today |

![](./examples/demo_calendar.gif)

#### Time Management Tab

##### Navigation
Expand Down Expand Up @@ -192,6 +226,7 @@ vault-tasks explorer # is the default
# Or
vault-tasks filter
vault-tasks time
vault-tasks calendar
```

You can also output the content of a vault in standard output using
Expand Down
Binary file added examples/demo_calendar.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/demo_calendar.mp4
Binary file not shown.
35 changes: 35 additions & 0 deletions examples/demo_calendar.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Output ./demo_calendar.gif
Output ./demo_calendar.mp4

Set Shell zsh
Set Theme "Builtin Solarized Light"
Set TypingSpeed 80ms
Set FontSize 22
Set Width 1800
Set Height 1000

Hide
Type "vault-tasks -c ../.config/ -v ../test-vault calendar"
Enter
Show
# Calendar tab
#
Sleep 2.5s

Right
Sleep 2s
Right@0.5s 4
Sleep 2s

Right@0.5s 3
Sleep 1s
Right@1s 2
Sleep 1s

Shift+k
Sleep 1s
Up@0.5s 3

# Stop vault-tasks
Ctrl+c

Binary file modified examples/demo_explorer.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/demo_explorer.mp4
Binary file not shown.
4 changes: 3 additions & 1 deletion examples/demo_explorer.tape
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Set Theme "Builtin Solarized Light"
Set TypingSpeed 80ms
Set FontSize 22
Set Width 1800
Set Height 800
Set Height 1000

Hide
Type "vault-tasks -c ../.config/ -v ../test-vault explorer"
Enter
Show

# First entry
Sleep 3s
Expand Down
Binary file modified examples/demo_filter.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/demo_filter.mp4
Binary file not shown.
4 changes: 3 additions & 1 deletion examples/demo_filter.tape
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Set Theme "Builtin Solarized Light"
Set TypingSpeed 80ms
Set FontSize 22
Set Width 1800
Set Height 800
Set Height 1000

Hide
Type "vault-tasks -c ../.config/ -v ../test-vault filter"
Enter
Show

Sleep 3s
Type "#tobuy 09/29"
Expand Down
Binary file modified examples/demo_full.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/demo_full.mp4
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/demo_full.tape
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Set TypingSpeed 80ms
Set FontSize 22
Set FontSize 22
Set Width 1800
Set Height 800
Set Height 1000

Source ./demo_explorer.tape
Source ./demo_filter.tape
Source ./demo_calendar.tape
Source ./demo_time.tape
Binary file modified examples/demo_full.webm
Binary file not shown.
Binary file modified examples/demo_time.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/demo_time.mp4
Binary file not shown.
4 changes: 3 additions & 1 deletion examples/demo_time.tape
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Set Theme "Builtin Solarized Light"
Set TypingSpeed 80ms
Set FontSize 22
Set Width 1800
Set Height 800
Set Height 1000

Hide
Type "vault-tasks -c ../.config/ -v ../test-vault time"
Enter
Show

# Time Management tab
Sleep 1s
Expand Down
1 change: 1 addition & 0 deletions examples/justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
make-all-vhs:
vhs < ./demo_explorer.tape
vhs < ./demo_filter.tape
vhs < ./demo_calendar.tape
vhs < ./demo_time.tape
git checkout HEAD -- ../test-vault/test.md # it is edited during explorer demo
vhs < ./demo_full.tape
Expand Down
5 changes: 5 additions & 0 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ pub enum Action {
Key(KeyEvent),
ReloadVault,
// Movements
GotoToday,
NextMonth,
PreviousMonth,
NextYear,
PreviousYear,
PreviousMethod,
NextMethod,
NextSegment,
Expand Down
7 changes: 5 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{
action::Action,
cli::{Cli, Commands},
components::{
explorer_tab::ExplorerTab, filter_tab::FilterTab, fps::FpsCounter, home::Home,
time_management_tab::TimeManagementTab, Component,
calendar_tab::CalendarTab, explorer_tab::ExplorerTab, filter_tab::FilterTab,
fps::FpsCounter, home::Home, time_management_tab::TimeManagementTab, Component,
},
config::Config,
tui::{Event, Tui},
Expand Down Expand Up @@ -41,6 +41,7 @@ pub enum Mode {
Explorer,
Filter,
TimeManagement,
Calendar,
}

impl App {
Expand All @@ -56,6 +57,7 @@ impl App {
Box::<FpsCounter>::default(),
Box::new(ExplorerTab::new()),
Box::new(FilterTab::new()),
Box::new(CalendarTab::new()),
Box::new(TimeManagementTab::new()),
],
should_quit: false,
Expand All @@ -72,6 +74,7 @@ impl App {
let tab = match args.command {
Some(Commands::Filter) => Action::Focus(Mode::Filter),
Some(Commands::TimeManagement) => Action::Focus(Mode::TimeManagement),
Some(Commands::Calendar) => Action::Focus(Mode::Calendar),
Some(Commands::Explorer | Commands::GenerateConfig { path: _ }) | None => {
Action::Focus(Mode::Explorer)
}
Expand Down
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub enum Commands {
/// Open Time Management view
#[command(alias = "time")]
TimeManagement,
/// Open Calendar view
#[command(alias = "cld")]
Calendar,
/// Generates a new configuration file from the default one
GenerateConfig { path: Option<PathBuf> },
/// Write tasks to STDOUT
Expand Down
1 change: 1 addition & 0 deletions src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
tui::{Event, Tui},
};

pub mod calendar_tab;
pub mod explorer_tab;
pub mod filter_tab;
pub mod fps;
Expand Down
Loading

0 comments on commit 20120cd

Please sign in to comment.