command: s/master/main/g (breaking change)

main is a better term to use here for several reasons:

1. It is more accurate: "master" implies that the designated views have
some kind of control over the other views, which is not the case. "main"
better expresses that the difference between the "main" view and others
is one of importance/focus.

2. It is a shorter word. 2 whole characters saved!

3. It reduces the chance of future development time being lost to
good-intentioned people complaining about usage of the word master as
has recently happened with regards to the default git branch name.
This commit is contained in:
Isaac Freund 2020-12-30 18:15:47 +01:00
parent 5f4ba06566
commit ba9df86472
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
10 changed files with 96 additions and 90 deletions

View file

@ -29,18 +29,18 @@ riverctl map normal $mod Comma focus-output previous
riverctl map normal $mod+Shift Period send-to-output next
riverctl map normal $mod+Shift Comma send-to-output previous
# Mod+Return to bump the focused view to the top of the layout stack, making
# it the new master
# Mod+Return to bump the focused view to the top of the layout stack
riverctl map normal $mod Return zoom
# Mod+H and Mod+L to decrease/increase the width of the master column by 5%
riverctl map normal $mod H mod-master-factor -0.05
riverctl map normal $mod L mod-master-factor +0.05
# Mod+H and Mod+L to decrease/increase the main factor by 5%
# If using rivertile(1) this determines the width of the main stack.
riverctl map normal $mod H mod-main-factor -0.05
riverctl map normal $mod L mod-main-factor +0.05
# Mod+Shift+H and Mod+Shift+L to increment/decrement the number of
# master views in the layout
riverctl map normal $mod+Shift H mod-master-count +1
riverctl map normal $mod+Shift L mod-master-count -1
# main views in the layout
riverctl map normal $mod+Shift H mod-main-count +1
riverctl map normal $mod+Shift L mod-main-count -1
# Mod+Alt+{H,J,K,L} to move views
riverctl map normal $mod+Mod1 H move left 100
@ -95,7 +95,7 @@ riverctl map normal $mod Space toggle-float
# Mod+F to toggle fullscreen
riverctl map normal $mod F toggle-fullscreen
# Mod+{Up,Right,Down,Left} to change master orientation
# Mod+{Up,Right,Down,Left} to change layout orientation
riverctl map normal $mod Up layout rivertile top
riverctl map normal $mod Right layout rivertile right
riverctl map normal $mod Down layout rivertile down

View file

@ -4,7 +4,7 @@ from sys import argv
# This is an implementation of the default "tiled" layout of dwm
#
# With 4 views and one master, the layout looks something like this:
# With 4 views and one main view, the layout looks something like this:
#
# +-----------------------+------------+
# | | |
@ -23,46 +23,46 @@ from sys import argv
# Assign the arguments to variables. The order and meaning of the arguments
# is explained in the river-layouts(7) man page
num_views = int(argv[1])
master_count = int(argv[2])
master_factor = float(argv[3])
main_count = int(argv[2])
main_factor = float(argv[3])
output_width = int(argv[4])
output_height = int(argv[5])
secondary_count = num_views - master_count
secondary_count = num_views - main_count
# handle the cases where there are no master or no secondary views
master_width = 0
# handle the cases where there are no main or no secondary views
main_width = 0
secondary_width = 0
if master_count > 0 and secondary_count > 0:
master_width = int(master_factor * output_width)
secondary_width = output_width - master_width
elif master_count > 0:
master_width = output_width
if main_count > 0 and secondary_count > 0:
main_width = int(main_factor * output_width)
secondary_width = output_width - main_width
elif main_count > 0:
main_width = output_width
elif secondary_count > 0:
secondary_width = output_width
# for each view, output the location/dimensions separated by spaces on a new line
for i in range(num_views):
if i < master_count:
# to make things pixel-perfect, we make the first master and first secondary
if i < main_count:
# to make things pixel-perfect, we make the first main and first secondary
# view slightly larger if the height is not evenly divisible
master_height = output_height // master_count
master_height_rem = output_height % master_count
main_height = output_height // main_count
main_height_rem = output_height % main_count
x = 0
y = i * master_height + (master_height_rem if i > 0 else 0)
width = master_width
height = master_height + (master_height_rem if i == 0 else 0)
y = i * main_height + (main_height_rem if i > 0 else 0)
width = main_width
height = main_height + (main_height_rem if i == 0 else 0)
print(x, y, width, height)
else:
secondary_height = output_height // secondary_count
secondary_height_rem = output_height % secondary_count
x = master_width
y = (i - master_count) * secondary_height + (secondary_height_rem if i > master_count else 0)
x = main_width
y = (i - main_count) * secondary_height + (secondary_height_rem if i > main_count else 0)
width = secondary_width
height = secondary_height + (secondary_height_rem if i == master_count else 0)
height = secondary_height + (secondary_height_rem if i == main_count else 0)
print(x, y, width, height)

View file

@ -16,8 +16,8 @@ When running the executable, river will provide it with five parameters which
are appended to the end of the command in the following order:
. The amount of visible clients (integer)
. The amount of views dedicated as master (integer)
. The screen size multiplier for the master area (float between 0.0 and 1.0)
. The amount of views dedicated as main (integer)
. The screen size multiplier for the main area (float between 0.0 and 1.0)
. The useable width of the output (integer)
. The useable height of the output (integer)

View file

