Compare commits
2 Commits
f0a3e0a568
...
6f77b03555
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f77b03555 | ||
|
|
f6ce2e30dc |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ tasksquire
|
||||
test/*.sqlite3*
|
||||
result
|
||||
main
|
||||
__debug*
|
||||
|
||||
25
.tmuxp.yaml
Normal file
25
.tmuxp.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
session_name: task
|
||||
start_directory: ./
|
||||
|
||||
windows:
|
||||
- window_name: code
|
||||
panes:
|
||||
- focus: 'true'
|
||||
shell_command: jj st
|
||||
- window_name: go
|
||||
panes:
|
||||
- focus: 'true'
|
||||
shell_command: clear
|
||||
- window_name: oc
|
||||
panes:
|
||||
- focus: 'true'
|
||||
shell_command: clear
|
||||
- window_name: v1
|
||||
start_directory: ../tasksquire_dev
|
||||
panes:
|
||||
- focus: 'true'
|
||||
shell_command: clear
|
||||
- window_name: sh
|
||||
panes:
|
||||
- focus: 'true'
|
||||
shell_command: clear
|
||||
18
flake.lock
generated
18
flake.lock
generated
@@ -5,11 +5,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1769996383,
|
||||
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
|
||||
"lastModified": 1777988971,
|
||||
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
|
||||
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1771848320,
|
||||
"narHash": "sha256-0MAd+0mun3K/Ns8JATeHT1sX28faLII5hVLq0L3BdZU=",
|
||||
"lastModified": 1777954456,
|
||||
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2fc6539b481e1d2569f25f8799236694180c0993",
|
||||
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -36,11 +36,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1769909678,
|
||||
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
|
||||
"lastModified": 1777168982,
|
||||
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "72716169fe93074c333e8d0173151350670b824c",
|
||||
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
37
go.mod
37
go.mod
@@ -1,28 +1,35 @@
|
||||
module tasksquire
|
||||
|
||||
go 1.25
|
||||
|
||||
toolchain go1.25.7
|
||||
go 1.26.2
|
||||
|
||||
require (
|
||||
charm.land/bubbles/v2 v2.0.0 // indirect
|
||||
charm.land/bubbletea/v2 v2.0.0 // indirect
|
||||
charm.land/lipgloss/v2 v2.0.0 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.4.2 // indirect
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.11.6 // indirect
|
||||
charm.land/bubbles/v2 v2.1.0
|
||||
charm.land/bubbletea/v2 v2.0.6
|
||||
charm.land/huh/v2 v2.0.3
|
||||
charm.land/lipgloss/v2 v2.0.3
|
||||
github.com/charmbracelet/x/ansi v0.11.7
|
||||
golang.org/x/term v0.43.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/atotto/clipboard v0.1.4 // indirect
|
||||
github.com/catppuccin/go v0.3.0 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260428153724-66037269d7be // indirect
|
||||
github.com/charmbracelet/x/exp/ordered v0.1.0 // indirect
|
||||
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
||||
github.com/charmbracelet/x/windows v0.2.2 // indirect
|
||||
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
||||
github.com/clipperhouse/stringish v0.1.1 // indirect
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.20 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.23 // indirect
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/term v0.40.0 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/sys v0.44.0 // indirect
|
||||
)
|
||||
|
||||
86
go.sum
86
go.sum
@@ -1,50 +1,68 @@
|
||||
charm.land/bubbles/v2 v2.0.0 h1:tE3eK/pHjmtrDiRdoC9uGNLgpopOd8fjhEe31B/ai5s=
|
||||
charm.land/bubbles/v2 v2.0.0/go.mod h1:rCHoleP2XhU8um45NTuOWBPNVHxnkXKTiZqcclL/qOI=
|
||||
charm.land/bubbletea/v2 v2.0.0 h1:p0d6CtWyJXJ9GfzMpUUqbP/XUUhhlk06+vCKWmox1wQ=
|
||||
charm.land/bubbletea/v2 v2.0.0/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ=
|
||||
charm.land/lipgloss/v2 v2.0.0 h1:sd8N/B3x892oiOjFfBQdXBQp3cAkvjGaU5TvVZC3ivo=
|
||||
charm.land/lipgloss/v2 v2.0.0/go.mod h1:w6SnmsBFBmEFBodiEDurGS/sdUY/u1+v72DqUzc6J14=
|
||||
github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=
|
||||
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
|
||||
github.com/charmbracelet/colorprofile v0.4.2 h1:BdSNuMjRbotnxHSfxy+PCSa4xAmz7szw70ktAtWRYrY=
|
||||
github.com/charmbracelet/colorprofile v0.4.2/go.mod h1:0rTi81QpwDElInthtrQ6Ni7cG0sDtwAd4C4le060fT8=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 h1:eyFRbAmexyt43hVfeyBofiGSEmJ7krjLOYt/9CF5NKA=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8/go.mod h1:SQpCTRNBtzJkwku5ye4S3HEuthAlGy2n9VXZnWkEW98=
|
||||
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
|
||||
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
|
||||
charm.land/bubbles/v2 v2.1.0 h1:YSnNh5cPYlYjPxRrzs5VEn3vwhtEn3jVGRBT3M7/I0g=
|
||||
charm.land/bubbles/v2 v2.1.0/go.mod h1:l97h4hym2hvWBVfmJDtrEHHCtkIKeTEb3TTJ4ZOB3wY=
|
||||
charm.land/bubbletea/v2 v2.0.6 h1:UHN/91OyuhaOFGSrBXQ/hMZD8IO1Uc4BvHlgHXL2WJo=
|
||||
charm.land/bubbletea/v2 v2.0.6/go.mod h1:MH/D8ZLlN3op37vQvijKuU29g3rqTp+aQapURFonF9g=
|
||||
charm.land/huh/v2 v2.0.3 h1:2cJsMqEPwSywGHvdlKsJyQKPtSJLVnFKyFbsYZTlLkU=
|
||||
charm.land/huh/v2 v2.0.3/go.mod h1:93eEveeeqn47MwiC3tf+2atZ2l7Is88rAtmZNZ8x9Wc=
|
||||
charm.land/lipgloss/v2 v2.0.3 h1:yM2zJ4Cf5Y51b7RHIwioil4ApI/aypFXXVHSwlM6RzU=
|
||||
charm.land/lipgloss/v2 v2.0.3/go.mod h1:7myLU9iG/3xluAWzpY/fSxYYHCgoKTie7laxk6ATwXA=
|
||||
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
|
||||
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
|
||||
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
|
||||
github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
|
||||
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
|
||||
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
|
||||
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
||||
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260428153724-66037269d7be h1:j7w8VP/D4lu5+/4GamMmFy8nrtadcl82/fjvDgSHwLo=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260428153724-66037269d7be/go.mod h1:3YdTxlnV/L0bQ3VN8WOSw8doF7LZV/xawUQ4MuAPDvo=
|
||||
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
|
||||
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
|
||||
github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs=
|
||||
github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk=
|
||||
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
|
||||
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=
|
||||
github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sBf+2agPBgnOFE=
|
||||
github.com/charmbracelet/x/exp/ordered v0.1.0/go.mod h1:5UHwmG+is5THxMyCJHNPCn2/ecI07aKNrW+LcResjJ8=
|
||||
github.com/charmbracelet/x/exp/strings v0.1.0 h1:i69S2XI7uG1u4NLGeJPSYU++Nmjvpo9nwd6aoEm7gkA=
|
||||
github.com/charmbracelet/x/exp/strings v0.1.0/go.mod h1:/ehtMPNh9K4odGFkqYJKpIYyePhdp1hLBRvyY4bWkH8=
|
||||
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
||||
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
||||
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
||||
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
|
||||
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
|
||||
github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA=
|
||||
github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA=
|
||||
github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw=
|
||||
github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y=
|
||||
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
|
||||
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
|
||||
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
|
||||
github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U=
|
||||
github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
|
||||
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mattn/go-runewidth v0.0.20 h1:WcT52H91ZUAwy8+HUkdM3THM6gXqXuLJi9O3rjcQQaQ=
|
||||
github.com/mattn/go-runewidth v0.0.20/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
|
||||
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
|
||||
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
|
||||
golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
|
||||
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
|
||||
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"image/color"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"tasksquire/internal/taskwarrior"
|
||||
|
||||
@@ -82,10 +84,10 @@ func NewStyles(config *taskwarrior.TWConfig) *Styles {
|
||||
styles.Base = lipgloss.NewStyle().Foreground(styles.Palette.Text.GetForeground())
|
||||
|
||||
styles.TableStyle = TableStyle{
|
||||
// Header: lipgloss.NewStyle().Bold(true).Padding(0, 1).BorderBottom(true),
|
||||
Cell: lipgloss.NewStyle().Padding(0, 1, 0, 0),
|
||||
Header: lipgloss.NewStyle().Bold(true).Padding(0, 1, 0, 0).Underline(true).Foreground(styles.Palette.Primary.GetForeground()),
|
||||
Selected: lipgloss.NewStyle().Bold(true).Reverse(true).Foreground(styles.Palette.Accent.GetForeground()),
|
||||
// Selected: lipgloss.NewStyle().Bold(true).Reverse(true).Foreground(styles.Palette.Accent.GetForeground()),
|
||||
Selected: lipgloss.NewStyle().Bold(true).Reverse(true),
|
||||
}
|
||||
|
||||
// formTheme := huh.ThemeBase()
|
||||
@@ -232,3 +234,77 @@ var colorStrings = map[string]int{
|
||||
"bright cyan": 14,
|
||||
"bright white": 15,
|
||||
}
|
||||
|
||||
func GetTaskTabelStyle(task *taskwarrior.Task, com Common) lipgloss.Style {
|
||||
if task.Status == "deleted" {
|
||||
if c, ok := com.Styles.Colors["deleted"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if task.Status == "completed" {
|
||||
if c, ok := com.Styles.Colors["completed"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if task.Status == "pending" && task.Start != "" {
|
||||
if c, ok := com.Styles.Colors["active"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
// TODO: implement keyword
|
||||
// TODO: implement tag
|
||||
if task.HasTag("next") {
|
||||
if c, ok := com.Styles.Colors["tag.next"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
// TODO: implement project
|
||||
if !task.GetDate("due").IsZero() && task.GetDate("due").Before(time.Now()) {
|
||||
if c, ok := com.Styles.Colors["overdue"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if task.Scheduled != "" {
|
||||
if c, ok := com.Styles.Colors["scheduled"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if !task.GetDate("due").IsZero() && task.GetDate("due").Truncate(24*time.Hour).Equal(time.Now().Truncate(24*time.Hour)) {
|
||||
if c, ok := com.Styles.Colors["due.today"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if task.Due != "" {
|
||||
if c, ok := com.Styles.Colors["due"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if len(task.Depends) > 0 {
|
||||
if c, ok := com.Styles.Colors["blocked"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
// TODO implement blocking
|
||||
if task.Recur != "" {
|
||||
if c, ok := com.Styles.Colors["recurring"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
// TODO: make styles optional and discard if empty
|
||||
if len(task.Tags) > 0 {
|
||||
if c, ok := com.Styles.Colors["tagged"]; ok && c != nil {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
if len(com.Udas) > 0 {
|
||||
for _, uda := range com.Udas {
|
||||
if u, ok := task.Udas[uda.Name]; ok {
|
||||
if c, ok := com.Styles.Colors[fmt.Sprintf("uda.%s.%s", uda.Name, u)]; ok {
|
||||
return c.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return com.Styles.Base.Inherit(com.Styles.TableStyle.Cell).Margin(com.Styles.TableStyle.Cell.GetMargin()).Padding(com.Styles.TableStyle.Cell.GetPadding())
|
||||
}
|
||||
|
||||
|
||||
34
internal/components/multiPageForm.go
Normal file
34
internal/components/multiPageForm.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
tea "charm.land/bubbletea/v2"
|
||||
"charm.land/huh/v2"
|
||||
)
|
||||
|
||||
type Page struct {
|
||||
form huh.Form
|
||||
}
|
||||
|
||||
type MultiPageForm struct {
|
||||
// pages []Page
|
||||
form huh.Form
|
||||
}
|
||||
|
||||
func NewMultiPageForm(form huh.Form) *MultiPageForm {
|
||||
return &MultiPageForm{
|
||||
form: form,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *MultiPageForm) Init() tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *MultiPageForm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
_, cmd := f.form.Update(msg)
|
||||
return f, cmd
|
||||
}
|
||||
|
||||
func (f *MultiPageForm) View() tea.View {
|
||||
return tea.NewView(f.form.View())
|
||||
}
|
||||
468
internal/components/table/table.go
Normal file
468
internal/components/table/table.go
Normal file
@@ -0,0 +1,468 @@
|
||||
// Package table provides a simple table component for Bubble Tea applications.
|
||||
package table
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"charm.land/bubbles/v2/help"
|
||||
"charm.land/bubbles/v2/key"
|
||||
"charm.land/bubbles/v2/viewport"
|
||||
tea "charm.land/bubbletea/v2"
|
||||
"charm.land/lipgloss/v2"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
)
|
||||
|
||||
// Model defines a state for the table widget.
|
||||
type Model struct {
|
||||
KeyMap KeyMap
|
||||
Help help.Model
|
||||
|
||||
cols []Column
|
||||
rows []Row
|
||||
rowStyles []lipgloss.Style
|
||||
cursor int
|
||||
focus bool
|
||||
styles Styles
|
||||
|
||||
viewport viewport.Model
|
||||
start int
|
||||
end int
|
||||
}
|
||||
|
||||
// Row represents one line in the table.
|
||||
type Row []string
|
||||
|
||||
// Column defines the table structure.
|
||||
type Column struct {
|
||||
Title string
|
||||
Width int
|
||||
}
|
||||
|
||||
// KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which
|
||||
// is used to render the help menu.
|
||||
type KeyMap struct {
|
||||
LineUp key.Binding
|
||||
LineDown key.Binding
|
||||
PageUp key.Binding
|
||||
PageDown key.Binding
|
||||
HalfPageUp key.Binding
|
||||
HalfPageDown key.Binding
|
||||
GotoTop key.Binding
|
||||
GotoBottom key.Binding
|
||||
}
|
||||
|
||||
// ShortHelp implements the KeyMap interface.
|
||||
func (km KeyMap) ShortHelp() []key.Binding {
|
||||
return []key.Binding{km.LineUp, km.LineDown}
|
||||
}
|
||||
|
||||
// FullHelp implements the KeyMap interface.
|
||||
func (km KeyMap) FullHelp() [][]key.Binding {
|
||||
return [][]key.Binding{
|
||||
{km.LineUp, km.LineDown, km.GotoTop, km.GotoBottom},
|
||||
{km.PageUp, km.PageDown, km.HalfPageUp, km.HalfPageDown},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultKeyMap returns a default set of keybindings.
|
||||
func DefaultKeyMap() KeyMap {
|
||||
return KeyMap{
|
||||
LineUp: key.NewBinding(
|
||||
key.WithKeys("up", "k"),
|
||||
key.WithHelp("↑/k", "up"),
|
||||
),
|
||||
LineDown: key.NewBinding(
|
||||
key.WithKeys("down", "j"),
|
||||
key.WithHelp("↓/j", "down"),
|
||||
),
|
||||
PageUp: key.NewBinding(
|
||||
key.WithKeys("b", "pgup"),
|
||||
key.WithHelp("b/pgup", "page up"),
|
||||
),
|
||||
PageDown: key.NewBinding(
|
||||
key.WithKeys("f", "pgdown", "space"),
|
||||
key.WithHelp("f/pgdn", "page down"),
|
||||
),
|
||||
HalfPageUp: key.NewBinding(
|
||||
key.WithKeys("u", "ctrl+u"),
|
||||
key.WithHelp("u", "½ page up"),
|
||||
),
|
||||
HalfPageDown: key.NewBinding(
|
||||
key.WithKeys("d", "ctrl+d"),
|
||||
key.WithHelp("d", "½ page down"),
|
||||
),
|
||||
GotoTop: key.NewBinding(
|
||||
key.WithKeys("home", "g"),
|
||||
key.WithHelp("g/home", "go to start"),
|
||||
),
|
||||
GotoBottom: key.NewBinding(
|
||||
key.WithKeys("end", "G"),
|
||||
key.WithHelp("G/end", "go to end"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Styles contains style definitions for this list component. By default, these
|
||||
// values are generated by DefaultStyles.
|
||||
type Styles struct {
|
||||
Header lipgloss.Style
|
||||
Cell lipgloss.Style
|
||||
Selected lipgloss.Style
|
||||
}
|
||||
|
||||
// DefaultStyles returns a set of default style definitions for this table.
|
||||
func DefaultStyles() Styles {
|
||||
return Styles{
|
||||
Selected: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("212")),
|
||||
Header: lipgloss.NewStyle().Bold(true).Padding(0, 1),
|
||||
Cell: lipgloss.NewStyle().Padding(0, 1),
|
||||
}
|
||||
}
|
||||
|
||||
// SetStyles sets the table styles.
|
||||
func (m *Model) SetStyles(s Styles) {
|
||||
m.styles = s
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// Option is used to set options in New. For example:
|
||||
//
|
||||
// table := New(WithColumns([]Column{{Title: "ID", Width: 10}}))
|
||||
type Option func(*Model)
|
||||
|
||||
// New creates a new model for the table widget.
|
||||
func New(opts ...Option) Model {
|
||||
m := Model{
|
||||
cursor: 0,
|
||||
viewport: viewport.New(viewport.WithHeight(20)), //nolint:mnd
|
||||
|
||||
KeyMap: DefaultKeyMap(),
|
||||
Help: help.New(),
|
||||
styles: DefaultStyles(),
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(&m)
|
||||
}
|
||||
|
||||
m.UpdateViewport()
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// WithColumns sets the table columns (headers).
|
||||
func WithColumns(cols []Column) Option {
|
||||
return func(m *Model) {
|
||||
m.cols = cols
|
||||
}
|
||||
}
|
||||
|
||||
// WithRows sets the table rows (data).
|
||||
func WithRows(rows []Row) Option {
|
||||
return func(m *Model) {
|
||||
m.rows = rows
|
||||
}
|
||||
}
|
||||
|
||||
// WithRowStyles sets the per row styles
|
||||
func WithRowStyles(styles []lipgloss.Style) Option {
|
||||
return func(m *Model) {
|
||||
m.rowStyles = styles
|
||||
}
|
||||
}
|
||||
|
||||
// WithHeight sets the height of the table.
|
||||
func WithHeight(h int) Option {
|
||||
return func(m *Model) {
|
||||
m.viewport.SetHeight(h - lipgloss.Height(m.headersView()))
|
||||
}
|
||||
}
|
||||
|
||||
// WithWidth sets the width of the table.
|
||||
func WithWidth(w int) Option {
|
||||
return func(m *Model) {
|
||||
m.viewport.SetWidth(w)
|
||||
}
|
||||
}
|
||||
|
||||
// WithFocused sets the focus state of the table.
|
||||
func WithFocused(f bool) Option {
|
||||
return func(m *Model) {
|
||||
m.focus = f
|
||||
}
|
||||
}
|
||||
|
||||
// WithStyles sets the table styles.
|
||||
func WithStyles(s Styles) Option {
|
||||
return func(m *Model) {
|
||||
m.styles = s
|
||||
}
|
||||
}
|
||||
|
||||
// WithKeyMap sets the key map.
|
||||
func WithKeyMap(km KeyMap) Option {
|
||||
return func(m *Model) {
|
||||
m.KeyMap = km
|
||||
}
|
||||
}
|
||||
|
||||
// Update is the Bubble Tea update loop.
|
||||
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
if !m.focus {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyPressMsg:
|
||||
switch {
|
||||
case key.Matches(msg, m.KeyMap.LineUp):
|
||||
m.MoveUp(1)
|
||||
case key.Matches(msg, m.KeyMap.LineDown):
|
||||
m.MoveDown(1)
|
||||
case key.Matches(msg, m.KeyMap.PageUp):
|
||||
m.MoveUp(m.viewport.Height())
|
||||
case key.Matches(msg, m.KeyMap.PageDown):
|
||||
m.MoveDown(m.viewport.Height())
|
||||
case key.Matches(msg, m.KeyMap.HalfPageUp):
|
||||
m.MoveUp(m.viewport.Height() / 2) //nolint:mnd
|
||||
case key.Matches(msg, m.KeyMap.HalfPageDown):
|
||||
m.MoveDown(m.viewport.Height() / 2) //nolint:mnd
|
||||
case key.Matches(msg, m.KeyMap.GotoTop):
|
||||
m.GotoTop()
|
||||
case key.Matches(msg, m.KeyMap.GotoBottom):
|
||||
m.GotoBottom()
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Focused returns the focus state of the table.
|
||||
func (m Model) Focused() bool {
|
||||
return m.focus
|
||||
}
|
||||
|
||||
// Focus focuses the table, allowing the user to move around the rows and
|
||||
// interact.
|
||||
func (m *Model) Focus() {
|
||||
m.focus = true
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// Blur blurs the table, preventing selection or movement.
|
||||
func (m *Model) Blur() {
|
||||
m.focus = false
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// View renders the component.
|
||||
func (m Model) View() string {
|
||||
return m.headersView() + "\n" + m.viewport.View()
|
||||
}
|
||||
|
||||
// HelpView is a helper method for rendering the help menu from the keymap.
|
||||
// Note that this view is not rendered by default and you must call it
|
||||
// manually in your application, where applicable.
|
||||
func (m Model) HelpView() string {
|
||||
return m.Help.View(m.KeyMap)
|
||||
}
|
||||
|
||||
// UpdateViewport updates the list content based on the previously defined
|
||||
// columns and rows.
|
||||
func (m *Model) UpdateViewport() {
|
||||
renderedRows := make([]string, 0, len(m.rows))
|
||||
|
||||
// Render only rows from: m.cursor-m.viewport.Height to: m.cursor+m.viewport.Height
|
||||
// Constant runtime, independent of number of rows in a table.
|
||||
// Limits the number of renderedRows to a maximum of 2*m.viewport.Height
|
||||
if m.cursor >= 0 {
|
||||
m.start = clamp(m.cursor-m.viewport.Height(), 0, m.cursor)
|
||||
} else {
|
||||
m.start = 0
|
||||
}
|
||||
m.end = clamp(m.cursor+m.viewport.Height(), m.cursor, len(m.rows))
|
||||
for i := m.start; i < m.end; i++ {
|
||||
renderedRows = append(renderedRows, m.renderRow(i))
|
||||
}
|
||||
|
||||
m.viewport.SetContent(
|
||||
lipgloss.JoinVertical(lipgloss.Left, renderedRows...),
|
||||
)
|
||||
}
|
||||
|
||||
// SelectedRow returns the selected row.
|
||||
// You can cast it to your own implementation.
|
||||
func (m Model) SelectedRow() Row {
|
||||
if m.cursor < 0 || m.cursor >= len(m.rows) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return m.rows[m.cursor]
|
||||
}
|
||||
|
||||
// Rows returns the current rows.
|
||||
func (m Model) Rows() []Row {
|
||||
return m.rows
|
||||
}
|
||||
|
||||
// Columns returns the current columns.
|
||||
func (m Model) Columns() []Column {
|
||||
return m.cols
|
||||
}
|
||||
|
||||
// SetRows sets a new rows state.
|
||||
func (m *Model) SetRows(r []Row) {
|
||||
m.rows = r
|
||||
|
||||
if m.cursor > len(m.rows)-1 {
|
||||
m.cursor = len(m.rows) - 1
|
||||
}
|
||||
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// SetColumns sets a new columns state.
|
||||
func (m *Model) SetColumns(c []Column) {
|
||||
m.cols = c
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// SetWidth sets the width of the viewport of the table.
|
||||
func (m *Model) SetWidth(w int) {
|
||||
m.viewport.SetWidth(w)
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// SetHeight sets the height of the viewport of the table.
|
||||
func (m *Model) SetHeight(h int) {
|
||||
m.viewport.SetHeight(h - lipgloss.Height(m.headersView()))
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// Height returns the viewport height of the table.
|
||||
func (m Model) Height() int {
|
||||
return m.viewport.Height()
|
||||
}
|
||||
|
||||
// Width returns the viewport width of the table.
|
||||
func (m Model) Width() int {
|
||||
return m.viewport.Width()
|
||||
}
|
||||
|
||||
// Cursor returns the index of the selected row.
|
||||
func (m Model) Cursor() int {
|
||||
return m.cursor
|
||||
}
|
||||
|
||||
// SetCursor sets the cursor position in the table.
|
||||
func (m *Model) SetCursor(n int) {
|
||||
m.cursor = clamp(n, 0, len(m.rows)-1)
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// MoveUp moves the selection up by any number of rows.
|
||||
// It can not go above the first row.
|
||||
func (m *Model) MoveUp(n int) {
|
||||
m.cursor = clamp(m.cursor-n, 0, len(m.rows)-1)
|
||||
|
||||
offset := m.viewport.YOffset()
|
||||
switch {
|
||||
case m.start == 0:
|
||||
offset = clamp(offset, 0, m.cursor)
|
||||
case m.start < m.viewport.Height():
|
||||
offset = clamp(clamp(offset+n, 0, m.cursor), 0, m.viewport.Height())
|
||||
case offset >= 1:
|
||||
offset = clamp(offset+n, 1, m.viewport.Height())
|
||||
}
|
||||
m.viewport.SetYOffset(offset)
|
||||
m.UpdateViewport()
|
||||
}
|
||||
|
||||
// MoveDown moves the selection down by any number of rows.
|
||||
// It can not go below the last row.
|
||||
func (m *Model) MoveDown(n int) {
|
||||
m.cursor = clamp(m.cursor+n, 0, len(m.rows)-1)
|
||||
m.UpdateViewport()
|
||||
|
||||
offset := m.viewport.YOffset()
|
||||
switch {
|
||||
case m.end == len(m.rows) && offset > 0:
|
||||
offset = clamp(offset-n, 1, m.viewport.Height())
|
||||
case m.cursor > (m.end-m.start)/2 && offset > 0:
|
||||
offset = clamp(offset-n, 1, m.cursor)
|
||||
case offset > 1:
|
||||
case m.cursor > offset+m.viewport.Height()-1:
|
||||
offset = clamp(offset+1, 0, 1)
|
||||
}
|
||||
m.viewport.SetYOffset(offset)
|
||||
}
|
||||
|
||||
// GotoTop moves the selection to the first row.
|
||||
func (m *Model) GotoTop() {
|
||||
m.MoveUp(m.cursor)
|
||||
}
|
||||
|
||||
// GotoBottom moves the selection to the last row.
|
||||
func (m *Model) GotoBottom() {
|
||||
m.MoveDown(len(m.rows))
|
||||
}
|
||||
|
||||
// FromValues create the table rows from a simple string. It uses `\n` by
|
||||
// default for getting all the rows and the given separator for the fields on
|
||||
// each row.
|
||||
func (m *Model) FromValues(value, separator string) {
|
||||
rows := []Row{} //nolint:prealloc
|
||||
for _, line := range strings.Split(value, "\n") {
|
||||
r := Row{}
|
||||
for _, field := range strings.Split(line, separator) {
|
||||
r = append(r, field)
|
||||
}
|
||||
rows = append(rows, r)
|
||||
}
|
||||
|
||||
m.SetRows(rows)
|
||||
}
|
||||
|
||||
func (m Model) headersView() string {
|
||||
s := make([]string, 0, len(m.cols))
|
||||
for _, col := range m.cols {
|
||||
if col.Width <= 0 {
|
||||
continue
|
||||
}
|
||||
style := lipgloss.NewStyle().Width(col.Width).MaxWidth(col.Width).Inline(true)
|
||||
renderedCell := style.Render(ansi.Truncate(col.Title, col.Width, "…"))
|
||||
s = append(s, m.styles.Header.Render(renderedCell))
|
||||
}
|
||||
return lipgloss.JoinHorizontal(lipgloss.Top, s...)
|
||||
}
|
||||
|
||||
func (m *Model) renderRow(r int) string {
|
||||
s := make([]string, 0, len(m.cols))
|
||||
for i, value := range m.rows[r] {
|
||||
if m.cols[i].Width <= 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
style := lipgloss.NewStyle().
|
||||
Width(m.cols[i].Width + m.styles.Cell.GetHorizontalPadding()).
|
||||
MaxWidth(m.cols[i].Width + m.styles.Cell.GetHorizontalPadding()).
|
||||
Inherit(m.rowStyles[r]).
|
||||
Inherit(m.styles.Cell).
|
||||
Inline(true)
|
||||
|
||||
if r == m.cursor {
|
||||
style = style.Inherit(m.styles.Selected)
|
||||
}
|
||||
|
||||
renderedCell := style.Render(ansi.Truncate(value, m.cols[i].Width, "…"))
|
||||
s = append(s, renderedCell)
|
||||
}
|
||||
|
||||
row := lipgloss.JoinHorizontal(lipgloss.Top, s...)
|
||||
|
||||
return row
|
||||
}
|
||||
|
||||
func clamp(v, low, high int) int {
|
||||
return min(max(v, low), high)
|
||||
}
|
||||
80
internal/components/table/table_test.go
Normal file
80
internal/components/table/table_test.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package table
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"charm.land/lipgloss/v2"
|
||||
)
|
||||
|
||||
func TestRenderRowSelection(t *testing.T) {
|
||||
cols := []Column{
|
||||
{Title: "ID", Width: 5},
|
||||
{Title: "Task", Width: 10},
|
||||
}
|
||||
rows := []Row{
|
||||
{"1", "Task 1"},
|
||||
{"2", "Task 2"},
|
||||
}
|
||||
|
||||
m := New(
|
||||
WithColumns(cols),
|
||||
WithRows(rows),
|
||||
WithStyles(Styles{
|
||||
Cell: lipgloss.NewStyle().Padding(0, 1),
|
||||
Selected: lipgloss.NewStyle().Background(lipgloss.Color("212")),
|
||||
}),
|
||||
)
|
||||
|
||||
m.SetWidth(30)
|
||||
m.SetCursor(0)
|
||||
|
||||
rendered := m.renderRow(0)
|
||||
|
||||
// The rendered row should contain the background color 212
|
||||
// AND the background should be present in the padding area.
|
||||
// Since we are using lipgloss, we check for the color code.
|
||||
if !strings.Contains(rendered, "212") {
|
||||
t.Errorf("expected rendered row to contain background color 212, got %s", rendered)
|
||||
}
|
||||
|
||||
// Verify it has the full width
|
||||
if lipgloss.Width(rendered) != 30 {
|
||||
t.Errorf("expected width 30, got %d", lipgloss.Width(rendered))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderRowOutOfBounds(t *testing.T) {
|
||||
cols := []Column{
|
||||
{Title: "ID", Width: 5},
|
||||
}
|
||||
rows := []Row{
|
||||
{"1", "Task 1 Extra Column"},
|
||||
}
|
||||
|
||||
m := New(
|
||||
WithColumns(cols),
|
||||
WithRows(rows),
|
||||
)
|
||||
|
||||
// This should not panic
|
||||
m.renderRow(0)
|
||||
}
|
||||
|
||||
func TestRenderRowNoStyles(t *testing.T) {
|
||||
cols := []Column{
|
||||
{Title: "ID", Width: 5},
|
||||
}
|
||||
rows := []Row{
|
||||
{"1"},
|
||||
}
|
||||
|
||||
m := New(
|
||||
WithColumns(cols),
|
||||
WithRows(rows),
|
||||
)
|
||||
m.rowStyles = nil // Ensure rowStyles is nil
|
||||
|
||||
// This should not panic
|
||||
m.renderRow(0)
|
||||
}
|
||||
1043
internal/components/taskEditor.go
Normal file
1043
internal/components/taskEditor.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,8 @@ package pages
|
||||
import (
|
||||
"tasksquire/internal/common"
|
||||
|
||||
"charm.land/bubbles/v2/key"
|
||||
tea "charm.land/bubbletea/v2"
|
||||
// "charm.land/bubbles/v2/key"
|
||||
"charm.land/lipgloss/v2"
|
||||
)
|
||||
|
||||
@@ -34,53 +34,48 @@ func NewMainPage(common *common.Common) *MainPage {
|
||||
}
|
||||
|
||||
func (m *MainPage) Init() tea.Cmd {
|
||||
return tea.Batch(m.taskPage.Init())
|
||||
// return tea.Batch(m.taskPage.Init(), m.timePage.Init())
|
||||
return tea.Batch()
|
||||
}
|
||||
|
||||
func (m *MainPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmd tea.Cmd
|
||||
|
||||
// switch msg := msg.(type) {
|
||||
// case tea.WindowSizeMsg:
|
||||
// m.width = msg.Width
|
||||
// m.height = msg.Height
|
||||
// m.common.SetSize(msg.Width, msg.Height)
|
||||
//
|
||||
// tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
// contentHeight := msg.Height - tabHeight
|
||||
// if contentHeight < 0 {
|
||||
// contentHeight = 0
|
||||
// }
|
||||
//
|
||||
// newMsg := tea.WindowSizeMsg{Width: msg.Width, Height: contentHeight}
|
||||
// activePage, cmd := m.activePage.Update(newMsg)
|
||||
// m.activePage = activePage.(common.Component)
|
||||
// return m, cmd
|
||||
//
|
||||
// case tea.KeyMsg:
|
||||
// // Only handle tab key for page switching when at the top level (no subpages active)
|
||||
// if key.Matches(msg, m.common.Keymap.Next) && !m.common.HasSubpages() {
|
||||
// if m.activePage == m.taskPage {
|
||||
// m.activePage = m.timePage
|
||||
// m.currentTab = 1
|
||||
// } else {
|
||||
// m.activePage = m.taskPage
|
||||
// m.currentTab = 0
|
||||
// }
|
||||
//
|
||||
// tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
// contentHeight := m.height - tabHeight
|
||||
// if contentHeight < 0 {
|
||||
// contentHeight = 0
|
||||
// }
|
||||
// m.activePage.SetSize(m.width, contentHeight)
|
||||
//
|
||||
// // Trigger a refresh/init on switch? Maybe not needed if we keep state.
|
||||
// // But we might want to refresh data.
|
||||
// return m, m.activePage.Init()
|
||||
// }
|
||||
// }
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.width = msg.Width
|
||||
m.height = msg.Height
|
||||
m.common.SetSize(msg.Width, msg.Height)
|
||||
|
||||
tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
contentHeight := max(msg.Height-tabHeight, 0)
|
||||
|
||||
newMsg := tea.WindowSizeMsg{Width: msg.Width, Height: contentHeight}
|
||||
activePage, cmd := m.activePage.Update(newMsg)
|
||||
m.activePage = activePage.(common.Component)
|
||||
return m, cmd
|
||||
|
||||
case tea.KeyMsg:
|
||||
// Only handle tab key for page switching when at the top level (no subpages active)
|
||||
if key.Matches(msg, m.common.Keymap.Next) && !m.common.HasSubpages() {
|
||||
// if m.activePage == m.taskPage {
|
||||
// m.activePage = m.timePage
|
||||
// m.currentTab = 1
|
||||
// } else {
|
||||
// m.activePage = m.taskPage
|
||||
// m.currentTab = 0
|
||||
// }
|
||||
//
|
||||
tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
contentHeight := m.height - tabHeight
|
||||
if contentHeight < 0 {
|
||||
contentHeight = 0
|
||||
}
|
||||
m.activePage.SetSize(m.width, contentHeight)
|
||||
|
||||
return m, m.activePage.Init()
|
||||
}
|
||||
}
|
||||
//
|
||||
activePage, cmd := m.activePage.Update(msg)
|
||||
m.activePage = activePage.(common.Component)
|
||||
@@ -105,7 +100,7 @@ func (m *MainPage) renderTabBar() string {
|
||||
}
|
||||
|
||||
func (m *MainPage) View() tea.View {
|
||||
v := tea.NewView(lipgloss.JoinVertical(lipgloss.Left, m.renderTabBar(), m.activePage.View().Content))
|
||||
v := tea.NewView(lipgloss.NewStyle().Margin(1, 3).Render(lipgloss.JoinVertical(lipgloss.Left, m.renderTabBar(), m.activePage.View().Content)))
|
||||
v.AltScreen = true
|
||||
return v
|
||||
// return lipgloss.JoinVertical(lipgloss.Left, m.renderTabBar(), m.activePage.View())
|
||||
|
||||
@@ -3,12 +3,12 @@ package pages
|
||||
|
||||
import (
|
||||
"tasksquire/internal/common"
|
||||
"tasksquire/internal/components/tasktable"
|
||||
"tasksquire/internal/components/table"
|
||||
"tasksquire/internal/taskwarrior"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
// "charm.land/lipgloss/v2"
|
||||
"charm.land/bubbles/v2/key"
|
||||
tea "charm.land/bubbletea/v2"
|
||||
"charm.land/lipgloss/v2"
|
||||
)
|
||||
|
||||
type TaskPage struct {
|
||||
@@ -22,7 +22,7 @@ type TaskPage struct {
|
||||
|
||||
tasks taskwarrior.Tasks
|
||||
|
||||
taskTable tasktable.Model
|
||||
taskTable table.Model
|
||||
|
||||
// Details panel state
|
||||
// detailsPanelActive bool
|
||||
@@ -33,11 +33,11 @@ type TaskPage struct {
|
||||
|
||||
func NewTaskPage(com *common.Common, report *taskwarrior.Report) *TaskPage {
|
||||
p := &TaskPage{
|
||||
common: com,
|
||||
activeReport: report,
|
||||
activeContext: com.TW.GetActiveContext(),
|
||||
activeProject: "",
|
||||
taskTable: tasktable.New(),
|
||||
common: com,
|
||||
activeReport: report,
|
||||
activeContext: com.TW.GetActiveContext(),
|
||||
activeProject: "",
|
||||
taskTable: table.New(),
|
||||
// detailsPanelActive: false,
|
||||
// detailsViewer: detailsviewer.New(com),
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func (p *TaskPage) SetSize(width int, height int) {
|
||||
// // Set component size (component handles its own border/padding)
|
||||
// // p.detailsViewer.SetSize(baseWidth, detailsHeight)
|
||||
// } else {
|
||||
tableHeight = baseHeight
|
||||
tableHeight = baseHeight
|
||||
// }
|
||||
|
||||
p.taskTable.SetWidth(baseWidth)
|
||||
@@ -75,178 +75,178 @@ func (p *TaskPage) Init() tea.Cmd {
|
||||
func (p *TaskPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmds []tea.Cmd
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
p.SetSize(msg.Width, msg.Height)
|
||||
// case BackMsg:
|
||||
case common.TickMsg:
|
||||
cmds = append(cmds, p.getTasks())
|
||||
cmds = append(cmds, common.DoTick())
|
||||
return p, tea.Batch(cmds...)
|
||||
case common.TaskMsg:
|
||||
p.tasks = taskwarrior.Tasks(msg)
|
||||
// case UpdateReportMsg:
|
||||
// p.activeReport = msg
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case UpdateContextMsg:
|
||||
// p.activeContext = msg
|
||||
// p.common.TW.SetContext(msg)
|
||||
// p.populateTaskTable(p.tasks)
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case UpdateProjectMsg:
|
||||
// p.activeProject = string(msg)
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case TaskPickedMsg:
|
||||
// if msg.Task != nil && msg.Task.Status == "pending" {
|
||||
// p.common.TW.StopActiveTasks()
|
||||
// p.common.TW.StartTask(msg.Task)
|
||||
// }
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case UpdatedTasksMsg:
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
case tea.KeyPressMsg:
|
||||
// Handle ESC when details panel is active
|
||||
// if p.detailsPanelActive && key.Matches(msg, p.common.Keymap.Back) {
|
||||
// p.detailsPanelActive = false
|
||||
// p.detailsViewer.Blur()
|
||||
// p.SetSize(p.common.Width(), p.common.Height())
|
||||
// return p, nil
|
||||
// }
|
||||
case tea.WindowSizeMsg:
|
||||
p.SetSize(msg.Width, msg.Height)
|
||||
// case BackMsg:
|
||||
case common.TickMsg:
|
||||
cmds = append(cmds, p.getTasks())
|
||||
cmds = append(cmds, common.DoTick())
|
||||
return p, tea.Batch(cmds...)
|
||||
case common.TaskMsg:
|
||||
p.tasks = taskwarrior.Tasks(msg)
|
||||
p.populateTaskTable(p.tasks)
|
||||
// case UpdateReportMsg:
|
||||
// p.activeReport = msg
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case UpdateContextMsg:
|
||||
// p.activeContext = msg
|
||||
// p.common.TW.SetContext(msg)
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case UpdateProjectMsg:
|
||||
// p.activeProject = string(msg)
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case TaskPickedMsg:
|
||||
// if msg.Task != nil && msg.Task.Status == "pending" {
|
||||
// p.common.TW.StopActiveTasks()
|
||||
// p.common.TW.StartTask(msg.Task)
|
||||
// }
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
// case UpdatedTasksMsg:
|
||||
// cmds = append(cmds, p.getTasks())
|
||||
case tea.KeyPressMsg:
|
||||
// Handle ESC when details panel is active
|
||||
// if p.detailsPanelActive && key.Matches(msg, p.common.Keymap.Back) {
|
||||
// p.detailsPanelActive = false
|
||||
// p.detailsViewer.Blur()
|
||||
// p.SetSize(p.common.Width(), p.common.Height())
|
||||
// return p, nil
|
||||
// }
|
||||
|
||||
switch {
|
||||
case key.Matches(msg, p.common.Keymap.Quit):
|
||||
return p, tea.Quit
|
||||
}
|
||||
// case key.Matches(msg, p.common.Keymap.SetReport):
|
||||
// p.subpage = NewReportPickerPage(p.common, p.activeReport)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.SetContext):
|
||||
// p.subpage = NewContextPickerPage(p.common)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Add):
|
||||
// p.subpage = NewTaskEditorPage(p.common, taskwarrior.NewTask())
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Edit):
|
||||
// p.subpage = NewTaskEditorPage(p.common, *p.selectedTask)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Subtask):
|
||||
// if p.selectedTask != nil {
|
||||
// // Create new task inheriting parent's attributes
|
||||
// newTask := taskwarrior.NewTask()
|
||||
//
|
||||
// // Set parent relationship
|
||||
// newTask.Parent = p.selectedTask.Uuid
|
||||
//
|
||||
// // Copy parent's attributes
|
||||
// newTask.Project = p.selectedTask.Project
|
||||
// newTask.Priority = p.selectedTask.Priority
|
||||
// newTask.Tags = make([]string, len(p.selectedTask.Tags))
|
||||
// copy(newTask.Tags, p.selectedTask.Tags)
|
||||
//
|
||||
// // Copy UDAs (except "details" which is task-specific)
|
||||
// if p.selectedTask.Udas != nil {
|
||||
// newTask.Udas = make(map[string]any)
|
||||
// for k, v := range p.selectedTask.Udas {
|
||||
// // Skip "details" UDA - it's specific to parent task
|
||||
// if k == "details" {
|
||||
// continue
|
||||
// }
|
||||
// // Deep copy other UDA values
|
||||
// newTask.Udas[k] = v
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Open task editor with pre-populated task
|
||||
// p.subpage = NewTaskEditorPage(p.common, newTask)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// }
|
||||
// return p, nil
|
||||
// case key.Matches(msg, p.common.Keymap.Ok):
|
||||
// p.common.TW.SetTaskDone(p.selectedTask)
|
||||
// return p, p.getTasks()
|
||||
// case key.Matches(msg, p.common.Keymap.Delete):
|
||||
// p.common.TW.DeleteTask(p.selectedTask)
|
||||
// return p, p.getTasks()
|
||||
// case key.Matches(msg, p.common.Keymap.SetProject):
|
||||
// p.subpage = NewProjectPickerPage(p.common, p.activeProject)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.PickProjectTask):
|
||||
// p.subpage = NewProjectTaskPickerPage(p.common)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Tag):
|
||||
// if p.selectedTask != nil {
|
||||
// tag := p.common.TW.GetConfig().Get("uda.tasksquire.tag.default")
|
||||
// if p.selectedTask.HasTag(tag) {
|
||||
// p.selectedTask.RemoveTag(tag)
|
||||
// } else {
|
||||
// p.selectedTask.AddTag(tag)
|
||||
// }
|
||||
// p.common.TW.ImportTask(p.selectedTask)
|
||||
// return p, p.getTasks()
|
||||
// }
|
||||
// return p, nil
|
||||
// case key.Matches(msg, p.common.Keymap.Undo):
|
||||
// p.common.TW.Undo()
|
||||
// return p, p.getTasks()
|
||||
// case key.Matches(msg, p.common.Keymap.StartStop):
|
||||
// if p.selectedTask != nil && p.selectedTask.Status == "pending" {
|
||||
// if p.selectedTask.Start == "" {
|
||||
// p.common.TW.StopActiveTasks()
|
||||
// p.common.TW.StartTask(p.selectedTask)
|
||||
// } else {
|
||||
// p.common.TW.StopTask(p.selectedTask)
|
||||
// }
|
||||
// return p, p.getTasks()
|
||||
// }
|
||||
// case key.Matches(msg, p.common.Keymap.ViewDetails):
|
||||
// if p.selectedTask != nil {
|
||||
// // Toggle details panel
|
||||
// p.detailsPanelActive = !p.detailsPanelActive
|
||||
// if p.detailsPanelActive {
|
||||
// p.detailsViewer.SetTask(p.selectedTask)
|
||||
// p.detailsViewer.Focus()
|
||||
// } else {
|
||||
// p.detailsViewer.Blur()
|
||||
// }
|
||||
// p.SetSize(p.common.Width(), p.common.Height())
|
||||
// return p, nil
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// var cmd tea.Cmd
|
||||
//
|
||||
// // Route keyboard messages to details viewer when panel is active
|
||||
// if p.detailsPanelActive {
|
||||
// var viewerCmd tea.Cmd
|
||||
// var viewerModel tea.Model
|
||||
// viewerModel, viewerCmd = p.detailsViewer.Update(msg)
|
||||
// p.detailsViewer = viewerModel.(*detailsviewer.DetailsViewer)
|
||||
// cmds = append(cmds, viewerCmd)
|
||||
// } else {
|
||||
// // Route to table when details panel not active
|
||||
// p.taskTable, cmd = p.taskTable.Update(msg)
|
||||
// cmds = append(cmds, cmd)
|
||||
//
|
||||
// if p.tasks != nil && len(p.tasks) > 0 {
|
||||
// p.selectedTask = p.tasks[p.taskTable.Cursor()]
|
||||
// } else {
|
||||
// p.selectedTask = nil
|
||||
// }
|
||||
// }
|
||||
switch {
|
||||
case key.Matches(msg, p.common.Keymap.Quit):
|
||||
return p, tea.Quit
|
||||
}
|
||||
// case key.Matches(msg, p.common.Keymap.SetReport):
|
||||
// p.subpage = NewReportPickerPage(p.common, p.activeReport)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.SetContext):
|
||||
// p.subpage = NewContextPickerPage(p.common)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Add):
|
||||
// p.subpage = NewTaskEditorPage(p.common, taskwarrior.NewTask())
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Edit):
|
||||
// p.subpage = NewTaskEditorPage(p.common, *p.selectedTask)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Subtask):
|
||||
// if p.selectedTask != nil {
|
||||
// // Create new task inheriting parent's attributes
|
||||
// newTask := taskwarrior.NewTask()
|
||||
//
|
||||
// // Set parent relationship
|
||||
// newTask.Parent = p.selectedTask.Uuid
|
||||
//
|
||||
// // Copy parent's attributes
|
||||
// newTask.Project = p.selectedTask.Project
|
||||
// newTask.Priority = p.selectedTask.Priority
|
||||
// newTask.Tags = make([]string, len(p.selectedTask.Tags))
|
||||
// copy(newTask.Tags, p.selectedTask.Tags)
|
||||
//
|
||||
// // Copy UDAs (except "details" which is task-specific)
|
||||
// if p.selectedTask.Udas != nil {
|
||||
// newTask.Udas = make(map[string]any)
|
||||
// for k, v := range p.selectedTask.Udas {
|
||||
// // Skip "details" UDA - it's specific to parent task
|
||||
// if k == "details" {
|
||||
// continue
|
||||
// }
|
||||
// // Deep copy other UDA values
|
||||
// newTask.Udas[k] = v
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Open task editor with pre-populated task
|
||||
// p.subpage = NewTaskEditorPage(p.common, newTask)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// }
|
||||
// return p, nil
|
||||
// case key.Matches(msg, p.common.Keymap.Ok):
|
||||
// p.common.TW.SetTaskDone(p.selectedTask)
|
||||
// return p, p.getTasks()
|
||||
// case key.Matches(msg, p.common.Keymap.Delete):
|
||||
// p.common.TW.DeleteTask(p.selectedTask)
|
||||
// return p, p.getTasks()
|
||||
// case key.Matches(msg, p.common.Keymap.SetProject):
|
||||
// p.subpage = NewProjectPickerPage(p.common, p.activeProject)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.PickProjectTask):
|
||||
// p.subpage = NewProjectTaskPickerPage(p.common)
|
||||
// cmd := p.subpage.Init()
|
||||
// p.common.PushPage(p)
|
||||
// return p.subpage, cmd
|
||||
// case key.Matches(msg, p.common.Keymap.Tag):
|
||||
// if p.selectedTask != nil {
|
||||
// tag := p.common.TW.GetConfig().Get("uda.tasksquire.tag.default")
|
||||
// if p.selectedTask.HasTag(tag) {
|
||||
// p.selectedTask.RemoveTag(tag)
|
||||
// } else {
|
||||
// p.selectedTask.AddTag(tag)
|
||||
// }
|
||||
// p.common.TW.ImportTask(p.selectedTask)
|
||||
// return p, p.getTasks()
|
||||
// }
|
||||
// return p, nil
|
||||
// case key.Matches(msg, p.common.Keymap.Undo):
|
||||
// p.common.TW.Undo()
|
||||
// return p, p.getTasks()
|
||||
// case key.Matches(msg, p.common.Keymap.StartStop):
|
||||
// if p.selectedTask != nil && p.selectedTask.Status == "pending" {
|
||||
// if p.selectedTask.Start == "" {
|
||||
// p.common.TW.StopActiveTasks()
|
||||
// p.common.TW.StartTask(p.selectedTask)
|
||||
// } else {
|
||||
// p.common.TW.StopTask(p.selectedTask)
|
||||
// }
|
||||
// return p, p.getTasks()
|
||||
// }
|
||||
// case key.Matches(msg, p.common.Keymap.ViewDetails):
|
||||
// if p.selectedTask != nil {
|
||||
// // Toggle details panel
|
||||
// p.detailsPanelActive = !p.detailsPanelActive
|
||||
// if p.detailsPanelActive {
|
||||
// p.detailsViewer.SetTask(p.selectedTask)
|
||||
// p.detailsViewer.Focus()
|
||||
// } else {
|
||||
// p.detailsViewer.Blur()
|
||||
// }
|
||||
// p.SetSize(p.common.Width(), p.common.Height())
|
||||
// return p, nil
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
var cmd tea.Cmd
|
||||
//
|
||||
// // Route keyboard messages to details viewer when panel is active
|
||||
// if p.detailsPanelActive {
|
||||
// var viewerCmd tea.Cmd
|
||||
// var viewerModel tea.Model
|
||||
// viewerModel, viewerCmd = p.detailsViewer.Update(msg)
|
||||
// p.detailsViewer = viewerModel.(*detailsviewer.DetailsViewer)
|
||||
// cmds = append(cmds, viewerCmd)
|
||||
// } else {
|
||||
// // Route to table when details panel not active
|
||||
p.taskTable, cmd = p.taskTable.Update(msg)
|
||||
cmds = append(cmds, cmd)
|
||||
|
||||
if len(p.tasks) > 0 {
|
||||
p.selectedTask = p.tasks[p.taskTable.Cursor()]
|
||||
} else {
|
||||
p.selectedTask = nil
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
return p, tea.Batch(cmds...)
|
||||
@@ -259,90 +259,116 @@ func (p *TaskPage) View() tea.View {
|
||||
|
||||
tableView := p.taskTable.View()
|
||||
|
||||
//
|
||||
// if !p.detailsPanelActive {
|
||||
// return tableView
|
||||
// }
|
||||
//
|
||||
// // Combine table and details panel vertically
|
||||
// return lipgloss.JoinVertical(
|
||||
// lipgloss.Left,
|
||||
// tableView,
|
||||
// p.detailsViewer.View(),
|
||||
// )
|
||||
// }
|
||||
//
|
||||
|
||||
return tea.NewView(tableView)
|
||||
}
|
||||
//
|
||||
// if !p.detailsPanelActive {
|
||||
// return tableView
|
||||
// }
|
||||
//
|
||||
// // Combine table and details panel vertically
|
||||
// return lipgloss.JoinVertical(
|
||||
// lipgloss.Left,
|
||||
// tableView,
|
||||
// p.detailsViewer.View(),
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// func (p *TaskPage) populateTaskTable(tasks taskwarrior.Tasks) {
|
||||
// if len(tasks) == 0 {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// // Build task tree for hierarchical display
|
||||
// taskTree := taskwarrior.BuildTaskTree(tasks)
|
||||
//
|
||||
// // Use flattened tree list for display order
|
||||
// orderedTasks := make(taskwarrior.Tasks, len(taskTree.FlatList))
|
||||
// for i, node := range taskTree.FlatList {
|
||||
// orderedTasks[i] = node.Task
|
||||
// }
|
||||
//
|
||||
// selected := p.taskTable.Cursor()
|
||||
//
|
||||
// // Adjust cursor for tree ordering
|
||||
// if p.selectedTask != nil {
|
||||
// for i, task := range orderedTasks {
|
||||
// if task.Uuid == p.selectedTask.Uuid {
|
||||
// selected = i
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if selected > len(orderedTasks)-1 {
|
||||
// selected = len(orderedTasks) - 1
|
||||
// }
|
||||
//
|
||||
// // Calculate proper dimensions based on whether details panel is active
|
||||
// baseHeight := p.common.Height() - p.common.Styles.Base.GetVerticalFrameSize()
|
||||
// baseWidth := p.common.Width() - p.common.Styles.Base.GetHorizontalFrameSize()
|
||||
//
|
||||
// var tableHeight int
|
||||
// if p.detailsPanelActive {
|
||||
// // Allocate 60% for table, 40% for details panel
|
||||
// // Minimum 5 lines for details, minimum 10 lines for table
|
||||
// detailsHeight := max(min(baseHeight*2/5, baseHeight-10), 5)
|
||||
// tableHeight = baseHeight - detailsHeight - 1 // -1 for spacing
|
||||
// } else {
|
||||
// tableHeight = baseHeight
|
||||
// }
|
||||
//
|
||||
// p.taskTable = table.New(
|
||||
// p.common,
|
||||
// able.WithReport(p.activeReport),
|
||||
// table.WithTasks(orderedTasks),
|
||||
// table.WithTaskTree(taskTree),
|
||||
// table.WithFocused(true),
|
||||
// table.WithWidth(baseWidth),
|
||||
// table.WithHeight(tableHeight),
|
||||
// table.WithStyles(p.common.Styles.TableStyle),
|
||||
// )
|
||||
//
|
||||
// if selected == 0 {
|
||||
// selected = p.taskTable.Cursor()
|
||||
// }
|
||||
// if selected < len(orderedTasks) {
|
||||
// p.taskTable.SetCursor(selected)
|
||||
// } else {
|
||||
// p.taskTable.SetCursor(len(p.tasks) - 1)
|
||||
// }
|
||||
//
|
||||
// // Refresh details content if panel is active
|
||||
// if p.detailsPanelActive && p.selectedTask != nil {
|
||||
// p.detailsViewer.SetTask(p.selectedTask)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
func (p *TaskPage) populateTaskTable(tasks taskwarrior.Tasks) {
|
||||
if len(tasks) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
selected := p.taskTable.Cursor()
|
||||
|
||||
// Calculate proper dimensions based on whether details panel is active
|
||||
baseHeight := p.common.Height() - p.common.Styles.Base.GetVerticalFrameSize()
|
||||
baseWidth := p.common.Width() - p.common.Styles.Base.GetHorizontalFrameSize()
|
||||
|
||||
var tableHeight int
|
||||
// if p.detailsPanelActive {
|
||||
// // Allocate 60% for table, 40% for details panel
|
||||
// // Minimum 5 lines for details, minimum 10 lines for table
|
||||
// detailsHeight := max(min(baseHeight*2/5, baseHeight-10), 5)
|
||||
// tableHeight = baseHeight - detailsHeight - 1 // -1 for spacing
|
||||
// } else {
|
||||
tableHeight = baseHeight
|
||||
// }
|
||||
//
|
||||
|
||||
numCols := len(p.activeReport.Columns)
|
||||
taskRows := make([]table.Row, len(tasks))
|
||||
taskStyles := make([]lipgloss.Style, len(tasks))
|
||||
widths := make([]int, numCols)
|
||||
|
||||
for i, task := range tasks {
|
||||
row := make(table.Row, numCols)
|
||||
for j, colKey := range p.activeReport.Columns {
|
||||
val := task.GetString(colKey)
|
||||
row[j] = val
|
||||
widths[j] = max(widths[j], lipgloss.Width(val))
|
||||
}
|
||||
taskRows[i] = row
|
||||
taskStyles[i] = common.GetTaskTabelStyle(task, *p.common)
|
||||
}
|
||||
|
||||
var columns []table.Column
|
||||
for j, w := range widths {
|
||||
title := p.activeReport.Labels[j]
|
||||
|
||||
width := 0
|
||||
if w > 0 {
|
||||
width = max(w, lipgloss.Width(title))
|
||||
}
|
||||
|
||||
columns = append(columns, table.Column{
|
||||
Title: title,
|
||||
Width: width,
|
||||
})
|
||||
}
|
||||
|
||||
if len(columns) > 0 {
|
||||
usedWidth := 0
|
||||
for i := 0; i < len(columns)-1; i++ {
|
||||
usedWidth += columns[i].Width + 1 // padding/border offset
|
||||
}
|
||||
|
||||
remaining := p.taskTable.Width() - usedWidth - 1
|
||||
lastIdx := len(columns) - 1
|
||||
columns[lastIdx].Width = max(columns[lastIdx].Width, remaining)
|
||||
}
|
||||
|
||||
p.taskTable = table.New(
|
||||
table.WithColumns(columns),
|
||||
table.WithRows(taskRows),
|
||||
table.WithRowStyles(taskStyles),
|
||||
table.WithFocused(true),
|
||||
table.WithWidth(baseWidth),
|
||||
table.WithHeight(tableHeight),
|
||||
table.WithStyles(table.Styles{
|
||||
Header: p.common.Styles.TableStyle.Header,
|
||||
Cell: p.common.Styles.TableStyle.Cell,
|
||||
Selected: p.common.Styles.TableStyle.Selected,
|
||||
}),
|
||||
)
|
||||
|
||||
if selected == 0 {
|
||||
selected = p.taskTable.Cursor()
|
||||
}
|
||||
if selected < len(tasks) {
|
||||
p.taskTable.SetCursor(selected)
|
||||
} else {
|
||||
p.taskTable.SetCursor(len(p.tasks) - 1)
|
||||
}
|
||||
// // Refresh details content if panel is active
|
||||
//
|
||||
// if p.detailsPanelActive && p.selectedTask != nil {
|
||||
// p.detailsViewer.SetTask(p.selectedTask)
|
||||
// }
|
||||
}
|
||||
|
||||
func (p *TaskPage) getTasks() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
filters := []string{}
|
||||
|
||||
Reference in New Issue
Block a user