chore: bumped sipp-go tui to charmbracelet v2
661487da
10 file(s) · +128 −108
| 2 | 2 | ||
| 3 | 3 | Go rewrite of [sipp](../sipp). Two binaries: |
|
| 4 | 4 | ||
| 5 | + | - root (`.`) — CLI dispatcher: `sipp server`, or `sipp <file>` to upload a |
|
| 6 | + | snippet to a remote instance via the JSON API. |
|
| 5 | 7 | - `cmd/server` — web server only (HTTP + admin + API + syntax highlight via |
|
| 6 | 8 | `github.com/alecthomas/chroma/v2`). |
|
| 7 | - | - `cmd/sipp` — CLI dispatcher: `sipp server`, or `sipp <file>` to upload a |
|
| 8 | - | snippet to a remote instance via the JSON API. |
|
| 9 | 9 | ||
| 10 | 10 | ## Notes vs Rust version |
|
| 11 | 11 | ||
| 22 | 22 | cp .env.example .env |
|
| 23 | 23 | go run ./cmd/server |
|
| 24 | 24 | # or |
|
| 25 | - | go run ./cmd/sipp server --port 3000 |
|
| 25 | + | go run . server --port 3000 |
|
| 26 | 26 | ``` |
|
| 27 | 27 | ||
| 28 | 28 | Upload a file: |
|
| 29 | 29 | ||
| 30 | 30 | ```bash |
|
| 31 | 31 | SIPP_REMOTE_URL=http://localhost:3000 SIPP_API_KEY=$KEY \ |
|
| 32 | - | go run ./cmd/sipp ./path/to/file.go |
|
| 32 | + | go run . ./path/to/file.go |
|
| 33 | 33 | ``` |
|
| 34 | 34 | ||
| 35 | 35 | See `.env.example` for env vars. |
|
| 42 | 42 | ` |
|
| 43 | 43 | ||
| 44 | 44 | func main() { |
|
| 45 | - | config.LoadDotEnv(".env") |
|
| 46 | 45 | args := os.Args[1:] |
|
| 47 | 46 | if len(args) == 0 { |
|
| 48 | 47 | runTUI(nil) |
|
| 63 | 62 | } |
|
| 64 | 63 | ||
| 65 | 64 | func runServer(args []string) { |
|
| 65 | + | config.LoadDotEnv(".env") |
|
| 66 | 66 | host := config.Getenv("HOST", "127.0.0.1") |
|
| 67 | 67 | port := config.GetenvInt("PORT", 3000) |
|
| 68 | 68 | for i := 0; i < len(args); i++ { |
|
| 1 | 1 | module github.com/stevedylandev/andromeda/apps/sipp-go |
|
| 2 | 2 | ||
| 3 | - | go 1.24.4 |
|
| 3 | + | go 1.25.0 |
|
| 4 | 4 | ||
| 5 | 5 | require ( |
|
| 6 | + | charm.land/bubbles/v2 v2.1.0 |
|
| 7 | + | charm.land/bubbletea/v2 v2.0.6 |
|
| 8 | + | charm.land/lipgloss/v2 v2.0.3 |
|
| 6 | 9 | github.com/BurntSushi/toml v1.6.0 |
|
| 7 | 10 | github.com/alecthomas/chroma/v2 v2.14.0 |
|
| 8 | 11 | github.com/atotto/clipboard v0.1.4 |
|
| 9 | - | github.com/charmbracelet/bubbles v1.0.0 |
|
| 10 | - | github.com/charmbracelet/bubbletea v1.3.10 |
|
| 11 | - | github.com/charmbracelet/lipgloss v1.1.0 |
|
| 12 | 12 | github.com/stevedylandev/andromeda/crates-go/auth v0.0.0 |
|
| 13 | 13 | github.com/stevedylandev/andromeda/crates-go/config v0.0.0 |
|
| 14 | 14 | github.com/stevedylandev/andromeda/crates-go/darkmatter v0.0.0 |
|
| 17 | 17 | ) |
|
| 18 | 18 | ||
| 19 | 19 | require ( |
|
| 20 | - | github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect |
|
| 21 | - | github.com/charmbracelet/colorprofile v0.4.1 // indirect |
|
| 22 | - | github.com/charmbracelet/x/ansi v0.11.6 // indirect |
|
| 23 | - | github.com/charmbracelet/x/cellbuf v0.0.15 // indirect |
|
| 20 | + | github.com/charmbracelet/colorprofile v0.4.3 // indirect |
|
| 21 | + | github.com/charmbracelet/ultraviolet v0.0.0-20260416155717-489999b90468 // indirect |
|
| 22 | + | github.com/charmbracelet/x/ansi v0.11.7 // indirect |
|
| 24 | 23 | github.com/charmbracelet/x/term v0.2.2 // indirect |
|
| 25 | - | github.com/clipperhouse/displaywidth v0.9.0 // indirect |
|
| 26 | - | github.com/clipperhouse/stringish v0.1.1 // indirect |
|
| 27 | - | github.com/clipperhouse/uax29/v2 v2.5.0 // indirect |
|
| 24 | + | github.com/charmbracelet/x/termios v0.1.1 // indirect |
|
| 25 | + | github.com/charmbracelet/x/windows v0.2.2 // indirect |
|
| 26 | + | github.com/clipperhouse/displaywidth v0.11.0 // indirect |
|
| 27 | + | github.com/clipperhouse/uax29/v2 v2.7.0 // indirect |
|
| 28 | 28 | github.com/dlclark/regexp2 v1.11.0 // indirect |
|
| 29 | 29 | github.com/dustin/go-humanize v1.0.1 // indirect |
|
| 30 | - | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect |
|
| 31 | 30 | github.com/google/uuid v1.6.0 // indirect |
|
| 32 | - | github.com/lucasb-eyer/go-colorful v1.3.0 // indirect |
|
| 31 | + | github.com/lucasb-eyer/go-colorful v1.4.0 // indirect |
|
| 33 | 32 | github.com/mattn/go-isatty v0.0.20 // indirect |
|
| 34 | - | github.com/mattn/go-localereader v0.0.1 // indirect |
|
| 35 | - | github.com/mattn/go-runewidth v0.0.19 // indirect |
|
| 36 | - | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect |
|
| 33 | + | github.com/mattn/go-runewidth v0.0.23 // indirect |
|
| 37 | 34 | github.com/muesli/cancelreader v0.2.2 // indirect |
|
| 38 | - | github.com/muesli/termenv v0.16.0 // indirect |
|
| 39 | 35 | github.com/ncruces/go-strftime v0.1.9 // indirect |
|
| 40 | 36 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect |
|
| 41 | 37 | github.com/rivo/uniseg v0.4.7 // indirect |
|
| 42 | 38 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect |
|
| 43 | 39 | golang.org/x/crypto v0.39.0 // indirect |
|
| 44 | 40 | golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect |
|
| 45 | - | golang.org/x/sys v0.38.0 // indirect |
|
| 46 | - | golang.org/x/text v0.26.0 // indirect |
|
| 41 | + | golang.org/x/mod v0.25.0 // indirect |
|
| 42 | + | golang.org/x/sync v0.20.0 // indirect |
|
| 43 | + | golang.org/x/sys v0.43.0 // indirect |
|
| 47 | 44 | modernc.org/libc v1.65.7 // indirect |
|
| 48 | 45 | modernc.org/mathutil v1.7.1 // indirect |
|
| 49 | 46 | modernc.org/memory v1.11.0 // indirect |
|
| 1 | + | charm.land/bubbles/v2 v2.1.0 h1:YSnNh5cPYlYjPxRrzs5VEn3vwhtEn3jVGRBT3M7/I0g= |
|
| 2 | + | charm.land/bubbles/v2 v2.1.0/go.mod h1:l97h4hym2hvWBVfmJDtrEHHCtkIKeTEb3TTJ4ZOB3wY= |
|
| 3 | + | charm.land/bubbletea/v2 v2.0.6 h1:UHN/91OyuhaOFGSrBXQ/hMZD8IO1Uc4BvHlgHXL2WJo= |
|
| 4 | + | charm.land/bubbletea/v2 v2.0.6/go.mod h1:MH/D8ZLlN3op37vQvijKuU29g3rqTp+aQapURFonF9g= |
|
| 5 | + | charm.land/lipgloss/v2 v2.0.3 h1:yM2zJ4Cf5Y51b7RHIwioil4ApI/aypFXXVHSwlM6RzU= |
|
| 6 | + | charm.land/lipgloss/v2 v2.0.3/go.mod h1:7myLU9iG/3xluAWzpY/fSxYYHCgoKTie7laxk6ATwXA= |
|
| 1 | 7 | github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= |
|
| 2 | 8 | github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= |
|
| 3 | 9 | github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= |
|
| 10 | 16 | github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= |
|
| 11 | 17 | github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= |
|
| 12 | 18 | github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= |
|
| 13 | - | github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= |
|
| 14 | - | github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= |
|
| 15 | - | github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY= |
|
| 16 | - | github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= |
|
| 17 | - | github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc= |
|
| 18 | - | github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E= |
|
| 19 | - | github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= |
|
| 20 | - | github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= |
|
| 21 | - | github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= |
|
| 22 | - | github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= |
|
| 23 | - | github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= |
|
| 24 | - | github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= |
|
| 25 | - | github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= |
|
| 26 | - | github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= |
|
| 27 | - | github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= |
|
| 28 | - | github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= |
|
| 29 | - | github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= |
|
| 30 | - | github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= |
|
| 19 | + | github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o= |
|
| 20 | + | github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w= |
|
| 21 | + | github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q= |
|
| 22 | + | github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q= |
|
| 23 | + | github.com/charmbracelet/ultraviolet v0.0.0-20260416155717-489999b90468 h1:Q9fO0y1Zo5KB/5Vu8JZoLGm1N3RzF9bNj3Ao3xoR+Ac= |
|
| 24 | + | github.com/charmbracelet/ultraviolet v0.0.0-20260416155717-489999b90468/go.mod h1:bAAz7dh/FTYfC+oiHavL4mX1tOIBZ0ZwYjSi3qE6ivM= |
|
| 25 | + | github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI= |
|
| 26 | + | github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ= |
|
| 27 | + | github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA= |
|
| 28 | + | github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I= |
|
| 31 | 29 | github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= |
|
| 32 | 30 | github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= |
|
| 33 | - | github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA= |
|
| 34 | - | github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA= |
|
| 35 | - | github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= |
|
| 36 | - | github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= |
|
| 37 | - | github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U= |
|
| 38 | - | github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= |
|
| 31 | + | github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= |
|
| 32 | + | github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= |
|
| 33 | + | github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM= |
|
| 34 | + | github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k= |
|
| 35 | + | github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= |
|
| 36 | + | github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= |
|
| 37 | + | github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= |
|
| 38 | + | github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= |
|
| 39 | 39 | github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= |
|
| 40 | 40 | github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= |
|
| 41 | 41 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= |
|
| 42 | 42 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= |
|
| 43 | - | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= |
|
| 44 | - | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= |
|
| 45 | 43 | github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= |
|
| 46 | 44 | github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= |
|
| 47 | 45 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= |
|
| 48 | 46 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
|
| 49 | 47 | github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= |
|
| 50 | 48 | github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= |
|
| 51 | - | github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= |
|
| 52 | - | github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= |
|
| 49 | + | github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4= |
|
| 50 | + | github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= |
|
| 53 | 51 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
|
| 54 | 52 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
|
| 55 | - | github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= |
|
| 56 | - | github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= |
|
| 57 | - | github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= |
|
| 58 | - | github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= |
|
| 59 | - | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= |
|
| 60 | - | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= |
|
| 53 | + | github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw= |
|
| 54 | + | github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= |
|
| 61 | 55 | github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= |
|
| 62 | 56 | github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= |
|
| 63 | - | github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= |
|
| 64 | - | github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= |
|
| 65 | 57 | github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= |
|
| 66 | 58 | github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= |
|
| 67 | 59 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= |
|
| 76 | 68 | golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= |
|
| 77 | 69 | golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= |
|
| 78 | 70 | golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= |
|
| 79 | - | golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= |
|
| 80 | - | golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= |
|
| 81 | - | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
| 71 | + | golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= |
|
| 72 | + | golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= |
|
| 82 | 73 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
| 83 | - | golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= |
|
| 84 | - | golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= |
|
| 85 | - | golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= |
|
| 86 | - | golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= |
|
| 74 | + | golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= |
|
| 75 | + | golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= |
|
| 87 | 76 | golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= |
|
| 88 | 77 | golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= |
|
| 89 | 78 | modernc.org/cc/v4 v4.26.1 h1:+X5NtzVBn0KgsBCBe+xkDC7twLb/jNVj9FPgiwSQO3s= |
|
| 7 | 7 | "path/filepath" |
|
| 8 | 8 | "runtime" |
|
| 9 | 9 | ||
| 10 | - | tea "github.com/charmbracelet/bubbletea" |
|
| 10 | + | tea "charm.land/bubbletea/v2" |
|
| 11 | 11 | ) |
|
| 12 | 12 | ||
| 13 | 13 | func openExternalEditor(shortID, name, content string) tea.Cmd { |
| 1 | 1 | package tui |
|
| 2 | 2 | ||
| 3 | - | import "github.com/charmbracelet/bubbles/key" |
|
| 3 | + | import "charm.land/bubbles/v2/key" |
|
| 4 | 4 | ||
| 5 | 5 | type keyMap struct { |
|
| 6 | 6 | Up key.Binding |
| 4 | 4 | "strings" |
|
| 5 | 5 | "time" |
|
| 6 | 6 | ||
| 7 | - | "github.com/charmbracelet/bubbles/help" |
|
| 8 | - | "github.com/charmbracelet/bubbles/textarea" |
|
| 9 | - | "github.com/charmbracelet/bubbles/textinput" |
|
| 10 | - | "github.com/charmbracelet/bubbles/viewport" |
|
| 11 | - | tea "github.com/charmbracelet/bubbletea" |
|
| 7 | + | "charm.land/bubbles/v2/help" |
|
| 8 | + | "charm.land/bubbles/v2/textarea" |
|
| 9 | + | "charm.land/bubbles/v2/textinput" |
|
| 10 | + | "charm.land/bubbles/v2/viewport" |
|
| 11 | + | tea "charm.land/bubbletea/v2" |
|
| 12 | 12 | ) |
|
| 13 | 13 | ||
| 14 | 14 | type Focus int |
|
| 71 | 71 | si.Placeholder = "search names" |
|
| 72 | 72 | si.Prompt = "/ " |
|
| 73 | 73 | ||
| 74 | - | vp := viewport.New(0, 0) |
|
| 74 | + | vp := viewport.New() |
|
| 75 | 75 | ||
| 76 | 76 | return Model{ |
|
| 77 | 77 | backend: backend, |
|
| 88 | 88 | } |
|
| 89 | 89 | ||
| 90 | 90 | func (m Model) Init() tea.Cmd { |
|
| 91 | - | return loadSnippetsCmd(m.backend) |
|
| 91 | + | return tea.Batch(tea.RequestWindowSize, loadSnippetsCmd(m.backend)) |
|
| 92 | 92 | } |
|
| 93 | 93 | ||
| 94 | 94 | func (m *Model) visible() []Snippet { |
|
| 1 | 1 | package tui |
|
| 2 | 2 | ||
| 3 | 3 | import ( |
|
| 4 | - | tea "github.com/charmbracelet/bubbletea" |
|
| 4 | + | tea "charm.land/bubbletea/v2" |
|
| 5 | 5 | ) |
|
| 6 | 6 | ||
| 7 | 7 | func Run(opts Options) error { |
|
| 11 | 11 | } |
|
| 12 | 12 | defer backend.Close() |
|
| 13 | 13 | ||
| 14 | - | p := tea.NewProgram(newModel(backend), tea.WithAltScreen()) |
|
| 14 | + | p := tea.NewProgram(newModel(backend)) |
|
| 15 | 15 | _, err = p.Run() |
|
| 16 | 16 | return err |
|
| 17 | 17 | } |
|
| 4 | 4 | "strings" |
|
| 5 | 5 | ||
| 6 | 6 | "github.com/atotto/clipboard" |
|
| 7 | - | "github.com/charmbracelet/bubbles/key" |
|
| 8 | - | tea "github.com/charmbracelet/bubbletea" |
|
| 9 | - | "github.com/charmbracelet/lipgloss" |
|
| 7 | + | "charm.land/bubbles/v2/key" |
|
| 8 | + | tea "charm.land/bubbletea/v2" |
|
| 9 | + | "charm.land/lipgloss/v2" |
|
| 10 | 10 | ) |
|
| 11 | 11 | ||
| 12 | 12 | func loadSnippetsCmd(b Backend) tea.Cmd { |
|
| 106 | 106 | m.status = "" |
|
| 107 | 107 | return m, nil |
|
| 108 | 108 | ||
| 109 | - | case tea.KeyMsg: |
|
| 109 | + | case tea.KeyPressMsg: |
|
| 110 | 110 | return m.handleKey(msg) |
|
| 111 | 111 | } |
|
| 112 | 112 | ||
| 130 | 130 | bodyH = 5 |
|
| 131 | 131 | } |
|
| 132 | 132 | ||
| 133 | - | m.contentVP.Width = contentW - 2 |
|
| 134 | - | m.contentVP.Height = bodyH - 2 |
|
| 133 | + | m.contentVP.SetWidth(contentW - 2) |
|
| 134 | + | m.contentVP.SetHeight(bodyH - 2) |
|
| 135 | 135 | ||
| 136 | - | m.nameInput.Width = contentW - 4 |
|
| 136 | + | m.nameInput.SetWidth(contentW - 4) |
|
| 137 | 137 | if m.wrapContent { |
|
| 138 | 138 | m.contentArea.SetWidth(contentW - 2) |
|
| 139 | 139 | } else { |
|
| 141 | 141 | } |
|
| 142 | 142 | m.contentArea.SetHeight(bodyH - 5) |
|
| 143 | 143 | ||
| 144 | - | m.searchInput.Width = listW - 4 |
|
| 144 | + | m.searchInput.SetWidth(listW - 4) |
|
| 145 | 145 | ||
| 146 | 146 | m.refreshPreview() |
|
| 147 | 147 | } |
|
| 156 | 156 | if m.highlighter != nil { |
|
| 157 | 157 | body = m.highlighter.render(s.ShortID, s.Name, s.Content) |
|
| 158 | 158 | } |
|
| 159 | - | if m.wrapContent && m.contentVP.Width > 0 { |
|
| 160 | - | body = lipgloss.NewStyle().Width(m.contentVP.Width).Render(body) |
|
| 159 | + | if m.wrapContent && m.contentVP.Width() > 0 { |
|
| 160 | + | body = lipgloss.NewStyle().Width(m.contentVP.Width()).Render(body) |
|
| 161 | 161 | } |
|
| 162 | 162 | m.contentVP.SetContent(body) |
|
| 163 | 163 | } |
|
| 164 | 164 | ||
| 165 | - | func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
|
| 165 | + | func (m Model) handleKey(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { |
|
| 166 | 166 | if msg.String() == "ctrl+c" { |
|
| 167 | 167 | return m, tea.Quit |
|
| 168 | 168 | } |
|
| 203 | 203 | return m, nil |
|
| 204 | 204 | } |
|
| 205 | 205 | ||
| 206 | - | func (m Model) keyList(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
|
| 206 | + | func (m Model) keyList(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { |
|
| 207 | 207 | list := m.visible() |
|
| 208 | 208 | switch { |
|
| 209 | 209 | case key.Matches(msg, m.keys.Quit): |
|
| 288 | 288 | return m, nil |
|
| 289 | 289 | } |
|
| 290 | 290 | ||
| 291 | - | func (m Model) keyContent(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
|
| 291 | + | func (m Model) keyContent(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { |
|
| 292 | 292 | switch { |
|
| 293 | 293 | case key.Matches(msg, m.keys.WrapToggle): |
|
| 294 | 294 | m.wrapContent = !m.wrapContent |
|
| 344 | 344 | return m, cmd |
|
| 345 | 345 | } |
|
| 346 | 346 | ||
| 347 | - | func (m Model) keyForm(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
|
| 347 | + | func (m Model) keyForm(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { |
|
| 348 | 348 | switch { |
|
| 349 | 349 | case key.Matches(msg, m.keys.WrapToggle): |
|
| 350 | 350 | m.wrapContent = !m.wrapContent |
|
| 351 | 351 | if m.wrapContent { |
|
| 352 | - | m.contentArea.SetWidth(m.contentVP.Width) |
|
| 352 | + | m.contentArea.SetWidth(m.contentVP.Width()) |
|
| 353 | 353 | return m, m.setStatus("wrap on", true) |
|
| 354 | 354 | } |
|
| 355 | 355 | m.contentArea.SetWidth(10000) |
|
| 405 | 405 | } |
|
| 406 | 406 | } |
|
| 407 | 407 | ||
| 408 | - | func (m Model) keySearch(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
|
| 408 | + | func (m Model) keySearch(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { |
|
| 409 | 409 | switch msg.String() { |
|
| 410 | 410 | case "esc": |
|
| 411 | 411 | m.searchInput.SetValue("") |
|
| 4 | 4 | "fmt" |
|
| 5 | 5 | "strings" |
|
| 6 | 6 | ||
| 7 | - | "github.com/charmbracelet/lipgloss" |
|
| 7 | + | tea "charm.land/bubbletea/v2" |
|
| 8 | + | "charm.land/lipgloss/v2" |
|
| 8 | 9 | ) |
|
| 9 | 10 | ||
| 10 | 11 | var ( |
|
| 39 | 40 | Background(lipgloss.Color("236")) |
|
| 40 | 41 | ) |
|
| 41 | 42 | ||
| 42 | - | func (m Model) View() string { |
|
| 43 | + | func (m Model) View() tea.View { |
|
| 43 | 44 | if !m.ready { |
|
| 44 | - | return "loading..." |
|
| 45 | + | return tea.View{Content: "loading...", AltScreen: true} |
|
| 45 | 46 | } |
|
| 46 | 47 | ||
| 47 | 48 | listW := m.width * 30 / 100 |
|
| 57 | 58 | body := lipgloss.JoinHorizontal(lipgloss.Top, left, right) |
|
| 58 | 59 | footer := m.renderFooter() |
|
| 59 | 60 | ||
| 60 | - | view := lipgloss.JoinVertical(lipgloss.Left, body, footer) |
|
| 61 | + | base := lipgloss.JoinVertical(lipgloss.Left, body, footer) |
|
| 61 | 62 | ||
| 63 | + | var overlays []*lipgloss.Layer |
|
| 62 | 64 | if m.showHelp { |
|
| 63 | - | view = lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, |
|
| 64 | - | modalStyle.Render(m.help.FullHelpView(m.keys.FullHelp())), |
|
| 65 | - | lipgloss.WithWhitespaceChars(" ")) |
|
| 65 | + | overlays = append(overlays, centerLayer(m.width, m.height, |
|
| 66 | + | modalStyle.Render(m.help.FullHelpView(m.keys.FullHelp())), 1)) |
|
| 66 | 67 | } |
|
| 67 | 68 | if m.confirmDelete { |
|
| 68 | 69 | s := m.current() |
|
| 70 | 71 | if s != nil { |
|
| 71 | 72 | name = s.Name |
|
| 72 | 73 | } |
|
| 73 | - | view = lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, |
|
| 74 | - | modalStyle.Render(fmt.Sprintf("Delete %q?\n\ny / n", name)), |
|
| 75 | - | lipgloss.WithWhitespaceChars(" ")) |
|
| 74 | + | overlays = append(overlays, centerLayer(m.width, m.height, |
|
| 75 | + | modalStyle.Render(fmt.Sprintf("Delete %q?\n\ny / n", name)), 2)) |
|
| 76 | 76 | } |
|
| 77 | 77 | if m.status != "" { |
|
| 78 | 78 | st := statusOK |
|
| 79 | 79 | if !m.statusOK { |
|
| 80 | 80 | st = statusErr |
|
| 81 | 81 | } |
|
| 82 | - | view = lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Bottom, |
|
| 83 | - | modalStyle.Render(st.Render(m.status)), |
|
| 84 | - | lipgloss.WithWhitespaceChars(" ")) |
|
| 82 | + | overlays = append(overlays, bottomCenterLayer(m.width, m.height, |
|
| 83 | + | modalStyle.Render(st.Render(m.status)), 3)) |
|
| 85 | 84 | } |
|
| 86 | - | return view |
|
| 85 | + | ||
| 86 | + | content := base |
|
| 87 | + | if len(overlays) > 0 { |
|
| 88 | + | layers := append([]*lipgloss.Layer{lipgloss.NewLayer(base)}, overlays...) |
|
| 89 | + | canvas := lipgloss.NewCanvas(m.width, m.height) |
|
| 90 | + | canvas.Compose(lipgloss.NewCompositor(layers...)) |
|
| 91 | + | content = canvas.Render() |
|
| 92 | + | } |
|
| 93 | + | ||
| 94 | + | return tea.View{Content: content, AltScreen: true} |
|
| 95 | + | } |
|
| 96 | + | ||
| 97 | + | func centerLayer(w, h int, content string, z int) *lipgloss.Layer { |
|
| 98 | + | cw, ch := lipgloss.Width(content), lipgloss.Height(content) |
|
| 99 | + | x := (w - cw) / 2 |
|
| 100 | + | y := (h - ch) / 2 |
|
| 101 | + | if x < 0 { |
|
| 102 | + | x = 0 |
|
| 103 | + | } |
|
| 104 | + | if y < 0 { |
|
| 105 | + | y = 0 |
|
| 106 | + | } |
|
| 107 | + | return lipgloss.NewLayer(content).X(x).Y(y).Z(z) |
|
| 108 | + | } |
|
| 109 | + | ||
| 110 | + | func bottomCenterLayer(w, h int, content string, z int) *lipgloss.Layer { |
|
| 111 | + | cw, ch := lipgloss.Width(content), lipgloss.Height(content) |
|
| 112 | + | x := (w - cw) / 2 |
|
| 113 | + | y := h - ch - 1 |
|
| 114 | + | if x < 0 { |
|
| 115 | + | x = 0 |
|
| 116 | + | } |
|
| 117 | + | if y < 0 { |
|
| 118 | + | y = 0 |
|
| 119 | + | } |
|
| 120 | + | return lipgloss.NewLayer(content).X(x).Y(y).Z(z) |
|
| 87 | 121 | } |
|
| 88 | 122 | ||
| 89 | 123 | func (m Model) renderList(w, h int) string { |
|