[HN Gopher] Rich Tables in the Terminal ___________________________________________________________________ Rich Tables in the Terminal Author : willm Score : 211 points Date : 2020-07-05 12:07 UTC (10 hours ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | miguelmota wrote: | This is sweet. Is there an equivalent of this library for Go? | Particularly with scrolling support | omani wrote: | Im using https://github.com/olekukonko/tablewriter in Go. | zemnmez wrote: | this is awesome! Terminal programs are so satisfying, but at the | same time it always feels like they miss so many primitives that | I take for granted for content display | willm wrote: | That was my main motivation in working in Rich. Whenever I move | from the frontend to the backend, I miss what the browser can | do so effortlessly. | 2ion wrote: | kitty terminal has built-in extensions to xterm terminal protocol | extensions to make this kind of thing much easier, toda. Hacking | the terminal is nice but another way is moving forward in | developing it. | Anthony-G wrote: | This looks really impressive: elegant and beautiful with an easy- | to-use API. I don't know if submission titles can be edited 9 | hours after posting but this would be an excellent addition to | _Show HN_ and might get more attention as such. | | https://news.ycombinator.com/showhn.html | xixixao wrote: | This makes me think how close this is to HTML output + DOM | rendering, and what would be the proc and cons of each, how could | you get max pros of the CLI approach into the HTML approach. | willm wrote: | My goal was to bring some of the capabilities of HTML to the | console. The browser is always going to win in terms of | capabilities. | a_t48 wrote: | That traceback handler is awesome. I wonder if there's a way to | hook all my python programs to use it. | chameleon_world wrote: | You can, the instructions are here: | https://rich.readthedocs.io/en/latest/traceback.html | | But it is noticeably slower than the default python handler | a_t48 wrote: | Slower in what way? Just on crash? I don't mind that. But I | meant for programs I _don't_ typically write source for - if | Python has a way to run code before every program start up it | would do what I want. | willm wrote: | Its slower when it renders the traceback, all that reading | of source and syntax highlighting takes second or two. | There is a way of importing something automatically, see | the sites module docs. | mattatkeyboard wrote: | Naff tables (along with poor graphs) was one of my key | motivations to create WV Linweise, which spawns a tiny web | renderer to make displays nicer... Love the terminal, but some | things it is just not great at... | | This mini example app renders CSV data from STDIN into a HTML | tables - https://github.com/forbesmyester/wv- | linewise/tree/master/exa... | easterncalculus wrote: | Rich is great. Have been using it for a couple of projects and | the support is great, even on terminals with less color support. | willm wrote: | I'm glad you find it useful! | kureikain wrote: | Can It detect non terminal output and render normal ascii such as | when pipe/redirect stdout/stderror to a file? or pipe to seed and | avoid messing up with color code. | | I recently release a tool with a nice table but many hate the | format, the color and it even make `grep` impossible because | color code make grep match every line :-( | willm wrote: | Yes, Rich will remove escape sequences when not writing to a | terminal. | the8472 wrote: | This may be heresey, but does it support mouse interaction, e.g. | sorting by clicking on the column header like midnight commander | does? | willm wrote: | No, the animation was for demo purposes. It's not normally | dynamic. | gonewb wrote: | Is this using ncurses? | sxp wrote: | https://github.com/willmcgugan/rich/blob/master/rich/console... | shows that's it's directly using escape codes: http://ascii- | table.com/ansi-escape-sequences-vt-100.php | eepp wrote: | looks like it hardcodes escape sequences with no regard to | the current terminal. | JdeBP wrote: | It's not using ncurses nor terminfo, but it's very misleading | to point to a list of VT100 escape sequences when it most | definitely is not doing things the VT100 way _either_. | | In contrast to the monochrome VT100 this is using colour | quite significantly, albeit not supporting the recent | corrections of a widespread mistake; and it even seems to | support the rare framed and encircled attributes of later | ECMA-48. Also in contrast to the VT100 it nowhere seems to | deal in double-height or double-width, nor is it using | ECMA-35 character set switching. | detaro wrote: | doesnt seem so | dang wrote: | Related from a few months ago: | https://news.ycombinator.com/item?id=23070821 | enricozb wrote: | Those progress bars look delicious | reaperducer wrote: | I agree. | | Also: My kingdom for rsync with progress bars. | oblio wrote: | He he! Souped up IBM PC box drawing characters, circa 1981: | https://en.m.wikipedia.org/wiki/Box-drawing_character | ishcheklein wrote: | This looks awesome! Gonna try to use it for DVC where we need to | show tables of experiments, metrics, etc. | teddyh wrote: | This seems to only support rendering. If you also want | interactive use, another library which does things like this is | Urwid: | | http://urwid.org/examples/ | cosmotic wrote: | This seems to be begging the question: At what point does one | move to a GUI? GUIs are well suited for these tasks. | makecheck wrote: | Terminal features work better across all platforms than most | GUIs. They are more likely to have efficient keyboard commands | for everything. And if (say) you wanted to Copy arbitrary text | from anywhere in the terminal, you can (a GUI would have to | explicitly support Copy for the things it presents). | | Clearly GUIs have a place but terminal UIs are really powerful. | bluedays wrote: | I started using this in a project of mine a few days ago and I | highly recommend this library. It is super intuitive and easy. | yjftsjthsd-h wrote: | So, it _is_ cool; let me say that much before I criticize. That | said: live resizing a table is a bit of a pain if you 're trying | to select something (to copy or to highlight it to show someone | else). It's like a webpage that moves a link just as you click. | Is there any way to fix the width and append only to the end? | (Just optionally; I understand why it resizes dynamically by | default) | dredmorbius wrote: | Best suggestion I've seen is for the interface to respond to | what was at the point of interaction ~300ms _before_ the click | or touch action. | willm wrote: | The animation is purely for demonstration purposes. Generally | you would use this to render a formatted table as the result of | a CLI. | 1996 wrote: | IF you want to add other things to the CLI, like graphics or | unicode, check this library: | | https://gitlab.com/klamonte/jexer ___________________________________________________________________ (page generated 2020-07-05 23:00 UTC)