diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-24 23:24:31 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-24 23:24:31 +0300 |
| commit | cfc9e9a45cbf517a833c1fbffda6ed5068d08454 (patch) | |
| tree | ee013ed633d9431e6211f22ef3894552ea2ae74e | |
| parent | dbfba814e68bd6b679b2fd77bf10d34336485238 (diff) | |
| parent | 60da6c59bcc58605bcc13609c855e32f045e9a1c (diff) | |
Merge pull request #92 from snonux/codex/add---disco-startup-flag-with-hotkey
Implement disco mode flag
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | cmd/tasksamurai/main.go | 3 | ||||
| -rw-r--r-- | internal/ui/table.go | 14 |
3 files changed, 22 insertions, 0 deletions
@@ -54,6 +54,7 @@ Task Samurai invokes the `task` command to read and modify tasks. The tasks are - `f`: change filter - `c`: random theme - `C`: reset theme +- `x`: toggle disco mode - `space`: refresh tasks - `H`: toggle help - `q` or `esc`: close search/help or quit (press `q` when nothing is open) @@ -79,3 +80,7 @@ go-task install ``` The second method requires [go-task](https://taskfile.dev/) to be installed. + +### Flags + +- `--disco`: start Task Samurai in disco mode, changing the theme every time a task is modified. diff --git a/cmd/tasksamurai/main.go b/cmd/tasksamurai/main.go index 8329fa1..42cbeb3 100644 --- a/cmd/tasksamurai/main.go +++ b/cmd/tasksamurai/main.go @@ -14,6 +14,7 @@ import ( func main() { debugLog := flag.String("debug-log", "", "path to debug log file") browserCmd := flag.String("browser-cmd", "firefox", "command used to open URLs") + disco := flag.Bool("disco", false, "enable disco mode") flag.Parse() if err := task.SetDebugLog(*debugLog); err != nil { @@ -27,6 +28,8 @@ func main() { os.Exit(1) } + m.SetDisco(*disco) + // Clear the screen before starting the TUI to avoid leaving any // previous command line artefacts behind. fmt.Print("\033[H\033[2J") diff --git a/internal/ui/table.go b/internal/ui/table.go index bac9f0b..d75f350 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -112,6 +112,7 @@ type Model struct { theme Theme defaultTheme Theme + disco bool } // editDoneMsg is emitted when the external editor process finishes. @@ -148,6 +149,10 @@ func (m *Model) startBlink(id int, markDone bool) tea.Cmd { if m.blinkRow == -1 { return nil } + if m.disco { + m.theme = RandomTheme() + m.applyTheme() + } m.blinkOn = true m.blinkCount = 0 m.updateBlinkRow() @@ -764,6 +769,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.theme = m.defaultTheme m.applyTheme() return m, nil + case "x": + m.disco = !m.disco + return m, nil case " ": m.reload() return m, nil @@ -904,6 +912,7 @@ func (m Model) View() string { "t: edit tags", "c: random theme", "C: reset theme", + "x: toggle disco mode", "space: refresh tasks", "/, ?: search", "n/N: next/prev search match", @@ -1406,6 +1415,11 @@ func (m *Model) applyTheme() { m.tbl.SetStyles(m.tblStyles) } +// SetDisco enables or disables disco mode. +func (m *Model) SetDisco(d bool) { + m.disco = d +} + func centerLines(s string, width int) string { lines := strings.Split(strings.TrimRight(s, "\n"), "\n") style := lipgloss.NewStyle().Width(width).Align(lipgloss.Center) |
