Migrate table formatting to go-pretty for proper UTF-8 and ANSI handling

Replace manual string-based table formatting with jedib0t/go-pretty/v6/table
library to fix alignment issues with Norwegian characters (æøå) and ANSI
color codes.

Changes:
- Migrate FormatTaskList() to use go-pretty table
- Migrate FormatTaskDetail() to use clean table format
- Migrate FormatProjects() and FormatTagCounts() for consistency
- Remove truncate() function (no longer needed)
- Configure StyleLight with Unicode box-drawing characters
- Set proper column widths and alignment

Fixes:
- Priority column now center-aligned under 'Pri'
- Norwegian characters (æøå) display and align correctly
- Tags column properly aligned
- Description field truncates at 40 chars with proper UTF-8 handling
- All ANSI color codes handled automatically
- Consistent formatting across all table views

All existing color functions work unchanged. UTF-8 and ANSI codes are
handled automatically by go-pretty's width calculation.
This commit is contained in:
2026-01-05 13:41:46 +01:00
parent 1d55f04a1f
commit 9bde1aefea
3 changed files with 152 additions and 62 deletions
+11 -6
View File
@@ -2,26 +2,31 @@ module git.jnss.me/joakim/opal
go 1.25.5
require github.com/google/uuid v1.6.0
require (
github.com/fatih/color v1.18.0
github.com/google/uuid v1.6.0
github.com/jedib0t/go-pretty/v6 v6.7.8
github.com/mattn/go-sqlite3 v1.14.33
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
)
require (
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.33 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/spf13/viper v1.21.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.28.0 // indirect
)