mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
Use keybind actions help strings in +list-keybinds.
This commit is contained in:
@ -1,17 +1,20 @@
|
||||
const std = @import("std");
|
||||
const inputpkg = @import("../input.zig");
|
||||
const args = @import("args.zig");
|
||||
const Action = @import("action.zig").Action;
|
||||
const KeybindAction = @import("../input/Binding.zig").Action;
|
||||
const Arena = std.heap.ArenaAllocator;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const configpkg = @import("../config.zig");
|
||||
const Config = configpkg.Config;
|
||||
const help_strings = @import("help_strings");
|
||||
|
||||
pub const Options = struct {
|
||||
/// If true, print out the default keybinds instead of the ones
|
||||
/// configured in the config file.
|
||||
default: bool = false,
|
||||
|
||||
docs: bool = false,
|
||||
|
||||
pub fn deinit(self: Options) void {
|
||||
_ = self;
|
||||
}
|
||||
@ -47,6 +50,24 @@ pub fn run(alloc: Allocator) !u8 {
|
||||
defer config.deinit();
|
||||
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
if (opts.docs) {
|
||||
const info = @typeInfo(KeybindAction);
|
||||
var first = true;
|
||||
inline for (info.Union.fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
if (@hasDecl(help_strings.KeybindAction, field.name)) {
|
||||
if (!first) try stdout.print("#\n", .{});
|
||||
try stdout.print("# {s}\n", .{field.name});
|
||||
const help = @field(help_strings.KeybindAction, field.name);
|
||||
var lines = std.mem.splitScalar(u8, help, '\n');
|
||||
while (lines.next()) |line| {
|
||||
try stdout.print("# {s}\n", .{line});
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try config.keybind.formatEntry(configpkg.entryFormatter("keybind", stdout));
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user