mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
add keybind actions docs to manpages
This commit is contained in:
@ -3,6 +3,7 @@ const help_strings = @import("help_strings");
|
||||
const build_options = @import("build_options");
|
||||
const Config = @import("../../config/Config.zig");
|
||||
const Action = @import("../../cli/action.zig").Action;
|
||||
const KeybindAction = @import("../../input/Binding.zig").Action;
|
||||
|
||||
pub fn substitute(alloc: std.mem.Allocator, input: []const u8, writer: anytype) !void {
|
||||
const version_string = try std.fmt.allocPrint(alloc, "{}", .{build_options.version});
|
||||
@ -83,3 +84,35 @@ pub fn genActions(writer: anytype) !void {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn genKeybindActions(writer: anytype) !void {
|
||||
try writer.writeAll(
|
||||
\\
|
||||
\\# KEYBIND ACTIONS
|
||||
\\
|
||||
\\
|
||||
);
|
||||
|
||||
const info = @typeInfo(KeybindAction);
|
||||
std.debug.assert(info == .Union);
|
||||
|
||||
inline for (info.Union.fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
|
||||
try writer.writeAll("`");
|
||||
try writer.writeAll(field.name);
|
||||
try writer.writeAll("`\n\n");
|
||||
|
||||
if (@hasDecl(help_strings.KeybindAction, field.name)) {
|
||||
var iter = std.mem.splitScalar(u8, @field(help_strings.KeybindAction, field.name), '\n');
|
||||
var first = true;
|
||||
while (iter.next()) |s| {
|
||||
try writer.writeAll(if (first) ": " else " ");
|
||||
try writer.writeAll(s);
|
||||
try writer.writeAll("\n");
|
||||
first = false;
|
||||
}
|
||||
try writer.writeAll("\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ pub fn main() !void {
|
||||
const output = std.io.getStdOut().writer();
|
||||
try gen.substitute(alloc, @embedFile("build/mdgen/ghostty_5_header.md"), output);
|
||||
try gen.genConfig(output, false);
|
||||
try gen.genKeybindActions(output);
|
||||
try gen.substitute(alloc, @embedFile("build/mdgen/ghostty_5_footer.md"), output);
|
||||
}
|
||||
|
Reference in New Issue
Block a user