| ... | @@ -14,15 +14,15 @@ const expectFmt = std.testing.expectFmt; | ... | @@ -14,15 +14,15 @@ const expectFmt = std.testing.expectFmt; |
| 14 | pub const default_max_depth = 3; | 14 | pub const default_max_depth = 3; |
| 15 | | 15 | |
| 16 | pub const Alignment = enum { | 16 | pub const Alignment = enum { |
| 17 | Left, | 17 | left, |
| 18 | Center, | 18 | center, |
| 19 | Right, | 19 | right, |
| 20 | }; | 20 | }; |
| 21 | | 21 | |
| 22 | pub const FormatOptions = struct { | 22 | pub const FormatOptions = struct { |
| 23 | precision: ?usize = null, | 23 | precision: ?usize = null, |
| 24 | width: ?usize = null, | 24 | width: ?usize = null, |
| 25 | alignment: Alignment = .Right, | 25 | alignment: Alignment = .right, |
| 26 | fill: u8 = ' ', | 26 | fill: u8 = ' ', |
| 27 | }; | 27 | }; |
| 28 | | 28 | |
| ... | @@ -252,11 +252,11 @@ pub const Placeholder = struct { | ... | @@ -252,11 +252,11 @@ pub const Placeholder = struct { |
| 252 | else => {}, | 252 | else => {}, |
| 253 | } | 253 | } |
| 254 | break :init switch (ch) { | 254 | break :init switch (ch) { |
| 255 | '<' => .Left, | 255 | '<' => .left, |
| 256 | '^' => .Center, | 256 | '^' => .center, |
| 257 | else => .Right, | 257 | else => .right, |
| 258 | }; | 258 | }; |
| 259 | } else .Right; | 259 | } else .right; |
| 260 | | 260 | |
| 261 | // Parse the width parameter | 261 | // Parse the width parameter |
| 262 | const width = comptime parser.specifier() catch |err| | 262 | const width = comptime parser.specifier() catch |err| |
| ... | @@ -1034,18 +1034,18 @@ pub fn formatBuf( | ... | @@ -1034,18 +1034,18 @@ pub fn formatBuf( |
| 1034 | return writer.writeAll(buf); | 1034 | return writer.writeAll(buf); |
| 1035 | | 1035 | |
| 1036 | switch (options.alignment) { | 1036 | switch (options.alignment) { |
| 1037 | .Left => { | 1037 | .left => { |
| 1038 | try writer.writeAll(buf); | 1038 | try writer.writeAll(buf); |
| 1039 | try writer.writeByteNTimes(options.fill, padding); | 1039 | try writer.writeByteNTimes(options.fill, padding); |
| 1040 | }, | 1040 | }, |
| 1041 | .Center => { | 1041 | .center => { |
| 1042 | const left_padding = padding / 2; | 1042 | const left_padding = padding / 2; |
| 1043 | const right_padding = (padding + 1) / 2; | 1043 | const right_padding = (padding + 1) / 2; |
| 1044 | try writer.writeByteNTimes(options.fill, left_padding); | 1044 | try writer.writeByteNTimes(options.fill, left_padding); |
| 1045 | try writer.writeAll(buf); | 1045 | try writer.writeAll(buf); |
| 1046 | try writer.writeByteNTimes(options.fill, right_padding); | 1046 | try writer.writeByteNTimes(options.fill, right_padding); |
| 1047 | }, | 1047 | }, |
| 1048 | .Right => { | 1048 | .right => { |
| 1049 | try writer.writeByteNTimes(options.fill, padding); | 1049 | try writer.writeByteNTimes(options.fill, padding); |
| 1050 | try writer.writeAll(buf); | 1050 | try writer.writeAll(buf); |
| 1051 | }, | 1051 | }, |