diff --git a/flake.lock b/flake.lock index e675ddcf0..1db3024a6 100644 --- a/flake.lock +++ b/flake.lock @@ -109,11 +109,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1665922169, - "narHash": "sha256-+NmtznNb+iEZP+KK69d10Q1CjSupSXn7ZLuI+tjY+eg=", + "lastModified": 1666181436, + "narHash": "sha256-BfVbxHew4bLVXYms5eUiKL7jbaI+Hp6TF2PH2Vb62cg=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "9fd4058448eecd25be1f465ea9dc22023c86207b", + "rev": "cf94d6039dd8205e48013eaef619da6a52bdc34e", "type": "github" }, "original": { diff --git a/src/Grid.zig b/src/Grid.zig index a1161dc71..b870d9dda 100644 --- a/src/Grid.zig +++ b/src/Grid.zig @@ -712,7 +712,7 @@ pub fn setScreenSize(self: *Grid, dim: ScreenSize) !void { // Update our LRU. We arbitrarily support a certain number of pages here. // We also always support a minimum number of caching in case a user // is resizing tiny then growing again we can save some of the renders. - const evicted = try self.cells_lru.resize(self.alloc, @maximum(80, self.size.rows * 10)); + const evicted = try self.cells_lru.resize(self.alloc, @max(80, self.size.rows * 10)); if (evicted) |list| for (list) |*value| value.deinit(self.alloc); // Update our shaper diff --git a/src/Window.zig b/src/Window.zig index d05d83b91..d8a9fdcf2 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -605,7 +605,7 @@ fn queueWrite(self: *Window, data: []const u8) !void { while (i < data.len) { const req = try self.write_req_pool.get(); const buf = try self.write_buf_pool.get(); - const end = @minimum(data.len, i + buf.len); + const end = @min(data.len, i + buf.len); std.mem.copy(u8, buf, data[i..end]); try self.pty_stream.write( .{ .req = req }, @@ -1007,7 +1007,7 @@ fn scrollCallback(window: glfw.Window, xoff: f64, yoff: f64) void { // Positive is up const sign: isize = if (yoff > 0) -1 else 1; - const delta: isize = sign * @maximum(@divFloor(win.grid.size.rows, 15), 1); + const delta: isize = sign * @max(@divFloor(win.grid.size.rows, 15), 1); log.info("scroll: delta={}", .{delta}); win.terminal.scrollViewport(.{ .delta = delta }) catch |err| log.err("error scrolling viewport err={}", .{err}); @@ -1450,13 +1450,13 @@ fn posToViewport(self: Window, xpos: f64, ypos: f64) terminal.point.Viewport { // Can be off the screen if the user drags it out, so max // it out on our available columns - break :x @minimum(x, self.terminal.cols - 1); + break :x @min(x, self.terminal.cols - 1); }, .y = if (ypos < 0) 0 else y: { const cell_height = @floatCast(f64, self.grid.cell_size.height); const y = @floatToInt(usize, ypos / cell_height); - break :y @minimum(y, self.terminal.rows - 1); + break :y @min(y, self.terminal.rows - 1); }, }; } diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 43cc26d17..bdb7338e4 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -230,7 +230,7 @@ pub const Face = struct { var max: f64 = 0; var i: usize = 0; while (i < advances.len) : (i += 1) { - max = @maximum(advances[i].width, max); + max = @max(advances[i].width, max); } break :cell_width @floatCast(f32, max); diff --git a/src/font/face/freetype.zig b/src/font/face/freetype.zig index be09833af..746650e94 100644 --- a/src/font/face/freetype.zig +++ b/src/font/face/freetype.zig @@ -363,9 +363,9 @@ pub const Face = struct { break :underscore 0; }; - break :cell_height @maximum( + break :cell_height @max( face_height, - @maximum(max_glyph_height, underscore_height), + @max(max_glyph_height, underscore_height), ); }; @@ -394,7 +394,7 @@ pub const Face = struct { // cell height (mainly: non-scalable fonts, i.e. emoji) break :underline_pos cell_height - 1; }; - const underline_thickness = @maximum(1, fontUnitsToPxY( + const underline_thickness = @max(1, fontUnitsToPxY( face, face.handle.*.underline_thickness, )); @@ -415,7 +415,7 @@ pub const Face = struct { break :pos @intToFloat(f32, ascender_px - declared_px); }, - .thickness = @maximum(1, fontUnitsToPxY(face, os2.yStrikeoutSize)), + .thickness = @max(1, fontUnitsToPxY(face, os2.yStrikeoutSize)), } else .{ .pos = cell_baseline * 0.6, .thickness = underline_thickness, diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 349ada767..4dde25f65 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -397,7 +397,7 @@ pub const Row = struct { self.storage[0].header.flags.dirty = true; // If the source has no graphemes (likely) then this is fast. - const end = @minimum(src.storage.len, self.storage.len); + const end = @min(src.storage.len, self.storage.len); if (!src.storage[0].header.flags.grapheme) { std.mem.copy(StorageCell, self.storage[1..], src.storage[1..end]); return; @@ -586,7 +586,7 @@ pub const RowIndexTag = enum { // Viewport can be any of the written rows or the max size // of a viewport. - .viewport => @minimum(screen.rows, screen.rowsWritten()), + .viewport => @min(screen.rows, screen.rowsWritten()), // History is all the way up to the top of our active area. If // we haven't filled our active area, there is no history. @@ -596,7 +596,7 @@ pub const RowIndexTag = enum { // written here because this is the only row index that can // actively grow our rows. .active => screen.rows, - //TODO .active => @minimum(rows_written, screen.rows), + //TODO .active => @min(rows_written, screen.rows), }; } @@ -751,7 +751,7 @@ pub fn init( // * Our buffer size is preallocated to fit double our visible space // or the maximum scrollback whichever is smaller. // * We add +1 to cols to fit the row header - const buf_size = (rows + @minimum(max_scrollback, rows)) * (cols + 1); + const buf_size = (rows + @min(max_scrollback, rows)) * (cols + 1); return Screen{ .alloc = alloc, @@ -943,7 +943,7 @@ fn scrollDelta(self: *Screen, delta: isize, grow: bool) !void { // If we're scrolling down and not growing, then we just // add to the viewport and clamp at the bottom. if (!grow) { - self.viewport = @minimum( + self.viewport = @min( self.history, self.viewport + @intCast(usize, delta), ); @@ -976,15 +976,15 @@ fn scrollDelta(self: *Screen, delta: isize, grow: bool) !void { // of what we actually need and two pages. We don't want to // allocate one row at a time (common for scrolling) so we do this // to chunk it. - const needed_capacity = @maximum( + const needed_capacity = @max( rows_final * (self.cols + 1), - @minimum(self.storage.capacity() * 2, max_capacity), + @min(self.storage.capacity() * 2, max_capacity), ); // Allocate what we can. try self.storage.resize( self.alloc, - @minimum(max_capacity, needed_capacity), + @min(max_capacity, needed_capacity), ); } } @@ -1076,7 +1076,7 @@ pub fn selectionString(self: *Screen, alloc: Allocator, sel: Selection) ![:0]con // Our end index is usually a full row, but if we're the final // row then we just use the length. - const end_idx = @minimum(slice.len, start_idx + self.cols + 1); + const end_idx = @min(slice.len, start_idx + self.cols + 1); // We may have to skip some cells from the beginning if we're // the first row. @@ -1206,9 +1206,9 @@ pub fn resizeWithoutReflow(self: *Screen, rows: usize, cols: usize) !void { // Calculate our buffer size. This is going to be either the old data // with scrollback or the max capacity of our new size. We prefer the old // length so we can save all the data (ignoring col truncation). - const old_len = @maximum(old.rowsWritten(), rows) * (cols + 1); + const old_len = @max(old.rowsWritten(), rows) * (cols + 1); const new_max_capacity = self.maxCapacity(); - const buf_size = @minimum(old_len, new_max_capacity); + const buf_size = @min(old_len, new_max_capacity); // Reallocate the storage self.storage = try StorageBuf.init(self.alloc, buf_size); @@ -1243,7 +1243,7 @@ pub fn resizeWithoutReflow(self: *Screen, rows: usize, cols: usize) !void { // screen we can accomodate keeping it on the same place if we retain // the same scrollback. const old_cursor_y_screen = RowIndexTag.active.index(old.cursor.y).toScreen(&old).screen; - self.cursor.x = @minimum(old.cursor.x, self.cols - 1); + self.cursor.x = @min(old.cursor.x, self.cols - 1); self.cursor.y = if (old_cursor_y_screen <= RowIndexTag.screen.maxLen(self)) old_cursor_y_screen -| self.history else @@ -1282,7 +1282,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { errdefer self.* = old; // Allocate enough to store our screen plus history. - const buf_size = (self.rows + @maximum(self.history, self.max_scrollback)) * (cols + 1); + const buf_size = (self.rows + @max(self.history, self.max_scrollback)) * (cols + 1); self.storage = try StorageBuf.init(self.alloc, buf_size); errdefer self.storage.deinit(self.alloc); defer old.storage.deinit(self.alloc); @@ -1356,7 +1356,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { const wrapped_cells_rem = wrapped_cells.len - wrapped_i; // We copy as much as we can into our new row - const copy_len = @minimum(new_row_rem, wrapped_cells_rem); + const copy_len = @min(new_row_rem, wrapped_cells_rem); // The row doesn't fit, meaning we have to soft-wrap the // new row but probably at a diff boundary. @@ -1436,7 +1436,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { errdefer self.* = old; // Allocate enough to store our screen plus history. - const buf_size = (self.rows + @maximum(self.history, self.max_scrollback)) * (cols + 1); + const buf_size = (self.rows + @max(self.history, self.max_scrollback)) * (cols + 1); self.storage = try StorageBuf.init(self.alloc, buf_size); errdefer self.storage.deinit(self.alloc); defer old.storage.deinit(self.alloc); @@ -1510,7 +1510,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { { assert(new_cursor == null); new_cursor = .{ - .x = @minimum(cursor_pos.x, self.cols - 1), + .x = @min(cursor_pos.x, self.cols - 1), .y = self.viewport + y, }; } @@ -1528,14 +1528,14 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { // point and set it up. if (new_cursor) |pos| { const viewport_pos = pos.toViewport(self); - self.cursor.x = @minimum(viewport_pos.x, self.cols - 1); - self.cursor.y = @minimum(viewport_pos.y, self.rows - 1); + self.cursor.x = @min(viewport_pos.x, self.cols - 1); + self.cursor.y = @min(viewport_pos.y, self.rows - 1); } else { // TODO: why is this necessary? Without this, neovim will // crash when we shrink the window to the smallest size. We // never got a test case to cover this. - self.cursor.x = @minimum(self.cursor.x, self.cols - 1); - self.cursor.y = @minimum(self.cursor.y, self.rows - 1); + self.cursor.x = @min(self.cursor.x, self.cols - 1); + self.cursor.y = @min(self.cursor.y, self.rows - 1); } } } @@ -1680,7 +1680,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void { } // So the cursor doesn't go off screen - self.cursor.x = @minimum(x, self.cols - 1); + self.cursor.x = @min(x, self.cols - 1); self.cursor.y = y; } diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index b7d275bb2..5de275707 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -711,7 +711,7 @@ pub fn index(self: *Terminal) !void { if (self.screen.cursor.y < self.scrolling_region.top or self.screen.cursor.y > self.scrolling_region.bottom) { - self.screen.cursor.y = @minimum(self.screen.cursor.y + 1, self.rows - 1); + self.screen.cursor.y = @min(self.screen.cursor.y + 1, self.rows - 1); return; } @@ -734,7 +734,7 @@ pub fn index(self: *Terminal) !void { } // Increase cursor by 1, maximum to bottom of scroll region - self.screen.cursor.y = @minimum(self.screen.cursor.y + 1, self.scrolling_region.bottom); + self.screen.cursor.y = @min(self.screen.cursor.y + 1, self.scrolling_region.bottom); } /// Move the cursor to the previous line in the scrolling region, possibly @@ -796,8 +796,8 @@ pub fn setCursorPos(self: *Terminal, row_req: usize, col_req: usize) void { const row = if (row_req == 0) 1 else row_req; const col = if (col_req == 0) 1 else col_req; - self.screen.cursor.x = @minimum(params.x_max, col) -| 1; - self.screen.cursor.y = @minimum(params.y_max, row + params.y_offset) -| 1; + self.screen.cursor.x = @min(params.x_max, col) -| 1; + self.screen.cursor.y = @min(params.y_max, row + params.y_offset) -| 1; // log.info("set cursor position: col={} row={}", .{ self.screen.cursor.x, self.screen.cursor.y }); // Unset pending wrap state @@ -821,7 +821,7 @@ pub fn setCursorColAbsolute(self: *Terminal, col_req: usize) void { if (self.status_display != .main) return; // TODO const col = if (col_req == 0) 1 else col_req; - self.screen.cursor.x = @minimum(self.cols, col) - 1; + self.screen.cursor.x = @min(self.cols, col) - 1; } /// Erase the display. @@ -966,7 +966,7 @@ pub fn eraseChars(self: *Terminal, count: usize) void { // Our last index is at most the end of the number of chars we have // in the current line. - const end = @minimum(self.cols, self.screen.cursor.x + count); + const end = @min(self.cols, self.screen.cursor.x + count); // Shift var pen = self.screen.cursor.pen; @@ -1169,7 +1169,7 @@ pub fn insertLines(self: *Terminal, count: usize) !void { const rem = self.scrolling_region.bottom - self.screen.cursor.y + 1; // If count is greater than the amount of rows, adjust down. - const adjusted_count = @minimum(count, rem); + const adjusted_count = @min(count, rem); // The the top `scroll_amount` lines need to move to the bottom // scroll area. We may have nothing to scroll if we're clearing. @@ -1219,7 +1219,7 @@ pub fn deleteLines(self: *Terminal, count: usize) !void { const rem = self.scrolling_region.bottom - self.screen.cursor.y + 1; // If the count is more than our remaining lines, we adjust down. - const adjusted_count = @minimum(count, rem); + const adjusted_count = @min(count, rem); // Scroll up the count amount. var y: usize = self.screen.cursor.y; @@ -1306,7 +1306,7 @@ pub fn setScrollingRegion(self: *Terminal, top: usize, bottom: usize) void { defer tracy.end(); var t = if (top == 0) 1 else top; - var b = @minimum(bottom, self.rows); + var b = @min(bottom, self.rows); if (t >= b) { t = 1; b = self.rows; diff --git a/src/terminal/circ_buf.zig b/src/terminal/circ_buf.zig index 1202874f7..3558b6c4a 100644 --- a/src/terminal/circ_buf.zig +++ b/src/terminal/circ_buf.zig @@ -120,7 +120,7 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { // If we're not full, we can just advance the tail. We know // it'll be less than the length because otherwise we'd be full. - self.tail += @minimum(self.len(), n); + self.tail += @min(self.len(), n); if (self.tail >= self.storage.len) self.tail -= self.storage.len; self.full = false; }