reykjalin/fn
Editor backend and TUI editor written in Zig
84d6cb381c0d628550fac3f6daa24c5faf7b2cd1
e8e6bb21c22d3e04374bf265ba48162a53b018c8
This repo contains 2 projects: libfn
, and Fönn. libfn
is an editor engine that I'm working on for fun. Fönn is a code editor powered by libfn
.
My primary goal is to eventually have a modern, capable TUI code editor that's powered by a reusable editing engine. The engine itself will eventually be exposed as a static library with a C API, but made in Zig. If I can get this project that far that is :)
A secondary goal is for fn
to eventually have both a GUI and a TUI powered by this same text
editing "engine".
❄️ Fönn: A code editor for fun.
This is currently a toy project, but fn
is stable enough that I'm exclusively using it when working on changes to the editor.
My primary goal is to have a modern, capable TUI code editor.
A secondary goal is for fn
to eventually have both a GUI and a TUI powered by the same text editing "engine".
# Debug build in ./zig-out/bin/fn.
zig build -Dtui
# Run debug build in current directory.
zig build run -Dtui
# Open a file with debug build.
zig build run -Dtui -- path/to/file
# Release build in ~/.local/bin/fn.
zig build -Dtui -Doptimize=ReleaseSafe --prefix ~/.local
$ fn --help
Usage: fn [file]
General options:
-h, --help Print fn help
-v, --version Print fn version
If you're working on a Zig project and want to play around with the library itself you can do so by
installing fun with zig fetch --save git+https://git.sr.ht/~reykjalin/fn
.
# Make sure libfn builds.
zig build check
# Run tests.
zig build test
$ zig fetch --save git+https://git.sr.ht/~reykjalin/fn
Then, in your build.zig
:
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const libfn_dep = b.dependency("libfn", .{ .optimize = optimize, .target = target });
const exe = b.addExecutable(.{
.name = "example",
.root_source_file = root_source_file,
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("libfn", libfn_dep.module("libfn"));
b.installArtifact(exe);
and then you can import it in your code:
const libfn = @import("libfn");
// ...
const editor: libfn.Editor = .init(allocator);