Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.
/ uvcasso Public archive

🏗️ Cassowary layout splitting for TUI

License

Notifications You must be signed in to change notification settings

metafates/uvcasso

Repository files navigation

Note

This code is now a part of charmbracelet/ultraviolet.


🏗️ uvcasso

Layout splitting for charmbracelet/ultraviolet based on Cassowary constraint-solving algorithm.

TL;DR

It allows you to dynamically split terminal screen into multiple rectangles based on the given constraints.

For example:

func display(s *uv.TerminalScreen) {
	screen.Clear(s)

	var top, bottom uv.Rectangle

	uvcasso.Vertical(
		uvcasso.Fill(1),
		uvcasso.Len(1),
		uvcasso.Len(3),
	).
		Split(s.Bounds()).
		Assign(&top, nil, &bottom)

	// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
	// The interesting part

	screen.FillArea(s, &uv.Cell{
		Content: "T",
		Width:   1,
	}, top)

	screen.FillArea(s, &uv.Cell{
		Content: "B",
		Width:   1,
	}, bottom)

	// Will fill the screen like this:
	// 1. Top part takes all available space
	// 2. Middle part takes exactly 1 line which we leave empty
	// 3. Bottom part takes exactly 3 lines

	/*
	   TTTTTTTTTTTTTTTT
	   TTTTTTTTTTTTTTTT
	   TTTTTTTTTTTTTTTT
	   TTTTTTTTTTTTTTTT
	   TTTTTTTTTTTTTTTT

	   BBBBBBBBBBBBBBBB
	   BBBBBBBBBBBBBBBB
	   BBBBBBBBBBBBBBBB
	*/

	s.Render()
	s.Flush()
}

Acknowledgements

This code is roughly 1:1 translation of how it's implemented in the ratatui, including the tests.

About

🏗️ Cassowary layout splitting for TUI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages