mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
update zig, src for loops
This commit is contained in:
6
flake.lock
generated
6
flake.lock
generated
@ -126,11 +126,11 @@
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676852827,
|
||||
"narHash": "sha256-PiUegeTKdyvsGVzdrTeoWTXTPNRQ/bhX/3MjKzzERiQ=",
|
||||
"lastModified": 1677457546,
|
||||
"narHash": "sha256-R2k5sOzf6dEg/PbMfZNYFjmJQY1Hbd/4sc8H36I3EAM=",
|
||||
"owner": "mitchellh",
|
||||
"repo": "zig-overlay",
|
||||
"rev": "8b3bf31d01b67b79e2f34eb9b6f6d313c8a203ca",
|
||||
"rev": "2b07e4e3e3eb07134ac61049abdc1da1ff6c5516",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -112,7 +112,7 @@ pub fn start(self: *Command, alloc: Allocator) !void {
|
||||
// Null-terminate all our arguments
|
||||
const pathZ = try arena.dupeZ(u8, self.path);
|
||||
const argsZ = try arena.allocSentinel(?[*:0]u8, self.args.len, null);
|
||||
for (self.args) |arg, i| argsZ[i] = (try arena.dupeZ(u8, arg)).ptr;
|
||||
for (self.args, 0..) |arg, i| argsZ[i] = (try arena.dupeZ(u8, arg)).ptr;
|
||||
|
||||
// Determine our env vars
|
||||
const envp = if (self.env) |env_map|
|
||||
|
@ -1417,7 +1417,7 @@ pub fn cursorPosCallback(
|
||||
if (self.io.terminal.modes.mouse_event != .none) {
|
||||
// We use the first mouse button we find pressed in order to report
|
||||
// since the spec (afaict) does not say...
|
||||
const button: ?input.MouseButton = button: for (self.mouse.click_state) |state, i| {
|
||||
const button: ?input.MouseButton = button: for (self.mouse.click_state, 0..) |state, i| {
|
||||
if (state == .press)
|
||||
break :button @intToEnum(input.MouseButton, i);
|
||||
} else null;
|
||||
|
@ -860,7 +860,7 @@ pub const Surface = struct {
|
||||
// that assumption is true.
|
||||
const keyval = keyval: {
|
||||
if (found > 0) {
|
||||
for (keys[0..@intCast(usize, keys_len)]) |key, i| {
|
||||
for (keys[0..@intCast(usize, keys_len)], 0..) |key, i| {
|
||||
if (key.group == 0 and key.level == 0)
|
||||
break :keyval keyvals[i];
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ pub const Wasm = struct {
|
||||
var buf: []u8 = try alloc.alloc(u8, self.data.len * 4);
|
||||
errdefer alloc.free(buf);
|
||||
std.mem.set(u8, buf, 0);
|
||||
for (self.data) |value, i| {
|
||||
for (self.data, 0..) |value, i| {
|
||||
buf[(i * 4) + 3] = value;
|
||||
}
|
||||
break :buf buf;
|
||||
|
@ -219,7 +219,7 @@ pub fn indexForCodepoint(
|
||||
}
|
||||
|
||||
fn indexForCodepointExact(self: Group, cp: u32, style: Style, p: ?Presentation) ?FontIndex {
|
||||
for (self.faces.get(style).items) |deferred, i| {
|
||||
for (self.faces.get(style).items, 0..) |deferred, i| {
|
||||
if (deferred.hasCodepoint(cp, p)) {
|
||||
return FontIndex{
|
||||
.style = style,
|
||||
|
@ -89,7 +89,7 @@ pub const Shaper = struct {
|
||||
if (info.len > self.cell_buf.len) return error.OutOfMemory;
|
||||
//log.warn("info={} pos={} run={}", .{ info.len, pos.len, run });
|
||||
|
||||
for (info) |v, i| {
|
||||
for (info, 0..) |v, i| {
|
||||
self.cell_buf[i] = .{
|
||||
.x = @intCast(u16, v.cluster),
|
||||
.glyph_index = v.codepoint,
|
||||
|
@ -316,7 +316,7 @@ pub const Row = struct {
|
||||
}
|
||||
|
||||
// We have graphemes, so we have to clear those first.
|
||||
for (self.storage[start + 1 .. len + 1]) |*storage_cell, x| {
|
||||
for (self.storage[start + 1 .. len + 1], 0..) |*storage_cell, x| {
|
||||
if (storage_cell.cell.attrs.grapheme) self.clearGraphemes(x);
|
||||
storage_cell.* = .{ .cell = cell };
|
||||
}
|
||||
@ -413,7 +413,7 @@ pub const Row = struct {
|
||||
}
|
||||
|
||||
// Source has graphemes, this is slow.
|
||||
for (src.storage[1..end]) |storage, x| {
|
||||
for (src.storage[1..end], 0..) |storage, x| {
|
||||
self.storage[x + 1] = .{ .cell = storage.cell };
|
||||
|
||||
// Copy grapheme data if it exists
|
||||
@ -1056,7 +1056,7 @@ pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usi
|
||||
};
|
||||
|
||||
// Zero
|
||||
for (zero_offset) |offset, i| {
|
||||
for (zero_offset, 0..) |offset, i| {
|
||||
if (offset >= slices[i].len) continue;
|
||||
|
||||
const dst = slices[i][offset..];
|
||||
@ -1488,7 +1488,7 @@ pub fn selectionString(
|
||||
var count: usize = 0;
|
||||
const arr = [_][]StorageCell{ slices.top, slices.bot };
|
||||
for (arr) |slice| {
|
||||
for (slice) |cell, i| {
|
||||
for (slice, 0..) |cell, i| {
|
||||
// detect row headers
|
||||
if (@mod(i, self.cols + 1) == 0) {
|
||||
// We use each row header as an opportunity to "count"
|
||||
@ -1967,7 +1967,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void {
|
||||
};
|
||||
|
||||
// Copy all the cells into our row.
|
||||
for (trimmed_row) |cell, i| {
|
||||
for (trimmed_row, 0..) |cell, i| {
|
||||
// Soft wrap if we have to
|
||||
if (x == self.cols) {
|
||||
var row = self.getRow(.{ .active = y });
|
||||
|
@ -32,7 +32,7 @@ const prealloc_count = prealloc_columns / unit_bits;
|
||||
/// We precompute all the possible masks since we never use a huge bit size.
|
||||
const masks = blk: {
|
||||
var res: [unit_bits]Unit = undefined;
|
||||
for (res) |_, i| {
|
||||
for (res, 0..) |_, i| {
|
||||
res[i] = @shlExact(@as(Unit, 1), @intCast(u3, i));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user