diff --git a/src/cli_args.zig b/src/cli_args.zig index 70a918369..8afb35e65 100644 --- a/src/cli_args.zig +++ b/src/cli_args.zig @@ -144,6 +144,11 @@ fn parseIntoField( 0, ), + f64 => try std.fmt.parseFloat( + f64, + value orelse return error.ValueRequired, + ), + else => unreachable, }; @@ -298,6 +303,20 @@ test "parseIntoField: unsigned numbers" { try testing.expectEqual(@as(u8, 1), data.u8); } +test "parseIntoField: floats" { + const testing = std.testing; + var arena = ArenaAllocator.init(testing.allocator); + defer arena.deinit(); + const alloc = arena.allocator(); + + var data: struct { + f64: f64, + } = undefined; + + try parseIntoField(@TypeOf(data), alloc, &data, "f64", "1"); + try testing.expectEqual(@as(f64, 1.0), data.f64); +} + test "parseIntoField: optional field" { const testing = std.testing; var arena = ArenaAllocator.init(testing.allocator); diff --git a/src/config.zig b/src/config.zig index c1c9f1f72..63038c74a 100644 --- a/src/config.zig +++ b/src/config.zig @@ -63,6 +63,10 @@ pub const Config = struct { /// The color of the cursor. If this is not set, a default will be chosen. @"cursor-color": ?Color = null, + /// The opacity level (opposite of transparency) of the background. + /// A value of 1 is fully opaque and a value of 0 is fully transparent. + @"background-opacity": f64 = 1.0, + /// The command to run, usually a shell. If this is not an absolute path, /// it'll be looked up in the PATH. If this is not set, a default will /// be looked up from your system. The rules for the default lookup are: @@ -754,6 +758,7 @@ pub const Config = struct { switch (@typeInfo(T)) { inline .Bool, .Int, + .Float, => return src, .Optional => |info| return try cloneValue( @@ -879,6 +884,7 @@ fn equal(comptime T: type, old: T, new: T) bool { inline .Bool, .Int, + .Float, .Enum, => return old == new,