diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 23:02:31 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 23:02:31 +0300 |
| commit | 8ef29dbc6a38ac2ad6dde713a622b1bcbc4f2ebb (patch) | |
| tree | 81a285d51cfa224d8b12f4d056f4981884c2c3af | |
| parent | f9cb77093a930c92c0d130d827148c518892e42c (diff) | |
| parent | 9c7b7f2f9be4cd453587f095b058a24402f7bf03 (diff) | |
Merge pull request #68 from snonux/codex/update-due-date-labels-and-reorder-columns
Implement custom due labels and column swap
| -rw-r--r-- | internal/ui/table.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go index 73971a1..92ad157 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -96,8 +96,8 @@ func newTable(rows []atable.Row) atable.Model { {Title: "ID", Width: 4}, {Title: "Pri", Width: 4}, {Title: "Age", Width: 6}, - {Title: "Due", Width: 10}, {Title: "Urg", Width: 5}, + {Title: "Due", Width: 10}, {Title: "Tags", Width: 15}, {Title: "Description", Width: 45}, {Title: "Annotations", Width: 20}, @@ -527,14 +527,17 @@ func taskToRow(t task.Task) atable.Row { style.Render(strconv.Itoa(t.ID)), formatPriority(t.Priority), style.Render(age), - formatDue(t.Due), style.Render(urg), + formatDue(t.Due), style.Render(tags), style.Render(t.Description), style.Render(strings.Join(anns, "; ")), } } +// formatDue returns a formatted due date string. Dates due today or tomorrow +// are returned as "today" or "tomorrow" respectively. Past due dates are +// highlighted in red. func formatDue(s string) string { if s == "" { return "" @@ -545,7 +548,15 @@ func formatDue(s string) string { } days := int(time.Until(ts).Hours() / 24) - val := fmt.Sprintf("%dd", days) + var val string + switch days { + case 0: + val = "today" + case 1: + val = "tomorrow" + default: + val = fmt.Sprintf("%dd", days) + } style := lipgloss.NewStyle() if days < 0 { style = style.Background(lipgloss.Color("1")) @@ -634,8 +645,8 @@ func taskToRowSearch(t task.Task, re *regexp.Regexp) atable.Row { idStr, priStr, ageStr, - dueStr, urgStr, + dueStr, tagStr, descStr, annStr, |
