summaryrefslogtreecommitdiff
path: root/src/Presentation.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-23 11:12:56 -0300
committerGabriel Schneider <[email protected]>2026-10-23 17:10:58 -0300
commita53a1aafb9804e943bdcd720c2bb688ecb90a888 (patch)
tree197ee0ac4106037d49c5c9fc7a2b6be4186173bf /src/Presentation.zig
parenta0d367b6c54ff29737662fd7cf5a78d4d183cb20 (diff)
downloadpardes-a53a1aafb9804e943bdcd720c2bb688ecb90a888.tar.gz
pardes-a53a1aafb9804e943bdcd720c2bb688ecb90a888.zip
Audit (colours, drawing): one Surface.tint, shared colour maths, the helix copies of hand-ported themes removed
The 22 <name>_helix themes that duplicate a hand-written port are gone; monokai, ayu_dark and nord stay, since others inherit from them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Presentation.zig')
-rw-r--r--src/Presentation.zig72
1 files changed, 28 insertions, 44 deletions
diff --git a/src/Presentation.zig b/src/Presentation.zig
index 2a75b66d..3fc9be44 100644
--- a/src/Presentation.zig
+++ b/src/Presentation.zig
@@ -347,52 +347,36 @@ pub fn acknowledge(self: *Presentation, p: *Pardes, tracks: []const Track) void
pub fn capturePrevious(self: *Presentation, gpa: std.mem.Allocator, surface: *const pardes.Surface) void {
self.diff_state = .none;
const cells = surface.cells;
- if (cells.len == 0) {
- self.previous_valid = false;
- self.previous_layout = @splat(null);
- return;
- }
- if (self.previous_cells.len != cells.len) {
- const next = gpa.alloc(pardes.Cell, cells.len) catch {
- self.previous_valid = false;
- self.previous_layout = @splat(null);
- return;
- };
- if (self.previous_cells.len > 0) gpa.free(self.previous_cells);
- self.previous_cells = next;
- }
- for (&self.previous_body_layers, surface.bodyLayers()) |*old, *current| {
- const count = if (current.rows > 0) current.cells.len else 0;
- const storage = if (old.cells.len == count) old.cells else gpa.realloc(old.cells, count) catch {
- self.previous_valid = false;
- self.previous_layout = @splat(null);
- return;
- };
- if (count > 0) @memcpy(storage, current.cells);
- old.* = current.*;
- old.cells = storage;
- }
- for (&self.previous_tag_layers, surface.tagLayers()) |*old, *current| {
- const count = if (current.rows > 0) current.cells.len else 0;
- const storage = if (old.cells.len == count) old.cells else gpa.realloc(old.cells, count) catch {
- self.previous_valid = false;
- self.previous_layout = @splat(null);
- return;
+ copy: {
+ if (cells.len == 0) break :copy;
+ if (self.previous_cells.len != cells.len) {
+ const next = gpa.alloc(pardes.Cell, cells.len) catch break :copy;
+ if (self.previous_cells.len > 0) gpa.free(self.previous_cells);
+ self.previous_cells = next;
+ }
+ const olds = [_][]pardes.Layer{ &self.previous_body_layers, &self.previous_tag_layers };
+ const currents = [_][]const pardes.Layer{ surface.bodyLayers(), surface.tagLayers() };
+ for (olds, currents) |old_layers, current_layers| for (old_layers, current_layers) |*old, *current| {
+ const count = if (current.rows > 0) current.cells.len else 0;
+ const storage = if (old.cells.len == count) old.cells else gpa.realloc(old.cells, count) catch break :copy;
+ if (count > 0) @memcpy(storage, current.cells);
+ old.* = current.*;
+ old.cells = storage;
};
- if (count > 0) @memcpy(storage, current.cells);
- old.* = current.*;
- old.cells = storage;
+ @memcpy(self.previous_cells, cells);
+ @memcpy(self.previous_regions[0..surface.nregions], surface.regionList());
+ self.previous_nregions = surface.nregions;
+ self.previous_cols = surface.cols;
+ self.previous_rows = surface.rows;
+ self.previous_valid = true;
+ self.previous_layout = if (self.submitted_ready)
+ self.submitted
+ else
+ @splat(null);
+ return;
}
- @memcpy(self.previous_cells, cells);
- @memcpy(self.previous_regions[0..surface.nregions], surface.regionList());
- self.previous_nregions = surface.nregions;
- self.previous_cols = surface.cols;
- self.previous_rows = surface.rows;
- self.previous_valid = true;
- self.previous_layout = if (self.submitted_ready)
- self.submitted
- else
- @splat(null);
+ self.previous_valid = false;
+ self.previous_layout = @splat(null);
}
pub fn cellDiff(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u16) pardes.PanelCellDiff {