-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filepicker Bubble #343
Filepicker Bubble #343
Conversation
Screen.Recording.2023-03-03.at.12.47.21.PM.mov |
I will update the README to include the file picker when we release the next version of Bubbles. |
FWIW, this is awesome! Cannot wait to use this. 📁 |
Great timing on adding this, just what I needed! 👍 |
No problem @ManveerBhullar, let us know if you have any feedback / issues with it! |
@maaslalani I tried to use it today, but the released version of bubbles is from Jan and doesn't have this in it :( |
Hey @ManveerBhullar, we will do a release soon including the file picker but you can also run: go get github.com/charmbracelet/bubbles@master To use the version on |
… to v0.16.1 (#18) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles) | require | minor | `v0.15.0` -> `v0.16.1` | copilot:all --- ### Release Notes <details> <summary>charmbracelet/bubbles</summary> ### [`v0.16.1`](https://github.com/charmbracelet/bubbles/releases/tag/v0.16.1) [Compare Source](https://github.com/charmbracelet/bubbles/compare/v0.16.0...v0.16.1) ### File Picker Bubble 📁 🫧 This release introduces a brand new `filepicker` bubble, new features, and a tonne of bugfixes. Let us know what you think, ask questions, or just say hello in our [Discord](https://charm.sh/chat). <img src="https://vhs.charm.sh/vhs-yET2HNiJNEbyqaVfYuLnY.gif" width="600" alt="File picker example"> For a quick start on how to use this bubble, take a look at the [Example code](https://github.com/charmbracelet/bubbletea/tree/master/examples/file-picker/main.go). ##### Getting Started Create a new file picker and add it to your Bubble Tea model. ```go picker := filepicker.New() picker.CurrentDirectory, err = os.UserHomeDir() if err != nil { // ... } m := model{ picker: picker, // ... } ``` Initialize the file picker in your `Model`'s `Init` function. ```go func (m model) Init() tea.Cmd { return tea.Batch( m.picker.Init(), // ... ) } ``` Update the filepicker as any other bubble in the `Update` function. After the `picker.Update`, use the `DidSelectFile(msg tea.Msg)` function to perform an action when the user selects a valid file. You may allow only certain file types to be selected with the `AllowedTypes` property and allow directories to be selected with the `DirAllowed` property. To see the currently selected file/directory use the `Path` property. ```go var cmd tea.Cmd m.picker, cmd = m.picker.Update(msg) // Did the user select a file? if didSelect, path := m.picker.DidSelectFile(msg); didSelect { // Get the path of the selected file. return m, tea.Println("You selected: " + selectedPath) } return m, cmd ``` For the full example on how to use this bubble, take a look at the [Example code](https://github.com/charmbracelet/bubbletea/tree/master/examples/file-picker/main.go). #### New - Filepicker: new bubble by [@​maaslalani](https://github.com/maaslalani) in [charmbracelet/bubbles#343 - Textarea: max width/height configurable by [@​knz](https://github.com/knz) in [charmbracelet/bubbles#370 - Spinner: periods of ellipsis by [@​meowgorithm](https://github.com/meowgorithm) in [charmbracelet/bubbles#375 - List: infinite scrolling by [@​jon4hz](https://github.com/jon4hz) in [charmbracelet/bubbles#316 #### Fixed - app would crash if `deleteWordRight` was called at the end of line by [@​infastin](https://github.com/infastin) in [charmbracelet/bubbles#313 - support pastes that end with a newline character by [@​knz](https://github.com/knz) in [charmbracelet/bubbles#314 - data corruption after multi-line input by [@​knz](https://github.com/knz) in [charmbracelet/bubbles#318 - Remove unused `BackgroundStyle` in TextInput by [@​savannahostrowski](https://github.com/savannahostrowski) in [charmbracelet/bubbles#341 - add bounds checking to the `SelectedRow` by [@​MikaelFangel](https://github.com/MikaelFangel) in [charmbracelet/bubbles#351 - fix(progress): last gradient color off by one by [@​residualmind](https://github.com/residualmind) in [charmbracelet/bubbles#338 - deprecate `CursorStyle` in favour of `Cursor.Style` by [@​maaslalani](https://github.com/maaslalani) in [charmbracelet/bubbles#365 - Reset blink only when `CursorBlink` by [@​remiposo](https://github.com/remiposo) in [charmbracelet/bubbles#378 #### New Contributors - [@​infastin](https://github.com/infastin) made their first contribution in [charmbracelet/bubbles#313 - [@​gzipChrist](https://github.com/gzipChrist) made their first contribution in [charmbracelet/bubbles#332 - [@​savannahostrowski](https://github.com/savannahostrowski) made their first contribution in [charmbracelet/bubbles#341 - [@​MikaelFangel](https://github.com/MikaelFangel) made their first contribution in [charmbracelet/bubbles#351 - [@​stefanbildl](https://github.com/stefanbildl) made their first contribution in [charmbracelet/bubbles#339 - [@​residualmind](https://github.com/residualmind) made their first contribution in [charmbracelet/bubbles#338 - [@​bashbunni](https://github.com/bashbunni) made their first contribution in [charmbracelet/bubbles#359 - [@​squrki](https://github.com/squrki) made their first contribution in [charmbracelet/bubbles#373 - [@​remiposo](https://github.com/remiposo) made their first contribution in [charmbracelet/bubbles#378 **Full Changelog**: charmbracelet/bubbles@v0.15.0...v0.16.0 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg?1" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@​charm), or on [Discord](https://charm.sh/chat). ### [`v0.16.0`](https://github.com/charmbracelet/bubbles/compare/v0.15.0...v0.16.0) [Compare Source](https://github.com/charmbracelet/bubbles/compare/v0.15.0...v0.16.0) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/sheldonhull/az-pr). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTAuMCIsInVwZGF0ZWRJblZlciI6IjM1LjExMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* feat: filepicker bubble * fix: bump bubbles to 1.16 * fix: allow customization of empty state * fix: change `Enter` to `Open` * fix: lint gomnd * fix: don't send msg, instead check if this update caused a selection
Filepicker bubbles allows for selecting files or directories with customizable
key bindings and styling.
It emits a
FileSelectedMsg
to allow the parent model to react to a valid selection action.