dantleech,
@dantleech@fosstodon.org avatar

have ported the best part of the Canvas widget from Ratatui to tui. It supports braille!

video/mp4

dantleech,
@dantleech@fosstodon.org avatar

ported the chart widget today, tomorrow I'll tackle the list/table widget...

video/mp4

dantleech,
@dantleech@fosstodon.org avatar

List and Table widgets done, just the BarChart widget to reproduce the original Rust TUI demo, after that going to switch to polishing and documentation... (oops, actually BarChart, Tab, Sparkline and Gauge, but meh... can do them later)

dantleech,
@dantleech@fosstodon.org avatar

Today I created a crossterm-rs-like terminal abstraction for low-level control

need to spend some time on the API namings and design 😅

dantleech,
@dantleech@fosstodon.org avatar

so the next interesting part is parsing output from /dev/tty into events, in addition to key input, it should allow mouse support and some other stuff. Will be borrowing heavily from crossterm as there's .... lots of detail.

dantleech,
@dantleech@fosstodon.org avatar

now ported / reimplemented a useful chunk of the crossterm "event" system, so you can pop events (e.g. sanitised key presses, focus, terminal resize) from a buffer. also it's calling out to stty to do a couple of things like (un)setting "raw" mode and disabling "echo".

also there's a "logo":

dantleech,
@dantleech@fosstodon.org avatar

