Skip to content

Commit

Permalink
feat: delay columns
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesrocket committed Sep 9, 2024
1 parent 8f9971a commit a684fb9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,24 @@ fn printCells(core: *Core, handler: *Handler, rand: std.rand.Random) !void {
}

for (0..@intCast(core.width)) |w| {
if (rand.boolean()) continue;
if (core.columns.?.items[w].?.chars.items.len == core.height) {
const old_char = core.columns.?.items[w].?.chars.pop();
core.allocator.destroy(&old_char);
}

if (rand.boolean()) continue;
if (rand.uintLessThan(u3, 7) < 5) {
try core.columns.?.items[w].?.chars.insert(0, null);
continue;
}

const str_len = core.columns.?.items[w].?.strLen();

if ((str_len == 0) and rand.boolean()) {
try core.columns.?.items[w].?.chars.insert(0, null);
continue;
}

if (str_len < @as(u32, @intCast(core.height)) / 2) {
if (str_len < 12) {
try core.columns.?.items[w].?.newChar(core, handler.mode, rand);
Expand Down

0 comments on commit a684fb9

Please sign in to comment.