summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 10:16:24 +0300
committerGitHub <noreply@github.com>2025-06-20 10:16:24 +0300
commit81e8a4dcbf06c02c8b9df5be7a35a1da632048b0 (patch)
treeb457f19c9f2bf7503476ac63080e3d22a14e7053
parente1c235b796417681b16292d7c3bc1c52a5d92ce4 (diff)
parentc97fd4091adeaadbf6b42c5a01a57105438d774c (diff)
Merge pull request #18 from snonux/codex/fix-s-hotkey-behavior-and-update-ui
Improve task start/stop control
-rw-r--r--internal/ui/table.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go
index ed91187..73a53dd 100644
--- a/internal/ui/table.go
+++ b/internal/ui/table.go
@@ -50,7 +50,7 @@ func New(filter string) (Model, error) {
func newTable(rows []atable.Row) atable.Model {
cols := []atable.Column{
{Title: "ID", Width: 4},
- {Title: "Task", Width: 30},
+ {Title: "Task", Width: 45},
{Title: "Age", Width: 6},
{Title: "Pri", Width: 4},
{Title: "Tags", Width: 15},
@@ -137,14 +137,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "s":
if row := m.tbl.SelectedRow(); row != nil {
if id, err := strconv.Atoi(row[0]); err == nil {
- task.Start(id)
- m.reload()
- }
- }
- case "S":
- if row := m.tbl.SelectedRow(); row != nil {
- if id, err := strconv.Atoi(row[0]); err == nil {
- task.Stop(id)
+ idx := m.tbl.Cursor()
+ if idx >= 0 && idx < len(m.tasks) {
+ if m.tasks[idx].Start == "" {
+ task.Start(id)
+ } else {
+ task.Stop(id)
+ }
+ }
m.reload()
}
}
@@ -166,8 +166,7 @@ func (m Model) View() string {
return lipgloss.JoinVertical(lipgloss.Left,
m.tbl.HelpView(),
"E: edit task",
- "s: start task",
- "S: stop task",
+ "s: toggle start/stop",
"q: quit",
"?: help", // show help toggle line
)