add(examples/layout): vertical, horizontal and grid
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 39s

This commit is contained in:
2025-02-21 11:31:18 +01:00
parent 69c1600eb9
commit 9dc1a4b95a
8 changed files with 369 additions and 209 deletions

View File

@@ -5,12 +5,17 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const Examples = enum {
// elements:
input,
layout,
scrollable,
// layouts:
vertical,
horizontal,
grid,
// styles:
};
const example = b.option(Examples, "example", "Example to build and/or run. (default: layout)") orelse .layout;
const example = b.option(Examples, "example", "Example to build and/or run. (default: vertical)") orelse .vertical;
const options = b.addOptions();
options.addOption(Examples, "example", example);
@@ -29,7 +34,9 @@ pub fn build(b: *std.Build) void {
});
lib.addImport("code_point", zg.module("code_point"));
// Examples.Input
//--- Examples ---
// elements:
const input = b.addExecutable(.{
.name = "input",
.root_source_file = b.path("examples/input.zig"),
@@ -38,29 +45,49 @@ pub fn build(b: *std.Build) void {
});
input.root_module.addImport("zterm", lib);
// Examples.Layout
const layout = b.addExecutable(.{
.name = "layout",
.root_source_file = b.path("examples/layout.zig"),
.target = target,
.optimize = optimize,
});
layout.root_module.addImport("zterm", lib);
// Examples.Scrollable
const scrollable = b.addExecutable(.{
.name = "scrollable",
.root_source_file = b.path("examples/scrollable.zig"),
.root_source_file = b.path("examples/elements/scrollable.zig"),
.target = target,
.optimize = optimize,
});
scrollable.root_module.addImport("zterm", lib);
// layouts:
const vertical = b.addExecutable(.{
.name = "vertical",
.root_source_file = b.path("examples/layouts/vertical.zig"),
.target = target,
.optimize = optimize,
});
vertical.root_module.addImport("zterm", lib);
const horizontal = b.addExecutable(.{
.name = "horizontal",
.root_source_file = b.path("examples/layouts/horizontal.zig"),
.target = target,
.optimize = optimize,
});
horizontal.root_module.addImport("zterm", lib);
const grid = b.addExecutable(.{
.name = "grid",
.root_source_file = b.path("examples/layouts/grid.zig"),
.target = target,
.optimize = optimize,
});
grid.root_module.addImport("zterm", lib);
// mapping of user selected example to compile step
const exe = switch (example) {
// elements:
.input => input,
.layout => layout,
.scrollable => scrollable,
// layouts:
.vertical => vertical,
.horizontal => horizontal,
.grid => grid,
// styles:
};
b.installArtifact(exe);