@ -46,14 +46,20 @@ control and configure river.
command to cause river to use its single internal layout, in which
windows span the entire width and height of the output.
*mod-master-count* _integer_
Increase or decrease the number of master views. _integer_ can be
positive or negative.
*mod-main-count* _integer_
Increase or decrease the number of "main" views which is relayed to
the layout generator. _integer_ can be positive or negative. Exactly
how "main" views are display, or if they are even displayed differently
from other views, is left to the layout generator.
*mod-master-factor* _float_
Make the master area bigger or smaller. _float_ is a positive or
negative floating point number (such as 0.05) where 1 corresponds to
the whole screen.
*mod-main-factor* _float_
Increase or decrease the "main factor" relayed to layout
generators. _float_ is a positive or negative floating point number
(such as 0.05). This value is added to the current main factor which
is then clamped to the range [0.0, 1.0]. The layout generator is
free to interpret this value as it sees fit, or ignore it entirely.
*rivertile*(1) uses this to determine what percentage of the screen
the "main" area will occupy.
*move* *up*|*down*|*left*|*right* _delta_
Move the focused view in the specified direction by _delta_. The view
@ -89,8 +95,8 @@ control and configure river.
Toggle the fullscreen state of the focused view.
*zoom*
Bump the focused view to the top of the layout stack to make it the new
master.
Bump the focused view to the top of the layout stack. If the top view
in the stack is already focused, bump the second view.
## TAG MANAGEMENT

View file

@ -11,21 +11,21 @@ rivertile - Tiled layout generator for river
# DESCRIPTION
*rivertile* is a layout generator for river. It produces tiled layouts with
split master/secondary stacks in four configurable orientations.
split main/secondary stacks in four configurable orientations.
# OPTIONS
*left*
Place the master stack on the left side of the output.
Place the main stack on the left side of the output.
*right*
Place the master stack on the right side of the output.
Place the main stack on the right side of the output.
*top*
Place the master stack at the top of the output.
Place the main stack at the top of the output.
*bottom*
Place the master stack at the bottom of the output.
Place the main stack at the bottom of the output.
# EXAMPLE

View file

@ -59,11 +59,11 @@ views: ViewStack(View) = .{},
current: State = State{ .tags = 1 << 0 },
pending: State = State{ .tags = 1 << 0 },
/// Number of views in "master" section of the screen.
master_count: u32 = 1,
/// Number of views in "main" section of the screen.
main_count: u32 = 1,
/// Percentage of the total screen that the master section takes up.
master_factor: f64 = 0.6,
/// Percentage of the total screen that the "main" section takes up.
main_factor: f64 = 0.6,
/// Current layout of the output. If it is "full", river will use the full
/// layout. Otherwise river assumes it contains a string which, when executed
@ -221,8 +221,8 @@ fn layoutExternal(self: *Self, visible_count: u32) !void {
const layout_command = try std.fmt.allocPrint0(&arena.allocator, "{} {} {} {d} {} {}", .{
self.layout,
visible_count,
self.master_count,
self.master_factor,
self.main_count,
self.main_factor,
layout_width,
layout_height,
});

View file

@ -59,8 +59,8 @@ const str_to_impl_fn = [_]struct {
.{ .name = "layout", .impl = @import("command/layout.zig").layout },
.{ .name = "map", .impl = @import("command/map.zig").map },
.{ .name = "map-pointer", .impl = @import("command/map.zig").mapPointer },
.{ .name = "mod-master-count", .impl = @import("command/mod_master_count.zig").modMasterCount },
.{ .name = "mod-master-factor", .impl = @import("command/mod_master_factor.zig").modMasterFactor },
.{ .name = "mod-main-count", .impl = @import("command/mod_main_count.zig").modMainCount },
.{ .name = "mod-main-factor", .impl = @import("command/mod_main_factor.zig").modMainFactor },
.{ .name = "move", .impl = @import("command/move.zig").move },
.{ .name = "opacity", .impl = @import("command/opacity.zig").opacity },
.{ .name = "outer-padding", .impl = @import("command/config.zig").outerPadding },

View file

@ -20,8 +20,8 @@ const std = @import("std");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
/// Modify the number of master views
pub fn modMasterCount(
/// Modify the number of main views
pub fn modMainCount(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
@ -32,7 +32,7 @@ pub fn modMasterCount(
const delta = try std.fmt.parseInt(i32, args[1], 10);
const output = seat.focused_output;
output.master_count = @intCast(u32, std.math.max(0, @intCast(i32, output.master_count) + delta));
output.main_count = @intCast(u32, std.math.max(0, @intCast(i32, output.main_count) + delta));
output.arrangeViews();
output.root.startTransaction();
}

View file

@ -20,8 +20,8 @@ const std = @import("std");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
/// Modify the percent of the width of the screen that the master views occupy.
pub fn modMasterFactor(
/// Modify the percent of the width of the screen that the main views occupy.
pub fn modMainFactor(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
@ -32,9 +32,9 @@ pub fn modMasterFactor(
const delta = try std.fmt.parseFloat(f64, args[1]);
const output = seat.focused_output;
const new_master_factor = std.math.min(std.math.max(output.master_factor + delta, 0.05), 0.95);
if (new_master_factor != output.master_factor) {
output.master_factor = new_master_factor;
const new_main_factor = std.math.min(std.math.max(output.main_factor + delta, 0.05), 0.95);
if (new_main_factor != output.main_factor) {
output.main_factor = new_main_factor;
output.arrangeViews();
output.root.startTransaction();
}

View file

@ -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 }),