Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to Foci are documented here. The format follows [Keep a Chan
## [Unreleased]

### Fixed
- **Opening the Add/Edit Event dialog crashed the app** (`UnboundLocalError: y_offset`).
- Pressing <kbd>S</kbd> for stats crashed the app (`NameError: font_path`).
- **Packaged app lost all data on restart.** The one-file `.exe` wrote events, to-dos, settings and coins into PyInstaller's temporary extraction folder, which is deleted on exit. User data now lives in the OS app-data folder for packaged builds (`%APPDATA%\Foci` etc.) and stays in `assets/` when running from source.
- Launching `python path/to/main.py` from a different directory couldn't find fonts, icons or the coin sprite sheet. Resources now resolve relative to the app, not the working directory.
- "Schedule for Tomorrow" set the `tmr` tag and then immediately deleted it.
Expand All @@ -16,6 +18,8 @@ All notable changes to Foci are documented here. The format follows [Keep a Chan
- Packaged builds call `multiprocessing.freeze_support()` so the lofi player subprocess starts correctly.

### Added
- **Keyboard shortcuts** for to-dos (select, check off, schedule, add, delete) and calendar navigation, plus a <kbd>?</kbd> help overlay. Suggested by Fazal.
- **Three new themes**: Ocean Breeze, Lavender Dusk and Matcha Latte. Suggested by Anaconda bro.
- To-dos show a date pill (*Today*, *Tomorrow*, *on Mon*), red when overdue.
- `FOCI_DATA_DIR` environment variable to choose where data is stored.
- `foci_store.py`: persistence and validation split out of `main.py` so it can be tested.
Expand All @@ -24,6 +28,7 @@ All notable changes to Foci are documented here. The format follows [Keep a Chan

### Changed
- The built executable is named `Foci.exe` instead of `main.exe`.
- The <kbd>T</kbd> theme shortcut now remembers the chosen theme.

## [1.0.0] - initial release

Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Both files are git-ignored and must never be committed.
- **Windows SMTC integration** — registers with the system media flyout so track name appears in the tray and media keys (⏯ ⏭ ⏮) work system-wide

### Themes & fonts
- 8 built-in themes: **Serene Morning**, **Golden Hour**, **Midnight Deep**, **Cyberpunk Night**, **Forest Canopy**, **Classic Light**, **Classic Dark**, **Kyoto Spring**
- 11 built-in themes: **Serene Morning**, **Golden Hour**, **Midnight Deep**, **Cyberpunk Night**, **Forest Canopy**, **Classic Light**, **Classic Dark**, **Kyoto Spring**, and new in this release **Ocean Breeze**, **Lavender Dusk** and **Matcha Latte** (suggested by **Anaconda bro**)
- Several themes feature animated slow-wave gradient backgrounds
- Font picker scans `assets/` for any `.ttf` / `.otf` and previews them live (ships with Domine, Roboto, Arimo, SansCode, RobotoCondensed)

Expand All @@ -155,6 +155,24 @@ Both files are git-ignored and must never be committed.
### Stats
- Animated donut charts (ease-out cubic) showing tasks completed % and time focused % for the day

### Keyboard shortcuts
*Suggested by **Fazal**.* Press <kbd>?</kbd> in the app to see them all.

| Keys | Action |
|---|---|
| <kbd>↑</kbd> <kbd>↓</kbd> or <kbd>K</kbd> <kbd>J</kbd> | Select previous / next to-do (walks into open folders) |
| <kbd>Space</kbd> / <kbd>Enter</kbd> | Check off the selected to-do, or open / close a folder |
| <kbd>1</kbd> <kbd>2</kbd> <kbd>3</kbd> | Schedule for Today / Tomorrow / Someday |
| <kbd>N</kbd> | New to-do |
| <kbd>Delete</kbd> | Delete the selected to-do |
| <kbd>Esc</kbd> | Clear the selection |
| <kbd>←</kbd> <kbd>→</kbd> | Previous / next day (week, in weekly view) |
| <kbd>Home</kbd> | Jump to today |
| <kbd>W</kbd> | Toggle weekly view |
| <kbd>S</kbd> | Today's stats |
| <kbd>T</kbd> | Next theme |
| <kbd>?</kbd> / <kbd>H</kbd> | Show the shortcuts overlay |

### Weekly view
- 7-column overview with event cards per day; click a day to jump to it; today column is highlighted

Expand Down Expand Up @@ -195,6 +213,13 @@ The files in `assets/` are git-ignored. Copy an `*.example.json` to get started,

---

## Acknowledgements

Thanks to the people who've shaped Foci with their ideas:

- **Fazal**: suggested keyboard shortcuts for getting around tasks quickly
- **Anaconda bro**: suggested the Ocean Breeze, Lavender Dusk and Matcha Latte themes

## Contributing

Bug reports, ideas and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, the project layout and how to run the tests. Changes are tracked in [CHANGELOG.md](CHANGELOG.md).
Expand Down
70 changes: 70 additions & 0 deletions foci_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,73 @@ def todo_tag_label(item, today=None):
pass
labels = {"today": "Today", "tmr": "Tomorrow"}
return labels.get(tag, tag), overdue


# --- Keyboard navigation of the to-do tree ----------------------------------
# A "path" is a tuple of child indexes, e.g. (2,) is the third top-level item
# and (2, 0) is the first child of that folder.

def visible_todo_paths(items, prefix=()):
"""Paths of every row currently shown in the list, in display order.

Children are included only when their folder is open, so arrow-key
navigation matches what the user sees.
"""
paths = []
for i, item in enumerate(items):
path = prefix + (i,)
paths.append(path)
if item.get("type") == "folder" and item.get("is_open"):
paths.extend(visible_todo_paths(item.get("children", []), path))
return paths


def get_todo_at(items, path):
"""Return the item at ``path`` or ``None`` if the path no longer exists."""
if not path:
return None
current = None
siblings = items
for index in path:
if not isinstance(siblings, list) or not 0 <= index < len(siblings):
return None
current = siblings[index]
siblings = current.get("children") if current.get("type") == "folder" else None
return current


def remove_todo_at(items, path):
"""Remove and return the item at ``path`` (``None`` if it doesn't exist)."""
if get_todo_at(items, path) is None:
return None
parent = items if len(path) == 1 else get_todo_at(items, path[:-1])["children"]
return parent.pop(path[-1])


def move_selection(items, current, delta):
"""Move the keyboard selection ``delta`` rows up (-) or down (+).

With no (or a stale) selection, Down starts at the first row and Up at the
last. The selection stops at the ends instead of wrapping.
"""
paths = visible_todo_paths(items)
if not paths:
return None
if current not in paths:
return paths[0] if delta > 0 else paths[-1]
index = max(0, min(len(paths) - 1, paths.index(current) + delta))
return paths[index]


def clamp_selection(items, current):
"""Keep a selection valid after the list changes (e.g. a delete)."""
if current is None:
return None
paths = visible_todo_paths(items)
if not paths:
return None
if current in paths:
return current
# Fall back to the nearest row at or before where the old one was.
earlier = [p for p in paths if p < current]
return earlier[-1] if earlier else paths[0]
Loading
Loading