Bubble-table - A table component for the Bubble Tea framework

Bubble-table

A table component for the Bubble Tea framework.

This is currently messy as it's in early development and came out of a different project, and should be cleaned up over time.

Table

View sample source code

Features

Displays a table with a header and borders.

Can be focused to highlight a row and navigate with up/down (and j/k).

Can make rows selectable, and fetch the current selections.

Contributing

Contributions welcome, but since this is being actively developed for use in Khan please check first by opening an issue!

Comments
  • Allow table to be horizontally scrollable with full-width columns

    Allow table to be horizontally scrollable with full-width columns

    There should be a way to disallow columns being truncated like this, and instead allow the table to stretch horizontally offscreen, which would then be able to be scrolled left and right with the arrow keys. There's an example output below for a table with many columns where truncation makes the table pretty much useless.

    171625774-93a43670-106f-468d-8d04-deaa46be7ca6

  • Add state query functions / state change messages

    Add state query functions / state change messages

    Things I want to check outside the table:

    • Which column is the table sorted by?
    • Is a filter active?
    • What is the current filter string?

    Possible tea.Msg:

    • filtering started
    • filtering changed
    • filtering ended
    • row changed
    • row selected
    • etc.
  • feat: custom filter text

    feat: custom filter text

    Hello again -- as shown in https://github.com/Evertras/bubble-table/issues/115 as an example, my app layout includes a "command bar" that can both invoke commands and filter views. I plan to support a bunch of functionality within this input that is not just a plain search string (e.g. the ability to also use key=value or !shebang type entries). Due to this, directly exposing it to bubble-table won't work, as the Value() output won't be what I'm looking to filter with. The way my usecase works, is it sends a message to all components through the app, with the filter text when it changes, allowing each component to individually filter based off the specific usecases of each component.

    What would be awesome to have supported, is a field that lets me specify the actual text for filtering, where "" is no filtering, and anything else would be used as filtering. With this, I would be able to support key-value type filtering, but also regular text filtering.

    Alternatively, loosening the restrictions on the WithFilterInput() method, to utilize an interface of Value() string, and selectively interface checking for other features like Focus(), so it only calls those if the underlying type has those methods.

    Thoughts?

  • String length limiting broken for double-width characters

    String length limiting broken for double-width characters

    The following string word-wraps incorrectly:

    直立した恐竜のような身体と、尻尾の先端に常に燃えている炎が特徴。
    

    This is likely because we're measuring rune width and not character width.

    The fix should likely be in table/strlimit.go

  • Customize Border Style

    Customize Border Style

    Currently you can customize the style of the rows and columns, but I was unsure how to customize the border style. I know that you can customize the glyphs used for the border itself, but I just wanted to customize the foreground and background colors for the border. Is that something that you are thinking of implementing, or can it be done via some method that I don't know of? Right now I am wrapping the whole table in a lipgloss.Style, but some of the inner borders stay at the default color, rather than the one that I specified in the style. Maybe it will work if implemented here instead 🤔 ?

  • Handle Rows / Rowdata with different number of columns

    Handle Rows / Rowdata with different number of columns

    I'm trying to create a table which will have data parsed from a CSV file.

    CSVs are tricky beasts, and there may be cases where records may have different number of fields.

    name,address,detail
    This,Is a,good record
    This,record,has,some,more,data
    This is too,small
    

    Now, I could make a pass over the file, find out the MAXIMUM number of columns and create a table with that many columns.

    But is there some other approach we could take?

    I don't want to make multiple passes over the data as I want to show the table as soon as possible (say with first 50 rows), while i load the rest of the CSV async.

    Can we dynamically add columns? What would happen to all other rows that don't have that column's value?

    Having a model that could represent arbitrarily sized rows would be great!

  • feat: filter feature works

    feat: filter feature works

    Request https://github.com/Evertras/bubble-table/issues/5 is done.

    demo go run examples/filter/main.go.

    A filtered simple default table
    Currently filter by:
    Press q or ctrl+c to quit
    
    ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━┓
    ┃        Title┃       Author┃Desc…┃
    ┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━┫
    ┃Computer Sys…┃Randal E. Br…┃This…┃
    ┃Effective Ja…┃ Joshua Bloch┃The …┃
    ┃Structure an…┃Harold Abels…┃Stru…┃
    ┃Game Program…┃Robert Nystr…┃The …┃
    ┣━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━┫
    ┃                              1/1┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    
    A filtered simple default table
    Currently filter by:
    Press q or ctrl+c to quit
    
    ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━┓
    ┃        Title┃       Author┃Desc…┃
    ┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━┫
    ┃Computer Sys…┃Randal E. Br…┃This…┃
    ┃Structure an…┃Harold Abels…┃Stru…┃
    ┃Game Program…┃Robert Nystr…┃The …┃
    ┣━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━┫
    ┃                        /pro  1/1┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    
    ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━┓
    ┃        Title┃       Author┃Desc…┃
    ┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━┫
    ┃Game Program…┃Robert Nystr…┃The …┃
    ┣━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━┫
    ┃                       /game  1/1┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    
  • Feature: select rows programatically

    Feature: select rows programatically

    Add a new Row.Selected(bool) Row function that allows to indicate if the row is selected or not in a programatic manner. In addition to this it:

    • refactors the way Model.SelectedRows() []Row works by computing the selected rows whenever this method is called instead of when the mark is toggled;
    • adds test for selecting rows programatically;
    • adds benchmark for Model.SelectedRows()
    • reduce some allocations in Model.SelectedRows

    As a byproduct of these changes, the previously reported and fixed bug #80 won't reappear again.

  • Feature request: select rows programatically

    Feature request: select rows programatically

    Hi! It's me again 😸

    I've been using this component for a project soon to be open sourced and it's been great so far 👏🏽 but I've found myself in the situation of missing how to select rows programmatically. It would be nice if there was a Row.Selected(bool) method or similar that would allow for marking the rows as selected before displaying them. Also methods on Model to select all/none could be very handy.

    What do you think? I could try taking a stab at this in a PR.

  • FR: ESC to immediately remove any active filtering

    FR: ESC to immediately remove any active filtering

    I like using / to start the table filtering, but I have to enter filter edit mode, delete the filter, and press return to remove a filter.

    How about supporting ESC to clear any filter?

    The table movement key should/could continue to work while I still edit the filter—no need to press return to get back to table navigation mode. I can continue to alter the filter and navigate the table.

  • Fix string length limiting for double-width characters

    Fix string length limiting for double-width characters

    https://github.com/Evertras/bubble-table/issues/40 Implemented the go-runewidth library to manage runes truncation Added tests for japanese characters

  • artifacts on terminal resize

    artifacts on terminal resize

    Hi, thanks for the great library!

    I've noticed that when using flex columns if I resize my terminal then some table artifacts appear on the screen. Any idea on how to clear this out when the terminal window resizes?

    image

    After a screen resize:

    image
  • feat: method to expand to fill height tea.WithAltScreen()

    feat: method to expand to fill height tea.WithAltScreen()

    Hello -- awesome library. I'm looking to use this with tea.WithAltScreen(), however I'm struggling to figure out the best approach to have the table expand to fill the entire height. This is the current layout of my UI (ignore the broken background):

    I'd essentially like the outer border to expand towards the bottom like shown below, however I don't see any height fields exposed to allow such a configuration.

    My first two thoughts would be:

    1. An empty row, with no column dividers (and depending on if footer is enabled, the borders would be rounded).
    2. A flag for toggling outer borders, but still allowing inner borders. This could allow the user to draw their own border. Currently, toggling border settings seems to apply across the board, including all columns/rows.

    Thoughts? Is there another way that I'm missing to do this? I've thought about repurposing the footer, and dynamically changing the height of it, but that feels fragile given the dynamic height of some of the other components inside of the table.

  • Hyperlinks break the table

    Hyperlinks break the table

    I am trying to add hyperlinks to my bubble-table, but OSC 8 hyperlinks don't work when inside the table.

    I am using this function to create the link:

    func hyperlink(text string, url string) string {
    	return "\x1b]8;;" + url + "\x07" + text + "\x1b]8;;\x07"
    }
    

    You can see an example code in this Gist. It renders like this: Screenshot 2022-05-16 at 12 38 24

    Same table, without hyperlinks: Screenshot 2022-05-16 at 12 39 23

  • Cell selection

    Cell selection

    We have row selection, but not cell selection. We should be able to move left/right to highlight a specific cell and make that information available to parent components in the same way as the row.

