Repository navigation
Contributing
Contributions are welcome across runtime behavior, widgets, examples, tests, documentation, and design. The project favors small typed layers, visible ownership, and tests that exercise the same buffers users see.
:::tip In a hurry?
CONTRIBUTING.md
at the repository root is the short version: the exact command block to run before
pushing, and the six checks that gate a merge. This page is the long version — the
architecture rules a change has to respect, how to add a widget end to end, and how to
write the pull request.
:::
Needs JDK 25 or newer — every published artifact declares -release:25. ./mill pins
its own build process to temurin:25 via .mill-jvm-version regardless of what is on
PATH, so a mismatched ambient JDK will not silently produce 21-compatible class files,
but a real JDK 25+ install is still required to run the ./mill launcher itself.
Building an example's native image additionally needs GraalVM graalvm-community:25.0.2
(Mill downloads it), which has no macOS x64 build past 25.0.1 — override
TuiExampleModule.jvmVersion in build.mill locally on an Intel Mac.
git clone git@github.com:oleksandr-balyshyn/glyphora.git
cd glyphora
./mill __.compile
# tests, one module at a time — the sequence CI runs
./mill core.test
./mill terminal.test
./mill widgets.test
./mill runtime.test
./mill macros.test
./mill dsl.test
./mill test-support.testEvery examples/<name> module has a suite too (./mill examples.showcase.test, and so
on); CI runs one job per example, discovered from the examples/ directory.
Run the tests per module rather than as ./mill __.test. That is what CI does, and
for a reason worth knowing: a single combined step only ever reports "still running",
so a module that hangs cannot be told apart from a module that is merely slow. One
command per module names the culprit immediately.
The build uses Mill. Every Scala module has a package.mill; shared Scala version,
strict compiler flags, ScalaTest wiring, and publication metadata live in
build.mill. Two shared traits carry the repetition: TuiPilotTests is a test
submodule that can also drive a whole app through Pilot, and TuiExampleModule is
everything an examples/<name> module needs — the GraalVM pin, --no-fallback, and
that test submodule — so an example's own package.mill declares only its
moduleDeps and its mainClass.
Useful development commands:
# Apply Scala formatting
./mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources
# Verify formatting without changing files
./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
# Run one module or example suite
./mill widgets.test
./mill examples.todo-list.test
# Manual terminal test bed
./mill examples.showcase.run
# Render-loop sanity check
./mill widgets.test.runMain io.worxbend.tui.widgets.RenderLoopBenchCI enforces constraints that protect the design:
- no
java.lang.reflectorClass.forNamein main Scala sources — the examples' sources included, since those are what people copy from; - no
String.substringfor layout math outsideCharWidth(the weather example's JSON parser is excluded by name: it indexes offsets in an ASCII wire format, which is not layout math); - warnings are errors (
-deprecation -feature -unchecked -Wunused:all -Werror); - Scalafmt owns formatting;
- all tests run headlessly on Linux, which is the only platform CI covers;
- every example compiles with GraalVM
--no-fallback, and every binary is then run with no TTY and has to exit1printingterminal not supported— the CI list is derived fromexamples/*/package.mill, so adding a module is enough.
For general Scala conventions, read
SCALA_CODE_STYLE.md.
-
Choose state ownership. A stateless widget implements
Widget; an interactive or scrollable renderer usesStatefulWidget[S], with state owned by the caller. -
Order the constructor parameters the same way every other widget does: required
data first, then
style, then any specialised styles, then glyph/symbol overrides. A reader can then tell content from appearance at the call site without opening the widget. -
Implement in
widgets/, in its own file named after the widget. Depend only ontui-core. Render inside the suppliedRect, clip safely, and route all visible-width logic throughCharWidth. A render rule two widgets share belongs in aprivate[widgets]object named for the concept, not copied into both. -
Test the buffer. Cover empty and tiny areas, normal content, truncation,
Unicode, selection/focus style, and state boundaries with
BufferAssertions. -
Add the DSL element. Put its retained data and built-in key/mouse behavior in the
node-family file it belongs to (
LayoutElements.scala,ChoiceElements.scala, and so on —Element.scalaholds only theElementtrait). Declaretype Selfas the node's own type so the fluent builders keep giving it back. Add a factory inElementFactories.scalaand export it fromdsl.scala. -
Test interaction. Use
Pilotfor focus, keys, mouse behavior, resize, and redraw when the widget is interactive. - Document it. Add it to Widget catalog, provide a short realistic snippet, and use it in an example when it introduces a new pattern.
Keep user handlers ahead of built-in behavior and return false when an event should
continue bubbling.
- Put the API in the lowest layer that can own it without creating an upward dependency.
- Prefer data types, sealed ADTs, and direct calls over runtime discovery.
- Write Scaladoc that explains ownership, thread constraints, and edge behavior—not only parameter names.
- Add tests at the owning layer and an integration test when multiple layers must cooperate.
- Update the task guide and API usage examples in the same pull request.
Canonical guide Markdown lives in website/docs/. Docusaurus publishes it to
GitHub Pages and scripts/export-wiki.mjs turns the same pages/navigation into the
GitHub Wiki.
cd website
npm ci
npm run build
cd ..
node scripts/export-wiki.mjs --output build/wikiFollow docs/STYLE_GUIDE.md:
lead with the reader's outcome, explain why, include a verified snippet, name the
terminal-specific pitfalls, and point to the next useful guide. Assets shared by the
README, Pages, and Wiki belong in docs/assets/.
When adding a page, add its ID to website/docs-navigation.mjs; that one navigation
tree drives both Docusaurus and the generated Wiki sidebar.
- Keep the change focused and explain the user-visible outcome first.
- Include commands you ran and any terminal/emulator used for manual verification.
- Add screenshots only when the change is genuinely visual; prefer text/buffer assertions for behavior.
- Call out public API and native-image implications explicitly.
- Do not commit generated
website/buildorbuild/wikioutput.
Before pushing:
./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
./mill __.fix --check # main *and* test sources
./mill __.compile
./mill core.test
./mill terminal.test
./mill widgets.test
./mill runtime.test
./mill macros.test
./mill dsl.test
./mill test-support.test
(cd website && npm run build)
node scripts/export-wiki.mjs --output build/wikiDocumentation is maintained in website/docs. Read the styled guide · API reference · MIT license