StructOp Handbook
Contents Examples Commands

Projects

Choose a collection below, or start with Hello world to see a declaration alongside its output. Each example includes the files used to build it. The test suite checks the output against an expected result.

For a larger program, read A worked application: the inventory manager: a window, a command line and a database file, built for C and for Rust, with its recorded output and its 13 tests on each target. It stands beside the catalogue projects counted below.

72C examples
43Rust examples
94feature examples
64terminal recordings
On this page

How to read a project page#

  1. The recording shows the program running, from structop apply onward. Games are played with a key script, one key per frame. Where no recording exists, the program's last screen stands in.
  2. The .st files contain the application declarations. Some examples also include input files, layouts or data assets.
  3. Input, plan and generated source show what was typed, what plan printed and the C or Rust source that apply wrote.

Switching the catalog examples between C and Rust#

For projects using portable providers, edit only lang in intent.st and run structop apply. A GTK 2 example pairs its C implementation with StructOp/gtk-rs for Rust. The game projects pair ncurses with bracket-lib. Both backends use the same application files, input and expected output.

The catalog check ran all 209 documented projects. Of those, 195 produced the expected output on both C and Rust, including the pointer, pointer interpolation, local pointer and zlib examples; the zlib example calls a generated C library binding from either target. The other 14 passed on their declared target and use one of the following target-specific features.

ExamplesTargetFeature
Void pointer, native expressionCEvaluate embedded C code
libc, curl, SQLite, SQLite in a functionCCall generated C library bindings that take callbacks or a library handle, which the Rust target does not support yet
Pointer after despawn, pointer after removeCKeep a pointer into component storage or into a List while that storage changes, which the Rust target does not support yet
Mini crate, standard library, curl, rusqlite, flate2, rusqlite in a windowRustCall the generated Rust crate bindings

The testing guide explains how to reproduce the catalog check.

Reading a dungeon screen#

The dungeon crawler draws its map with terminal characters. The random seed determines the layout.