A component on PolarStack, a hybrid cloud Alibaba Cloud DBaaS product
A component on PolarStack, a hybrid cloud Alibaba Cloud DBaaS product

What is PolarDB Stack Daemon? PolarDB Stack Daemon is a component on PolarStack, a hybrid cloud Alibaba Cloud DBaaS product, and is designed mainly fo

Nov 21, 2021
ASCII table in golang
ASCII table in golang

ASCII Table Writer Generate ASCII table on the fly ... Installation is simple as go get github.com/olekukonko/tablewriter Features Automatic Padding

Jan 1, 2023
CLI tool for manipulating Ceph's upmap exception table.

pgremapper When working with Ceph clusters, there are actions that cause backfill (CRUSH map changes) and cases where you want to cause backfill (movi

Aug 10, 2022
Another CLI framework for Go. It works on my machine.
Another CLI framework for Go. It works on my machine.

Command line interface framework Go framework for rapid command line application development

Dec 30, 2022
A powerful little TUI framework 🏗
A powerful little TUI framework 🏗

Bubble Tea The fun, functional and stateful way to build terminal apps. A Go framework based on The Elm Architecture. Bubble Tea is well-suited for si

Dec 27, 2022
Golang anti-vm framework for Red Team and Pentesters
Golang anti-vm framework for Red Team and Pentesters

Chacal is an anti-vm framework written in Golang in order to support Red Team and Pentesters in your assalts, in Windows environment!

Dec 28, 2022
Dinogo is an CLI framework for build terminal and shell applications in Go.

dinogo Dinogo is an CLI framework for build terminal and shell applications in Go. Features Cross Platform Fast and efficient Keyboard API Enable/Disa

Aug 29, 2022
Highly customizable and lightweight Go CLI app framework 👌
Highly customizable and lightweight Go CLI app framework 👌

Nice ?? Nice is a highly customizable and lightweight framework for crafting CLI apps. Nice respects idiomatic Go code and focuses to be clear, effici

Dec 30, 2022
CLI written on golang for JT Framework

Installation Linux & Mac OS (64-bit) Global sh -c "$(curl -fsSL https://raw.githubusercontent.com/jarvis-technologies/cli/main/install.sh)" Local Linu

Jan 3, 2022
Fiber v2 ,web framework for go.

go run main.go Liveness Probe cat /tmp/live echo $? output = 0 ,status = up Method RelativePath CURL GET /healthz http://127.0.0.1:8080/healthz GET

Jan 10, 2022
This repository contains example apps created using GoCondor framework

Examples This repository contains example apps created using GoCondor framework what are the examples? 1- Todo API A todo api with the below routes:

May 7, 2021
Basic usage of Vecty framework examples.

vecty-examples Basic usage of Vecty framework examples. Instructions Change directory to the folder with the example you wish to run Run wasmserve. To

Jun 20, 2022
Vfkit - Simple command line tool to start VMs through virtualization framework

vfkit - Simple command line tool to start VMs through virtualization framework v

Oct 21, 2022
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework

This is the official CLI tool to operate with Getting Things Done Framework. How

Feb 14, 2022
Golang Bubble Tea Weather Demo

Golang Bubble Tea Weather Demo Demo weather app writen in Golang using Bubble Tea. Video Instructions go mod download go build ./go-tea-weather Discl

Nov 17, 2022
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.

toc toc TOC, table of content generator for Markdown files Table of Contents Table of Contents Usage Installation Packages Arch Linux Homebrew Docker

Dec 29, 2022
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
A toaster component for hogosuru framework
A toaster component for hogosuru framework

Toaster component for hogosuru Toaster implementation for hogosuru How to use? Create a hogosurutoaster.Toaster or attach it to a hogosuru container a

Mar 24, 2022