print float parameters with decimal notation

This commit is contained in:
Luna 2020-06-01 23:58:56 -03:00
parent ee7ffd1be7
commit 5235482ab4
1 changed files with 7 additions and 2 deletions

View File

@ -1,9 +1,14 @@
const std = @import("std");
const langs = @import("lang.zig");
fn printCommandWithParams(stream: var, command: var) !void {
const Parameters = @TypeOf(command.parameters);
inline for (@typeInfo(Parameters).Struct.fields) |field| {
try stream.print(" {}", .{@field(command.parameters, field.name)});
if (field.field_type == f32 or field.field_type == f64) {
try stream.print(" {d}", .{@field(command.parameters, field.name)});
} else {
try stream.print(" {}", .{@field(command.parameters, field.name)});
}
}
}
@ -42,7 +47,7 @@ pub fn printList(list: langs.CommandList, stream: var) !void {
.noop, .quicksave => {},
.rotate => {
const rotate = cmd.cast(langs.Command.Rotate).?;
try stream.print(" {} {}", .{ rotate.deg, rotate.bgfill });
try stream.print(" {d} {}", .{ rotate.deg, rotate.bgfill });
},
.amp => try printCommand(stream, cmd, .amp),