making a demo app, could totally make a pong or space invaders game 😅 (and yes there's a bug with the cell styles!)

dantleech,
@dantleech@fosstodon.org avatar

I'm just about happy with the API now, although some widgets are missing from the ratatui port, and some features are missing from the crossterm port, all the bases are covered.

time to write + generate documentation... thinking a github page, probably Sphinx/RST although tempted to use Hugo 🤔

dantleech,
@dantleech@fosstodon.org avatar

Docs have started: https://php-tui.github.io/php-tui

  • Widget docs are generated from source.
  • Code examples execute in CI...
  • and I wrote a parser to read the raw ANSI exampe output ...
  • and they are painted back to the docs (only using text atm, but can hopefully get colourful HTML working soon)

Still a bunch of work to do, hope I don't get a job this week 😅

kitchen,
@kitchen@simian.rodeo avatar

@dantleech it would be an understatement to say I don’t love php but I do love me some TUI goodness and it’s been real exciting following this journey ❤️

dantleech,
@dantleech@fosstodon.org avatar

@kitchen PHP is pretty OK depending on which rock you find it under. Probably not the best choice for a TUI but 🤷 . have enjoyed following your journey too 😄

dantleech,
@dantleech@fosstodon.org avatar

added support for rendering "sprites" and RGB colors

i think the next step will be rendering bitmap fonts (and porting yet another Rust library) for some 90s nostalgia.

dantleech,
@dantleech@fosstodon.org avatar

have created the BNF font parser and can render text!

i know how I'm going to make this slide deck...

video/mp4

Pol,
@Pol@mathstodon.xyz avatar

@dantleech
Maaan, excellent !

dantleech,
@dantleech@fosstodon.org avatar

today I'm going to think about introducing an image widget, taking inspiration from https://github.com/rivo/tview/tree/master

dantleech,
@dantleech@fosstodon.org avatar

well image magick made this easy:

dantleech, (edited )
@dantleech@fosstodon.org avatar

terminal photo album?

abmurrow,
@abmurrow@fosstodon.org avatar

@dantleech
Terminal photo album 🤚
Minecraft photo filter 👉

ciaran,
@ciaran@social.ciaranmc.com avatar

@dantleech witchcraft

nicemicro,
@nicemicro@fosstodon.org avatar

@dantleech someone maxed out pixel art :D

Anachron,
@Anachron@fosstodon.org avatar

@dantleech

you haven't heard of https://github.com/hzeller/timg yet?

dantleech,
@dantleech@fosstodon.org avatar

@Anachron interesting!

dantleech,
@dantleech@fosstodon.org avatar

Having a go at rendering terminal cells in HTML for the docs.

My CSS and HTML skills are a bit rusty, not sure if there is a better way than adding <span style="<blah>" for each char.

But here it is: https://php-tui.github.io/php-tui/docs/reference/shapes/imageshape/

Definite improvement on just having <pre>

MaZderMind,
@MaZderMind@chaos.social avatar

@dantleech You could use a canvas with scale mode set to pixelated and then either directly access the pixel data or use the pixel setters: https://stackoverflow.com/a/10525163

dantleech,
@dantleech@fosstodon.org avatar

@MaZderMind that would be better, thanks!

dantleech,
@dantleech@fosstodon.org avatar

there are some architectural changes I'm thinking of making vs. Ratatui:

  1. Ratatui's widgets render themsevles ... which is convenient, but it does mean you probably need global state at some point (caching, or loading fonts for example).

I'm thinking to split the widget data from a widget rendering service which can have fat dependencies - so each widget will (mostly) require 2 classes - the lightweight widget (config and state) and the renderer.

dantleech,
@dantleech@fosstodon.org avatar
  1. Ratatui uses the builder pattern extrensively to mutate the widgets. This is mostly convenient, but also adds complexity, considering dropping the builder pattern and just using navitve constructors... but then you'd still want static constructors and then it all starts to get complicated again.
Pol,
@Pol@mathstodon.xyz avatar

@dantleech
I prefer to use native stuff than a wrong pattern.

dantleech,
@dantleech@fosstodon.org avatar

@Pol context is this:

new Paragraph(  
 new Text([  
 new Line([  
 new Span(  
 'Hello World',   
 AnsiColor::Green  
 )  
 ])  
 ])  
)  

vs this:

Paragraph::fromString(  
 'Hello World'  
)->color(AnsiColor::Green)  

also torn on mutability here

Pol,
@Pol@mathstodon.xyz avatar

@dantleech Indeed. IMHO, I would use that (using new) internally and eventually propose shortcuts through static functions or another pattern.

dantleech,
@dantleech@fosstodon.org avatar

Today I've ported mouse support to PHP-Term:

video/mp4

dantleech,
@dantleech@fosstodon.org avatar

I've switched the HTML rendering to use the Canvas - and the percentage of "code" that is HTML has dropped from 73% to just 35% 😌

ciaran,
@ciaran@social.ciaranmc.com avatar

@dantleech is that a good or bad thing?

Can I make a plea to consider a11y?

dantleech,
@dantleech@fosstodon.org avatar

@ciaran better considering each terminal cell was previously a span with a ton of inline styles and a character in it.

as for a11y - the context is rendering examples in the docs:

https://php-tui.github.io/php-tui/docs/reference/shapes/imageshape/

not sure how to make that accessible really, <canvas> is surely better than a ton of spans though...

hoping somebody that actually knows CSS can help out at some point :D

dantleech,
@dantleech@fosstodon.org avatar

and I've tagged the first version at 0.0.1. Still some big changes to come, but I've got through the first round of issues.

https://packagist.org/packages/php-tui/php-tui

Thanks also to Kenedy Tedesco for contributing lots of small fixes and improvements!

dantleech,
@dantleech@fosstodon.org avatar

Gauges (or Guages as I seem to want to spell it)

dantleech,
@dantleech@fosstodon.org avatar

not one of the sexiest widgets, and one of the more tedious to port: the BarChart.

Will have to add legends and axis at some point (which are missing from Ratatui)

wyri,
@wyri@haxim.us avatar

@dantleech Sweeet!

dantleech,
@dantleech@fosstodon.org avatar

adding a new "color" type LinearGradient will be available on all widgets!

dantleech,
@dantleech@fosstodon.org avatar

... and added support for angle and point of origin and ordered "trigonometry for dummies" from Amazon.

dantleech,
@dantleech@fosstodon.org avatar

thinking it would be a great PoC to add a @phpbench extension which uses PHP-TUI for progress widgets and reports (and include that extension as a dev depdency for PHP-TUIs benchmarks)

dantleech,
@dantleech@fosstodon.org avatar

... also thanks to @KennedyTedesco PHP-TUI supports a subset of the Symfony Console markup:

Instead of:

Line::fromSpans(Span::fromString('foo')-&gt;green(), Span::fromString('bar')-&gt;red()-&gt;onBlack())  

(which is already an improvement on an even more verbose API)

you can use:

Line::parse('&lt;fg=green&gt;foo&lt;/&gt;&lt;fg=red bg=black&gt;bar&lt;/&gt;');  
dantleech,
@dantleech@fosstodon.org avatar

round 2 of documentation done: https://php-tui.github.io/php-tui the docs are getting better... (well, some of it got slightly worse, but more steps forward than back)

dantleech,
@dantleech@fosstodon.org avatar

I've tagged a 0.0.2 of TUI - lots of bug fixes, linear gradient and the gauge, image, and barchart widgets, DX improvements for styling, inline and fixed viewports and more and a slightly pimped up README:

https://github.com/php-tui/php-tui/releases/tag/0.0.2

dantleech, (edited )
@dantleech@fosstodon.org avatar

I've just added multibyte support to php-term, which I think pretty much brings it closer to parity with crossterm in terms of event parsing

dantleech,
@dantleech@fosstodon.org avatar

Spent (checks watch) today improving the ANSI parsing and making the resulting generated terminal examples better:

still not perfect though (check Colors > Linear Gradient) which is frustrating.

https://php-tui.github.io/php-tui/docs/guides/getting-started/

dantleech,
@dantleech@fosstodon.org avatar

starting to feel I should "cash in" and finish it off this week.

The whole thing is pretty much there now, I want to split the "term" and BDF parsing libs out, maybe implement a few more widgets.

made good progress with a "text editor" but might put that to one side as it's a large and ill-defined undertaking

dantleech,
@dantleech@fosstodon.org avatar

I've split out the Term library, it provides comprehensize terminal manipulation and querying, based heavily on Rust's crossterm library:

  • emits and parses a large number of CSI and OSC escape codes
  • mouse capture events
  • various keyboard events
  • sets raw mode
  • terminal size

https://github.com/php-tui/term

dantleech, (edited )
@dantleech@fosstodon.org avatar

... and with Sparkline and Tab widgets I've ported all the widgets I'm going to port (the only remaining one is the "calendar" widget, but meh).

They could all be improved (and maybe I could port some imporvements back to Ratatui), but basically that's it.

I ported Ratatui.

/endofthread

dantleech,
@dantleech@fosstodon.org avatar

and with that I've tagged 0.1.0

https://github.com/php-tui/php-tui/releases/tag/0.1.0

thanks to @KennedyTedesco for all the help!

kitchen,
@kitchen@simian.rodeo avatar

@dantleech I won’t lie and say I love php but I will say it’s been a hell of a lot of fun watching you do this and seeing the awesome results. Fucking great job!

dantleech,
@dantleech@fosstodon.org avatar

@kitchen thanks!

wyri,
@wyri@haxim.us avatar

@dantleech are you planning on adding a progress bar?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • tacticalgear
  • DreamBathrooms
  • cisconetworking
  • magazineikmin
  • InstantRegret
  • Durango
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • mdbf
  • khanakhh
  • kavyap
  • everett
  • JUstTest
  • modclub
  • Leos
  • cubers
  • ngwrru68w68
  • ethstaker
  • osvaldo12
  • GTA5RPClips
  • anitta
  • provamag3
  • normalnudes
  • tester
  • megavids
  • lostlight
  • All magazines