diff options
Diffstat (limited to 'rivertile/main.zig')
| -rw-r--r-- | rivertile/main.zig | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/rivertile/main.zig b/rivertile/main.zig index d5cb8d1..d1149b1 100644 --- a/rivertile/main.zig +++ b/rivertile/main.zig @@ -29,7 +29,7 @@ const Orientation = enum { /// orientation in mind and then the input/output values are adjusted to apply /// the necessary transformations to derive the other 3. /// -/// With 4 views and one master, the left layout looks something like this: +/// With 4 views and one main view, the left layout looks something like this: /// /// +-----------------------+------------+ /// | | | @@ -49,15 +49,15 @@ pub fn main() !void { if (args.len != 7) printUsageAndExit(); // first arg must be left, right, top, or bottom - const master_location = std.meta.stringToEnum(Orientation, std.mem.spanZ(args[1])) orelse + const main_location = std.meta.stringToEnum(Orientation, std.mem.spanZ(args[1])) orelse printUsageAndExit(); // the other 5 are passed by river and described in river-layouts(7) const num_views = try std.fmt.parseInt(u32, std.mem.spanZ(args[2]), 10); - const master_count = try std.fmt.parseInt(u32, std.mem.spanZ(args[3]), 10); - const master_factor = try std.fmt.parseFloat(f64, std.mem.spanZ(args[4])); + const main_count = try std.fmt.parseInt(u32, std.mem.spanZ(args[3]), 10); + const main_factor = try std.fmt.parseFloat(f64, std.mem.spanZ(args[4])); - const width_arg: u32 = switch (master_location) { + const width_arg: u32 = switch (main_location) { .left, .right => 5, .top, .bottom => 6, }; @@ -66,32 +66,32 @@ pub fn main() !void { const output_width = try std.fmt.parseInt(u32, std.mem.spanZ(args[width_arg]), 10); const output_height = try std.fmt.parseInt(u32, std.mem.spanZ(args[height_arg]), 10); - const secondary_count = if (num_views > master_count) num_views - master_count else 0; + const secondary_count = if (num_views > main_count) num_views - main_count else 0; - // to make things pixel-perfect, we make the first master and first secondary + // to make things pixel-perfect, we make the first main and first secondary // view slightly larger if the height is not evenly divisible - var master_width: u32 = undefined; - var master_height: u32 = undefined; - var master_height_rem: u32 = undefined; + var main_width: u32 = undefined; + var main_height: u32 = undefined; + var main_height_rem: u32 = undefined; var secondary_width: u32 = undefined; var secondary_height: u32 = undefined; var secondary_height_rem: u32 = undefined; - if (master_count > 0 and secondary_count > 0) { - master_width = @floatToInt(u32, master_factor * @intToFloat(f64, output_width)); - master_height = output_height / master_count; - master_height_rem = output_height % master_count; + if (main_count > 0 and secondary_count > 0) { + main_width = @floatToInt(u32, main_factor * @intToFloat(f64, output_width)); + main_height = output_height / main_count; + main_height_rem = output_height % main_count; - secondary_width = output_width - master_width; + secondary_width = output_width - main_width; secondary_height = output_height / secondary_count; secondary_height_rem = output_height % secondary_count; - } else if (master_count > 0) { - master_width = output_width; - master_height = output_height / master_count; - master_height_rem = output_height % master_count; + } else if (main_count > 0) { + main_width = output_width; + main_height = output_height / main_count; + main_height_rem = output_height % main_count; } else if (secondary_width > 0) { - master_width = 0; + main_width = 0; secondary_width = output_width; secondary_height = output_height / secondary_count; secondary_height_rem = output_height % secondary_count; @@ -108,19 +108,19 @@ pub fn main() !void { var width: u32 = undefined; var height: u32 = undefined; - if (i < master_count) { + if (i < main_count) { x = 0; - y = i * master_height + if (i > 0) master_height_rem else 0; - width = master_width; - height = master_height + if (i == 0) master_height_rem else 0; + y = i * main_height + if (i > 0) main_height_rem else 0; + width = main_width; + height = main_height + if (i == 0) main_height_rem else 0; } else { - x = master_width; - y = (i - master_count) * secondary_height + if (i > master_count) secondary_height_rem else 0; + x = main_width; + y = (i - main_count) * secondary_height + if (i > main_count) secondary_height_rem else 0; width = secondary_width; - height = secondary_height + if (i == master_count) secondary_height_rem else 0; + height = secondary_height + if (i == main_count) secondary_height_rem else 0; } - switch (master_location) { + switch (main_location) { .left => try stdout.print("{} {} {} {}\n", .{ x, y, width, height }), .right => try stdout.print("{} {} {} {}\n", .{ output_width - x - width, y, width, height }), .top => try stdout.print("{} {} {} {}\n", .{ y, x, height, width }), |
