From 44a48f62f1f3888d9f91f5592effdfeed9041f9a Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Fri, 17 Nov 2023 15:40:59 +0100 Subject: [PATCH] change unmodified `var`s to `const`s in anticipation of zig changes --- build.zig | 6 +- pkg/fontconfig/test.zig | 2 +- pkg/macos/foundation/data.zig | 2 +- pkg/pixman/image.zig | 4 +- src/Command.zig | 2 +- src/Surface.zig | 8 +- src/apprt/embedded.zig | 2 +- src/circ_buf.zig | 2 +- src/config/Config.zig | 2 +- src/font/Atlas.zig | 6 +- src/font/DeferredFace.zig | 4 +- src/font/Group.zig | 4 +- src/font/GroupCache.zig | 4 +- src/font/face/coretext.zig | 2 +- src/font/face/freetype.zig | 2 +- src/font/face/web_canvas.zig | 6 +- src/font/shaper/web_canvas.zig | 4 +- src/font/sprite/canvas.zig | 6 +- src/lru.zig | 4 +- src/os/wasm.zig | 4 +- src/renderer/Metal.zig | 2 +- src/renderer/OpenGL.zig | 2 +- src/segmented_pool.zig | 8 +- src/terminal/Screen.zig | 338 +++++++++++----------- src/terminal/Tabstops.zig | 2 +- src/terminal/Terminal.zig | 390 +++++++++++++------------- src/terminal/kitty/graphics_image.zig | 4 +- src/termio/Exec.zig | 4 +- src/termio/message.zig | 2 +- 29 files changed, 414 insertions(+), 414 deletions(-) diff --git a/build.zig b/build.zig index 75378d0f8..f6164675e 100644 --- a/build.zig +++ b/build.zig @@ -143,14 +143,14 @@ pub fn build(b: *std.Build) !void { break :patch_rpath env.get("LD_LIBRARY_PATH"); }; - var version_string = b.option( + const version_string = b.option( []const u8, "version-string", "A specific version string to use for the build. " ++ "If not specified, git will be used. This must be a semantic version.", ); - var version: std.SemanticVersion = if (version_string) |v| + const version: std.SemanticVersion = if (version_string) |v| try std.SemanticVersion.parse(v) else version: { const vsn = try Version.detect(b); @@ -589,7 +589,7 @@ pub fn build(b: *std.Build) !void { // Tests { const test_step = b.step("test", "Run all tests"); - var test_filter = b.option([]const u8, "test-filter", "Filter for test"); + const test_filter = b.option([]const u8, "test-filter", "Filter for test"); const main_test = b.addTest(.{ .name = "ghostty-test", diff --git a/pkg/fontconfig/test.zig b/pkg/fontconfig/test.zig index 9ba1fe819..bd121c1bc 100644 --- a/pkg/fontconfig/test.zig +++ b/pkg/fontconfig/test.zig @@ -43,7 +43,7 @@ test "fc-match" { const fonts = result.fs.fonts(); try testing.expect(fonts.len > 0); for (fonts) |font| { - var pat_prep = try cfg.fontRenderPrepare(pat, font); + const pat_prep = try cfg.fontRenderPrepare(pat, font); try testing.expect(fs.add(pat_prep)); } result.fs.destroy(); diff --git a/pkg/macos/foundation/data.zig b/pkg/macos/foundation/data.zig index c4047e87d..7c9b7d6cb 100644 --- a/pkg/macos/foundation/data.zig +++ b/pkg/macos/foundation/data.zig @@ -28,7 +28,7 @@ pub const Data = opaque { test { //const testing = std.testing; - var raw = "hello world"; + const raw = "hello world"; const data = try Data.createWithBytesNoCopy(raw); defer data.release(); } diff --git a/pkg/pixman/image.zig b/pkg/pixman/image.zig index 0c87167f5..09c60540f 100644 --- a/pkg/pixman/image.zig +++ b/pkg/pixman/image.zig @@ -169,7 +169,7 @@ test "create and destroy" { const stride = format.strideForWidth(width); const len = height * @as(usize, @intCast(stride)); - var data = try alloc.alloc(u32, len); + const data = try alloc.alloc(u32, len); defer alloc.free(data); @memset(data, 0); const img = try Image.createBitsNoClear(.g1, width, height, data.ptr, stride); @@ -191,7 +191,7 @@ test "fill boxes a1" { // Image const len = height * @as(usize, @intCast(stride)); - var data = try alloc.alloc(u32, len); + const data = try alloc.alloc(u32, len); defer alloc.free(data); @memset(data, 0); const img = try Image.createBitsNoClear(format, width, height, data.ptr, stride); diff --git a/src/Command.zig b/src/Command.zig index d12b67204..afca6a564 100644 --- a/src/Command.zig +++ b/src/Command.zig @@ -310,7 +310,7 @@ pub fn wait(self: Command, block: bool) !Exit { } var exit_code: windows.DWORD = undefined; - var has_code = windows.kernel32.GetExitCodeProcess(self.pid.?, &exit_code) != 0; + const has_code = windows.kernel32.GetExitCodeProcess(self.pid.?, &exit_code) != 0; if (!has_code) { return windows.unexpectedError(windows.kernel32.GetLastError()); } diff --git a/src/Surface.zig b/src/Surface.zig index 0c7783df9..484daacee 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -422,7 +422,7 @@ pub fn init( ); // The mutex used to protect our renderer state. - var mutex = try alloc.create(std.Thread.Mutex); + const mutex = try alloc.create(std.Thread.Mutex); mutex.* = .{}; errdefer alloc.destroy(mutex); @@ -604,7 +604,7 @@ pub fn activateInspector(self: *Surface) !void { if (self.inspector != null) return; // Setup the inspector - var ptr = try self.alloc.create(inspector.Inspector); + const ptr = try self.alloc.create(inspector.Inspector); errdefer self.alloc.destroy(ptr); ptr.* = try inspector.Inspector.init(self); self.inspector = ptr; @@ -895,7 +895,7 @@ fn setSelection(self: *Surface, sel_: ?terminal.Selection) void { } } - var buf = self.io.terminal.screen.selectionString( + const buf = self.io.terminal.screen.selectionString( self.alloc, sel, self.config.clipboard_trim_trailing_spaces, @@ -2314,7 +2314,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool // We can read from the renderer state without holding // the lock because only we will write to this field. if (self.io.terminal.screen.selection) |sel| { - var buf = self.io.terminal.screen.selectionString( + const buf = self.io.terminal.screen.selectionString( self.alloc, sel, self.config.clipboard_trim_trailing_spaces, diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index cf2a2dc15..5ac6cef43 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -353,7 +353,7 @@ pub const Surface = struct { if (self.inspector) |v| return v; const alloc = self.app.core_app.alloc; - var inspector = try alloc.create(Inspector); + const inspector = try alloc.create(Inspector); errdefer alloc.destroy(inspector); inspector.* = try Inspector.init(self); self.inspector = inspector; diff --git a/src/circ_buf.zig b/src/circ_buf.zig index b36a1bc08..2cb004c70 100644 --- a/src/circ_buf.zig +++ b/src/circ_buf.zig @@ -49,7 +49,7 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { /// Initialize a new circular buffer that can store size elements. pub fn init(alloc: Allocator, size: usize) !Self { - var buf = try alloc.alloc(T, size); + const buf = try alloc.alloc(T, size); @memset(buf, default); return Self{ diff --git a/src/config/Config.zig b/src/config/Config.zig index c13a76bef..ecf596e59 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1967,7 +1967,7 @@ pub const Keybinds = struct { pub fn parseCLI(self: *Keybinds, alloc: Allocator, input: ?[]const u8) !void { var copy: ?[]u8 = null; - var value = value: { + const value = value: { const value = input orelse return error.ValueRequired; // If we don't have a colon, use the value as-is, no copy diff --git a/src/font/Atlas.zig b/src/font/Atlas.zig index 50c0d85a9..01ee5caa6 100644 --- a/src/font/Atlas.zig +++ b/src/font/Atlas.zig @@ -124,7 +124,7 @@ pub fn reserve(self: *Atlas, alloc: Allocator, width: u32, height: u32) !Region if (width == 0 and height == 0) return region; // Find the location in our nodes list to insert the new node for this region. - var best_idx: usize = best_idx: { + const best_idx: usize = best_idx: { var best_height: u32 = std.math.maxInt(u32); var best_width: u32 = best_height; var chosen: ?usize = null; @@ -395,7 +395,7 @@ pub const Wasm = struct { defer ctx.deinit(); // We need to draw pixels so this is format dependent. - var buf: []u8 = switch (self.format) { + const buf: []u8 = switch (self.format) { // RGBA is the native ImageData format .rgba => self.data, @@ -454,7 +454,7 @@ pub const Wasm = struct { } test "happy path" { - var atlas = atlas_new(512, @intFromEnum(Format.greyscale)).?; + const atlas = atlas_new(512, @intFromEnum(Format.greyscale)).?; defer atlas_free(atlas); const reg = atlas_reserve(atlas, 2, 2).?; diff --git a/src/font/DeferredFace.zig b/src/font/DeferredFace.zig index 9d97952f5..6ff7f3922 100644 --- a/src/font/DeferredFace.zig +++ b/src/font/DeferredFace.zig @@ -341,7 +341,7 @@ pub const Wasm = struct { } fn deferred_face_new_(ptr: [*]const u8, len: usize, presentation: u16) !*DeferredFace { - var font_str = try alloc.dupeZ(u8, ptr[0..len]); + const font_str = try alloc.dupeZ(u8, ptr[0..len]); errdefer alloc.free(font_str); var face: DeferredFace = .{ @@ -353,7 +353,7 @@ pub const Wasm = struct { }; errdefer face.deinit(); - var result = try alloc.create(DeferredFace); + const result = try alloc.create(DeferredFace); errdefer alloc.destroy(result); result.* = face; return result; diff --git a/src/font/Group.zig b/src/font/Group.zig index 9c942cda8..0ed3db490 100644 --- a/src/font/Group.zig +++ b/src/font/Group.zig @@ -662,7 +662,7 @@ pub const Wasm = struct { var group = try Group.init(alloc, .{}, .{ .points = pts }); errdefer group.deinit(); - var result = try alloc.create(Group); + const result = try alloc.create(Group); errdefer alloc.destroy(result); result.* = group; return result; @@ -749,7 +749,7 @@ pub const Wasm = struct { .max_height = max_height, }); - var result = try alloc.create(Glyph); + const result = try alloc.create(Glyph); errdefer alloc.destroy(result); result.* = glyph; return result; diff --git a/src/font/GroupCache.zig b/src/font/GroupCache.zig index 6e8ee9856..99e5548bf 100644 --- a/src/font/GroupCache.zig +++ b/src/font/GroupCache.zig @@ -244,7 +244,7 @@ pub const Wasm = struct { var gc = try GroupCache.init(alloc, group.*); errdefer gc.deinit(alloc); - var result = try alloc.create(GroupCache); + const result = try alloc.create(GroupCache); errdefer alloc.destroy(result); result.* = gc; return result; @@ -304,7 +304,7 @@ pub const Wasm = struct { .max_height = max_height, }); - var result = try alloc.create(Glyph); + const result = try alloc.create(Glyph); errdefer alloc.destroy(result); result.* = glyph; return result; diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 969207e9c..eb83354b5 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -301,7 +301,7 @@ pub const Face = struct { // usually stabilizes pretty quickly and is very infrequent so I think // the allocation overhead is acceptable compared to the cost of // caching it forever or having to deal with a cache lifetime. - var buf = try alloc.alloc(u8, width * height * color.depth); + const buf = try alloc.alloc(u8, width * height * color.depth); defer alloc.free(buf); @memset(buf, 0); diff --git a/src/font/face/freetype.zig b/src/font/face/freetype.zig index 66c27aa99..c8cc38067 100644 --- a/src/font/face/freetype.zig +++ b/src/font/face/freetype.zig @@ -389,7 +389,7 @@ pub const Face = struct { // If we need to copy the data, we copy it into a temporary buffer. const buffer = if (needs_copy) buffer: { - var temp = try alloc.alloc(u8, tgt_w * tgt_h * depth); + const temp = try alloc.alloc(u8, tgt_w * tgt_h * depth); var dst_ptr = temp; var src_ptr = bitmap.buffer; var i: usize = 0; diff --git a/src/font/face/web_canvas.zig b/src/font/face/web_canvas.zig index 415de15a4..6470f6a8b 100644 --- a/src/font/face/web_canvas.zig +++ b/src/font/face/web_canvas.zig @@ -302,7 +302,7 @@ pub const Face = struct { } // Set our context font - var font_val = try std.fmt.allocPrint( + const font_val = try std.fmt.allocPrint( self.alloc, "{d}px {s}", .{ self.size.points, self.font_str }, @@ -450,7 +450,7 @@ pub const Face = struct { // Allocate our local memory to copy the data to. const len = try src_array.get(u32, "length"); - var bitmap = try alloc.alloc(u8, @intCast(len)); + const bitmap = try alloc.alloc(u8, @intCast(len)); errdefer alloc.free(bitmap); // Create our target Uint8Array that we can use to copy from src. @@ -506,7 +506,7 @@ pub const Wasm = struct { ); errdefer face.deinit(); - var result = try alloc.create(Face); + const result = try alloc.create(Face); errdefer alloc.destroy(result); result.* = face; return result; diff --git a/src/font/shaper/web_canvas.zig b/src/font/shaper/web_canvas.zig index 912192eb1..53fb77f4b 100644 --- a/src/font/shaper/web_canvas.zig +++ b/src/font/shaper/web_canvas.zig @@ -239,13 +239,13 @@ pub const Wasm = struct { } fn shaper_new_(cap: usize) !*Shaper { - var cell_buf = try alloc.alloc(font.shape.Cell, cap); + const cell_buf = try alloc.alloc(font.shape.Cell, cap); errdefer alloc.free(cell_buf); var shaper = try Shaper.init(alloc, .{ .cell_buf = cell_buf }); errdefer shaper.deinit(); - var result = try alloc.create(Shaper); + const result = try alloc.create(Shaper); errdefer alloc.destroy(result); result.* = shaper; return result; diff --git a/src/font/sprite/canvas.zig b/src/font/sprite/canvas.zig index 93551335e..a13e1e50b 100644 --- a/src/font/sprite/canvas.zig +++ b/src/font/sprite/canvas.zig @@ -241,7 +241,7 @@ const WebCanvasImpl = struct { // Allocate our local memory to copy the data to. const len = try src_array.get(u32, "length"); - var bitmap = try alloc.alloc(u8, @intCast(len)); + const bitmap = try alloc.alloc(u8, @intCast(len)); errdefer alloc.free(bitmap); // Create our target Uint8Array that we can use to copy from src. @@ -314,7 +314,7 @@ const PixmanImpl = struct { // Allocate our buffer. pixman uses []u32 so we divide our length // by 4 since u32 / u8 = 4. - var data = try alloc.alloc(u32, len / 4); + const data = try alloc.alloc(u32, len / 4); errdefer alloc.free(data); @memset(data, 0); @@ -385,7 +385,7 @@ const PixmanImpl = struct { // If we need to copy the data, we copy it into a temporary buffer. const buffer = if (needs_copy) buffer: { - var temp = try alloc.alloc(u8, width * height * depth); + const temp = try alloc.alloc(u8, width * height * depth); var dst_ptr = temp; var src_ptr = data.ptr; var i: usize = 0; diff --git a/src/lru.zig b/src/lru.zig index 34d4ee430..a334a783e 100644 --- a/src/lru.zig +++ b/src/lru.zig @@ -120,7 +120,7 @@ pub fn HashMap( // reusing the node we would've evicted. var node = if (!evict) try alloc.create(Queue.Node) else node: { // Our first node is the least recently used. - var least_used = self.queue.first.?; + const least_used = self.queue.first.?; // Move our least recently used to the end to make // it the most recently used. @@ -186,7 +186,7 @@ pub fn HashMap( var i: Map.Size = 0; while (i < delta) : (i += 1) { - var node = self.queue.first.?; + const node = self.queue.first.?; evicted[i] = node.data.value; self.queue.remove(node); _ = self.map.remove(node.data.key); diff --git a/src/os/wasm.zig b/src/os/wasm.zig index e8f32965b..92e12fe62 100644 --- a/src/os/wasm.zig +++ b/src/os/wasm.zig @@ -94,7 +94,7 @@ pub fn toModuleOwned(ptr: anytype) void { test "basics" { const testing = std.testing; - var buf = malloc(32).?; + const buf = malloc(32).?; try testing.expect(allocs.size == 1); free(buf); try testing.expect(allocs.size == 0); @@ -104,7 +104,7 @@ test "toHostOwned" { const testing = std.testing; const Point = struct { x: u32 = 0, y: u32 = 0 }; - var p = try alloc.create(Point); + const p = try alloc.create(Point); errdefer alloc.destroy(p); const ptr = try toHostOwned(p); try testing.expect(allocs.size == 1); diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 0d0147835..73a65a22d 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1305,7 +1305,7 @@ pub fn updateCell( // The colors for the cell. const colors: BgFg = colors: { // If we are selected, we our colors are just inverted fg/bg - var selection_res: ?BgFg = if (selected) .{ + const selection_res: ?BgFg = if (selected) .{ .bg = self.config.selection_background orelse self.foreground_color, .fg = self.config.selection_foreground orelse self.background_color, } else null; diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 62fdac1c3..12b20aec5 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1087,7 +1087,7 @@ pub fn updateCell( // The colors for the cell. const colors: BgFg = colors: { // If we are selected, we our colors are just inverted fg/bg - var selection_res: ?BgFg = if (selected) .{ + const selection_res: ?BgFg = if (selected) .{ .bg = self.config.selection_background orelse self.foreground_color, .fg = self.config.selection_foreground orelse self.background_color, } else null; diff --git a/src/segmented_pool.zig b/src/segmented_pool.zig index ae866f729..8a91ed745 100644 --- a/src/segmented_pool.zig +++ b/src/segmented_pool.zig @@ -67,8 +67,8 @@ test "SegmentedPool" { try testing.expectEqual(@as(usize, 2), list.available); // Get to capacity - var v1 = try list.get(); - var v2 = try list.get(); + const v1 = try list.get(); + const v2 = try list.get(); try testing.expect(v1 != v2); try testing.expectError(error.OutOfValues, list.get()); @@ -77,13 +77,13 @@ test "SegmentedPool" { // Put a value back list.put(); - var temp = try list.get(); + const temp = try list.get(); try testing.expect(v1 == temp); try testing.expect(temp.* == 42); try testing.expectError(error.OutOfValues, list.get()); // Grow - var v3 = try list.getGrow(testing.allocator); + const v3 = try list.getGrow(testing.allocator); try testing.expect(v1 != v3 and v2 != v3); _ = try list.get(); try testing.expectError(error.OutOfValues, list.get()); diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 9e27873bf..a92175e15 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -1944,7 +1944,7 @@ fn jumpPrompt(self: *Screen, delta: isize) bool { const max_y: isize = @intCast(self.rowsWritten() - 1); // Go line-by-line counting the number of prompts we see. - var step: isize = if (delta > 0) 1 else -1; + const step: isize = if (delta > 0) 1 else -1; var y: isize = start_y + step; const delta_start: usize = @intCast(if (delta > 0) delta else -delta); var delta_rem: usize = delta_start; @@ -2040,7 +2040,7 @@ pub fn selectionString( var buf_i: usize = 0; var row_count: usize = 0; for (arr) |slice| { - var row_start: usize = row_count; + const row_start: usize = row_count; while (row_count < slices.rows) : (row_count += 1) { const row_i = row_count - row_start; @@ -2566,7 +2566,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { // Convert our cursor coordinates to screen coordinates because // we may have to reflow the cursor if the line it is on is moved. - var cursor_pos = (point.Viewport{ + const cursor_pos = (point.Viewport{ .x = old.cursor.x, .y = old.cursor.y, }).toScreen(&old); @@ -2684,7 +2684,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { } // Write the cell - var new_cell = row.getCellPtr(x); + const new_cell = row.getCellPtr(x); new_cell.* = cell.cell; // If the old cell is a multi-codepoint grapheme then we @@ -3178,7 +3178,7 @@ test "Screen" { try s.testWriteString(str); try testing.expect(s.rowsWritten() == 3); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -3200,7 +3200,7 @@ test "Screen" { { var it = s.rowIterator(.viewport); while (it.next()) |row| row.fill(.{ .char = 'A' }); - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("AAAAA\nAAAAA\nAAAAA", contents); } @@ -3273,7 +3273,7 @@ test "Screen: scrolling" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3288,7 +3288,7 @@ test "Screen: scrolling" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3308,7 +3308,7 @@ test "Screen: scroll down from 0" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3325,7 +3325,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3336,7 +3336,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3347,7 +3347,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3357,7 +3357,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3367,7 +3367,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3377,7 +3377,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3387,7 +3387,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3396,7 +3396,7 @@ test "Screen: scrollback" { var it = s.rowIterator(.active); while (it.next()) |row| row.clear(.{}); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD", contents); } @@ -3406,7 +3406,7 @@ test "Screen: scrollback" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("", contents); } @@ -3425,7 +3425,7 @@ test "Screen: scrollback with large delta" { try s.scroll(.{ .top = {} }); { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3435,7 +3435,7 @@ test "Screen: scrollback with large delta" { try testing.expect(s.viewportIsBottom()); { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("4ABCD\n5EFGH\n6IJKL", contents); } @@ -3452,7 +3452,7 @@ test "Screen: scrollback empty" { { // Test our contents - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3470,7 +3470,7 @@ test "Screen: scrollback doesn't move viewport if not at bottom" { try s.scroll(.{ .screen = -1 }); try testing.expect(!s.viewportIsBottom()); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL\n4ABCD", contents); } @@ -3480,7 +3480,7 @@ test "Screen: scrollback doesn't move viewport if not at bottom" { try s.scroll(.{ .screen = 1 }); try testing.expect(!s.viewportIsBottom()); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL\n4ABCD", contents); } @@ -3490,7 +3490,7 @@ test "Screen: scrollback doesn't move viewport if not at bottom" { try s.scroll(.{ .screen = 1 }); try testing.expect(!s.viewportIsBottom()); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL\n4ABCD", contents); } @@ -3500,7 +3500,7 @@ test "Screen: scrollback doesn't move viewport if not at bottom" { try s.scroll(.{ .screen = 1 }); try testing.expect(!s.viewportIsBottom()); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("3IJKL\n4ABCD\n5EFGH", contents); } @@ -3533,7 +3533,7 @@ test "Screen: scrolling moves selection" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3549,7 +3549,7 @@ test "Screen: scrolling moves selection" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3588,7 +3588,7 @@ test "Screen: scrolling with scrollback available doesn't move selection" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3605,7 +3605,7 @@ test "Screen: scrolling with scrollback available doesn't move selection" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -3618,7 +3618,7 @@ test "Screen: scrolling with scrollback available doesn't move selection" { { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("3IJKL", contents); } @@ -3635,7 +3635,7 @@ test "Screen: history region with no scrollback" { const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -3659,20 +3659,20 @@ test "Screen: history region with scrollback" { const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); } { // Test our contents - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } { - var contents = try s.testString(alloc, .history); + const contents = try s.testString(alloc, .history); defer alloc.free(contents); const expected = "1ABCD\n2EFGH"; try testing.expectEqualStrings(expected, contents); @@ -3691,7 +3691,7 @@ test "Screen: row copy" { try s.copyRow(.{ .active = 2 }, .{ .active = 0 }); // Test our contents - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL\n2EFGH", contents); } @@ -3710,7 +3710,7 @@ test "Screen: clone" { defer s2.deinit(); // Test our contents rotated - var contents = try s2.testString(alloc, .viewport); + const contents = try s2.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH", contents); } @@ -3720,7 +3720,7 @@ test "Screen: clone" { defer s2.deinit(); // Test our contents rotated - var contents = try s2.testString(alloc, .viewport); + const contents = try s2.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -3738,7 +3738,7 @@ test "Screen: clone empty viewport" { defer s2.deinit(); // Test our contents rotated - var contents = try s2.testString(alloc, .viewport); + const contents = try s2.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("", contents); } @@ -3757,7 +3757,7 @@ test "Screen: clone one line viewport" { defer s2.deinit(); // Test our contents - var contents = try s2.testString(alloc, .viewport); + const contents = try s2.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABC", contents); } @@ -3775,7 +3775,7 @@ test "Screen: clone empty active" { defer s2.deinit(); // Test our contents rotated - var contents = try s2.testString(alloc, .active); + const contents = try s2.testString(alloc, .active); defer alloc.free(contents); try testing.expectEqualStrings("", contents); } @@ -3797,7 +3797,7 @@ test "Screen: clone one line active with extra space" { defer s2.deinit(); // Test our contents rotated - var contents = try s2.testString(alloc, .active); + const contents = try s2.testString(alloc, .active); defer alloc.free(contents); try testing.expectEqualStrings("1ABC", contents); } @@ -4207,7 +4207,7 @@ test "Screen: scrollRegionUp single" { s.scrollRegionUp(.{ .active = 1 }, .{ .active = 2 }, 1); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n3IJKL\n\n4ABCD", contents); } @@ -4224,7 +4224,7 @@ test "Screen: scrollRegionUp same line" { s.scrollRegionUp(.{ .active = 1 }, .{ .active = 1 }, 1); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL\n4ABCD", contents); } @@ -4245,7 +4245,7 @@ test "Screen: scrollRegionUp single with pen" { s.scrollRegionUp(.{ .active = 1 }, .{ .active = 2 }, 1); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n3IJKL\n\n4ABCD", contents); const cell = s.getCell(.active, 2, 0); @@ -4266,7 +4266,7 @@ test "Screen: scrollRegionUp multiple" { s.scrollRegionUp(.{ .active = 1 }, .{ .active = 3 }, 1); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n3IJKL\n4ABCD", contents); } @@ -4283,7 +4283,7 @@ test "Screen: scrollRegionUp multiple count" { s.scrollRegionUp(.{ .active = 1 }, .{ .active = 3 }, 2); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n4ABCD", contents); } @@ -4300,7 +4300,7 @@ test "Screen: scrollRegionUp count greater than available lines" { s.scrollRegionUp(.{ .active = 1 }, .{ .active = 2 }, 10); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n\n\n4ABCD", contents); } @@ -4320,7 +4320,7 @@ test "Screen: scrollRegionUp fills with pen" { s.scrollRegionUp(.{ .active = 0 }, .{ .active = 2 }, 1); { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("B\nC\n\nD", contents); const cell = s.getCell(.active, 2, 0); @@ -4353,7 +4353,7 @@ test "Screen: scrollRegionUp buffer wrap" { { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("3IJKL\n4ABCD", contents); const cell = s.getCell(.active, 2, 0); @@ -4386,7 +4386,7 @@ test "Screen: scrollRegionUp buffer wrap alternate" { { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("4ABCD", contents); const cell = s.getCell(.active, 2, 0); @@ -4428,7 +4428,7 @@ test "Screen: scrollRegionUp buffer wrap alternative with extra lines" { { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("3IJKL\n4ABCD\n\n\n5EFGH", contents); } @@ -4446,13 +4446,13 @@ test "Screen: clear history with no history" { try testing.expect(s.viewportIsBottom()); { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("4ABCD\n5EFGH\n6IJKL", contents); } { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("4ABCD\n5EFGH\n6IJKL", contents); } @@ -4471,7 +4471,7 @@ test "Screen: clear history" { try s.scroll(.{ .top = {} }); { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents); } @@ -4480,13 +4480,13 @@ test "Screen: clear history" { try testing.expect(s.viewportIsBottom()); { // Test our contents rotated - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("4ABCD\n5EFGH\n6IJKL", contents); } { // Test our contents rotated - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("4ABCD\n5EFGH\n6IJKL", contents); } @@ -4503,12 +4503,12 @@ test "Screen: clear above cursor" { try s.clear(.above_cursor); try testing.expect(s.viewportIsBottom()); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("6IJKL", contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("6IJKL", contents); } @@ -4529,12 +4529,12 @@ test "Screen: clear above cursor with history" { try s.clear(.above_cursor); try testing.expect(s.viewportIsBottom()); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("6IJKL", contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL\n6IJKL", contents); } @@ -4553,7 +4553,7 @@ test "Screen: selectionString basic" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 1 }, .end = .{ .x = 2, .y = 2 }, }, true); @@ -4573,7 +4573,7 @@ test "Screen: selectionString start outside of written area" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 5 }, .end = .{ .x = 2, .y = 6 }, }, true); @@ -4593,7 +4593,7 @@ test "Screen: selectionString end outside of written area" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 2 }, .end = .{ .x = 2, .y = 6 }, }, true); @@ -4613,7 +4613,7 @@ test "Screen: selectionString trim space" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 2, .y = 1 }, }, true); @@ -4624,7 +4624,7 @@ test "Screen: selectionString trim space" { // No trim { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 2, .y = 1 }, }, false); @@ -4644,7 +4644,7 @@ test "Screen: selectionString trim empty line" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 2, .y = 2 }, }, true); @@ -4655,7 +4655,7 @@ test "Screen: selectionString trim empty line" { // No trim { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 2, .y = 2 }, }, false); @@ -4675,7 +4675,7 @@ test "Screen: selectionString soft wrap" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 1 }, .end = .{ .x = 2, .y = 2 }, }, true); @@ -4701,7 +4701,7 @@ test "Screen: selectionString wrap around" { try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 1 }, .end = .{ .x = 2, .y = 2 }, }, true); @@ -4721,7 +4721,7 @@ test "Screen: selectionString wide char" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 3, .y = 0 }, }, true); @@ -4731,7 +4731,7 @@ test "Screen: selectionString wide char" { } { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 2, .y = 0 }, }, true); @@ -4741,7 +4741,7 @@ test "Screen: selectionString wide char" { } { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 3, .y = 0 }, .end = .{ .x = 3, .y = 0 }, }, true); @@ -4761,7 +4761,7 @@ test "Screen: selectionString wide char with header" { try s.testWriteString(str); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 4, .y = 0 }, }, true); @@ -4790,7 +4790,7 @@ test "Screen: selectionString empty with soft wrap" { try s.testWriteString(" "); { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 1, .y = 0 }, .end = .{ .x = 2, .y = 0 }, }, true); @@ -4826,7 +4826,7 @@ test "Screen: selectionString with zero width joiner" { // The real test { - var contents = try s.selectionString(alloc, .{ + const contents = try s.selectionString(alloc, .{ .start = .{ .x = 0, .y = 0 }, .end = .{ .x = 1, .y = 0 }, }, true); @@ -4969,7 +4969,7 @@ test "Screen: resize (no reflow) more rows" { // Resize try s.resizeWithoutReflow(10, 5); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -4990,7 +4990,7 @@ test "Screen: resize (no reflow) less rows" { try s.resizeWithoutReflow(2, 5); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents); } @@ -5026,7 +5026,7 @@ test "Screen: resize (no reflow) less rows trims blank lines" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD", contents); } @@ -5062,7 +5062,7 @@ test "Screen: resize (no reflow) more rows trims blank lines" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings("1ABCD", contents); } @@ -5079,7 +5079,7 @@ test "Screen: resize (no reflow) more cols" { try s.resizeWithoutReflow(3, 10); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5096,7 +5096,7 @@ test "Screen: resize (no reflow) less cols" { try s.resizeWithoutReflow(3, 4); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABC\n2EFG\n3IJK"; try testing.expectEqualStrings(expected, contents); @@ -5114,7 +5114,7 @@ test "Screen: resize (no reflow) more rows with scrollback" { try s.resizeWithoutReflow(10, 5); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5131,7 +5131,7 @@ test "Screen: resize (no reflow) less rows with scrollback" { try s.resizeWithoutReflow(2, 5); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "2EFGH\n3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5185,7 +5185,7 @@ test "Screen: resize (no reflow) grapheme copy" { try s.resizeWithoutReflow(10, 5); { const expected = "1️A️B️C️D️\n2️E️F️G️H️\n3️I️J️K️L️"; - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(expected, contents); } @@ -5219,7 +5219,7 @@ test "Screen: resize (no reflow) more rows with soft wrapping" { // Resize try s.resizeWithoutReflow(10, 2); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1A\n2B\n3C\n4E\n5F\n6G"; try testing.expectEqualStrings(expected, contents); @@ -5251,12 +5251,12 @@ test "Screen: resize more rows no scrollback" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5277,12 +5277,12 @@ test "Screen: resize more rows with empty scrollback" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5297,7 +5297,7 @@ test "Screen: resize more rows with populated scrollback" { const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5315,7 +5315,7 @@ test "Screen: resize more rows with populated scrollback" { try testing.expectEqual(@as(u32, '4'), s.getCell(.active, s.cursor.y, s.cursor.x).char); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5330,7 +5330,7 @@ test "Screen: resize more rows and cols with wrapping" { const str = "1A2B\n3C4D"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1A\n2B\n3C\n4D"; try testing.expectEqualStrings(expected, contents); @@ -5343,12 +5343,12 @@ test "Screen: resize more rows and cols with wrapping" { try testing.expectEqual(@as(usize, 1), s.cursor.y); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5369,12 +5369,12 @@ test "Screen: resize more cols no reflow" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5414,12 +5414,12 @@ test "Screen: resize more cols no reflow preserves semantic prompt" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5467,13 +5467,13 @@ test "Screen: resize more cols grapheme map" { { const expected = "1️A️B️C️D️\n2️E️F️G️H️\n3️I️J️K️L️"; - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(expected, contents); } { const expected = "1️A️B️C️D️\n2️E️F️G️H️\n3️I️J️K️L️"; - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(expected, contents); } @@ -5490,7 +5490,7 @@ test "Screen: resize more cols with reflow that fits full width" { // Verify we soft wrapped { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABCD\n2EFGH\n3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5504,7 +5504,7 @@ test "Screen: resize more cols with reflow that fits full width" { // Resize and verify we undid the soft wrap because we have space now try s.resize(3, 10); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5525,7 +5525,7 @@ test "Screen: resize more cols with reflow that ends in newline" { // Verify we soft wrapped { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABCD2\nEFGH\n3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5539,7 +5539,7 @@ test "Screen: resize more cols with reflow that ends in newline" { // Resize and verify we undid the soft wrap because we have space now try s.resize(3, 10); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5564,7 +5564,7 @@ test "Screen: resize more cols with reflow that forces more wrapping" { // Verify we soft wrapped { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABCD\n2EFGH\n3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5573,7 +5573,7 @@ test "Screen: resize more cols with reflow that forces more wrapping" { // Resize and verify we undid the soft wrap because we have space now try s.resize(3, 7); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABCD2E\nFGH\n3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5600,7 +5600,7 @@ test "Screen: resize more cols with reflow that unwraps multiple times" { // Verify we soft wrapped { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABCD\n2EFGH\n3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5609,7 +5609,7 @@ test "Screen: resize more cols with reflow that unwraps multiple times" { // Resize and verify we undid the soft wrap because we have space now try s.resize(3, 15); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1ABCD2EFGH3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5629,7 +5629,7 @@ test "Screen: resize more cols with populated scrollback" { const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD5EFGH"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5647,7 +5647,7 @@ test "Screen: resize more cols with populated scrollback" { try testing.expectEqual(@as(u32, '5'), s.getCell(.active, s.cursor.y, s.cursor.x).char); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "2EFGH\n3IJKL\n4ABCD5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5670,7 +5670,7 @@ test "Screen: resize more cols with reflow" { // Verify we soft wrapped { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "BC\n4D\nEF"; try testing.expectEqualStrings(expected, contents); @@ -5680,7 +5680,7 @@ test "Screen: resize more cols with reflow" { try s.resize(3, 7); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "1ABC\n2DEF\n3ABC\n4DEF"; try testing.expectEqualStrings(expected, contents); @@ -5708,13 +5708,13 @@ test "Screen: resize less rows no scrollback" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5743,13 +5743,13 @@ test "Screen: resize less rows moving cursor" { try testing.expectEqual(@as(usize, 0), s.cursor.y); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5767,12 +5767,12 @@ test "Screen: resize less rows with empty scrollback" { try s.resize(1, 5); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL"; try testing.expectEqualStrings(expected, contents); @@ -5788,7 +5788,7 @@ test "Screen: resize less rows with populated scrollback" { const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5798,12 +5798,12 @@ test "Screen: resize less rows with populated scrollback" { try s.resize(1, 5); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5819,7 +5819,7 @@ test "Screen: resize less rows with full scrollback" { const str = "00000\n1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5836,13 +5836,13 @@ test "Screen: resize less rows with full scrollback" { try testing.expectEqual(Cursor{ .x = 4, .y = 1 }, s.cursor); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -5866,12 +5866,12 @@ test "Screen: resize less cols no reflow" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5905,12 +5905,12 @@ test "Screen: resize less cols trailing background colors" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -5953,13 +5953,13 @@ test "Screen: resize less cols with graphemes" { { const expected = "1️A️B️\n2️E️F️\n3️I️J️"; - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(expected, contents); } { const expected = "1️A️B️\n2️E️F️\n3️I️J️"; - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(expected, contents); } @@ -5989,12 +5989,12 @@ test "Screen: resize less cols no reflow preserves semantic prompt" { try testing.expectEqual(cursor, s.cursor); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6030,13 +6030,13 @@ test "Screen: resize less cols with reflow but row space" { try s.resize(3, 3); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "1AB\nCD"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "1AB\nCD"; try testing.expectEqualStrings(expected, contents); @@ -6058,13 +6058,13 @@ test "Screen: resize less cols with reflow with trimmed rows" { try s.resize(3, 3); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "CD\n5EF\nGH"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "CD\n5EF\nGH"; try testing.expectEqualStrings(expected, contents); @@ -6082,13 +6082,13 @@ test "Screen: resize less cols with reflow with trimmed rows and scrollback" { try s.resize(3, 3); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "CD\n5EF\nGH"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "4AB\nCD\n5EF\nGH"; try testing.expectEqualStrings(expected, contents); @@ -6106,7 +6106,7 @@ test "Screen: resize less cols with reflow previously wrapped" { // Check { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -6115,13 +6115,13 @@ test "Screen: resize less cols with reflow previously wrapped" { try s.resize(3, 3); // { - // var contents = try s.testString(alloc, .viewport); + // const contents = try s.testString(alloc, .viewport); // defer alloc.free(contents); // const expected = "CD\n5EF\nGH"; // try testing.expectEqualStrings(expected, contents); // } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "ABC\nD5E\nFGH"; try testing.expectEqualStrings(expected, contents); @@ -6145,7 +6145,7 @@ test "Screen: resize less cols with reflow and scrollback" { try s.resize(3, 3); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3C\n4D\n5E"; try testing.expectEqualStrings(expected, contents); @@ -6167,7 +6167,7 @@ test "Screen: resize less cols with reflow previously wrapped and scrollback" { // Check { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "3IJKL\n4ABCD\n5EFGH"; try testing.expectEqualStrings(expected, contents); @@ -6181,13 +6181,13 @@ test "Screen: resize less cols with reflow previously wrapped and scrollback" { try s.resize(3, 3); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "CD5\nEFG\nH"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "JKL\n4AB\nCD5\nEFG\nH"; try testing.expectEqualStrings(expected, contents); @@ -6209,13 +6209,13 @@ test "Screen: resize more rows, less cols with reflow with scrollback" { try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "1ABCD\n2EFGH\n3IJKL\n4MNOP"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "2EFGH\n3IJKL\n4MNOP"; try testing.expectEqualStrings(expected, contents); @@ -6224,13 +6224,13 @@ test "Screen: resize more rows, less cols with reflow with scrollback" { try s.resize(10, 2); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); const expected = "BC\nD\n2E\nFG\nH3\nIJ\nKL\n4M\nNO\nP"; try testing.expectEqualStrings(expected, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); const expected = "1A\nBC\nD\n2E\nFG\nH3\nIJ\nKL\n4M\nNO\nP"; try testing.expectEqualStrings(expected, contents); @@ -6252,12 +6252,12 @@ test "Screen: resize more rows then shrink again" { // Grow try s.resize(10, 5); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6265,12 +6265,12 @@ test "Screen: resize more rows then shrink again" { // Shrink try s.resize(3, 5); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6278,12 +6278,12 @@ test "Screen: resize more rows then shrink again" { // Grow again try s.resize(10, 5); { - var contents = try s.testString(alloc, .viewport); + const contents = try s.testString(alloc, .viewport); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6298,7 +6298,7 @@ test "Screen: resize less cols to eliminate wide char" { const str = "😀"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6311,7 +6311,7 @@ test "Screen: resize less cols to eliminate wide char" { // Resize to 1 column can't fit a wide char. So it should be deleted. try s.resize(1, 1); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(" ", contents); } @@ -6332,7 +6332,7 @@ test "Screen: resize less cols to wrap wide char" { const str = "x😀"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6345,7 +6345,7 @@ test "Screen: resize less cols to wrap wide char" { try s.resize(3, 2); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("x\n😀", contents); } @@ -6367,7 +6367,7 @@ test "Screen: resize less cols to eliminate wide char with row space" { const str = "😀"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6380,7 +6380,7 @@ test "Screen: resize less cols to eliminate wide char with row space" { try s.resize(2, 1); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(" \n ", contents); } @@ -6402,7 +6402,7 @@ test "Screen: resize more cols with wide spacer head" { const str = " 😀"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(" \n😀", contents); } @@ -6421,7 +6421,7 @@ test "Screen: resize more cols with wide spacer head" { try s.resize(2, 4); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6449,7 +6449,7 @@ test "Screen: resize less cols preserves grapheme cluster" { try testing.expectEqual(@as(usize, 2), row.codepointLen(0)); } { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6458,7 +6458,7 @@ test "Screen: resize less cols preserves grapheme cluster" { // the same grapheme cluster. try s.resize(1, 4); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6473,7 +6473,7 @@ test "Screen: resize more cols with wide spacer head multiple lines" { const str = "xxxyy😀"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("xxx\nyy\n😀", contents); } @@ -6490,7 +6490,7 @@ test "Screen: resize more cols with wide spacer head multiple lines" { try s.resize(2, 8); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings(str, contents); } @@ -6512,7 +6512,7 @@ test "Screen: resize more cols requiring a wide spacer head" { const str = "xx😀"; try s.testWriteString(str); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("xx\n😀", contents); } @@ -6526,7 +6526,7 @@ test "Screen: resize more cols requiring a wide spacer head" { // end of the first row since we're wrapping to the next row. try s.resize(2, 3); { - var contents = try s.testString(alloc, .screen); + const contents = try s.testString(alloc, .screen); defer alloc.free(contents); try testing.expectEqualStrings("xx\n😀", contents); } diff --git a/src/terminal/Tabstops.zig b/src/terminal/Tabstops.zig index 15e45c6b8..5a54fb28b 100644 --- a/src/terminal/Tabstops.zig +++ b/src/terminal/Tabstops.zig @@ -215,7 +215,7 @@ test "Tabstops: count on 80" { defer t.deinit(testing.allocator); // Count the tabstops - var count: usize = count: { + const count: usize = count: { var v: usize = 0; var i: usize = 0; while (i < 80) : (i += 1) { diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 5b3052099..b6544d36d 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -991,7 +991,7 @@ pub fn decaln(self: *Terminal) !void { }; // Our pen has the letter E - var pen: Screen.Cell = .{ .char = 'E' }; + const pen: Screen.Cell = .{ .char = 'E' }; // Fill with Es, does not move cursor. for (0..self.rows) |y| { @@ -2116,7 +2116,7 @@ test "Terminal: input with no control characters" { try testing.expectEqual(@as(usize, 0), t.screen.cursor.y); try testing.expectEqual(@as(usize, 5), t.screen.cursor.x); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hello", str); } @@ -2167,7 +2167,7 @@ test "Terminal: print over wide spacer tail" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -2198,7 +2198,7 @@ test "Terminal: zero width chars with grapheme clustering can be put in their ow try t.print(0x7F); // zero-width control character { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("x", str); } @@ -2223,7 +2223,7 @@ test "Terminal: VS15 to make narrow character" { try t.print(0xFE0E); // VS15 to make narrow { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("⛈︎", str); } @@ -2248,7 +2248,7 @@ test "Terminal: VS16 to make wide character with mode 2027" { try t.print(0xFE0F); // VS16 to make wide { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("❤️", str); } @@ -2275,7 +2275,7 @@ test "Terminal: VS16 repeated with mode 2027" { try t.print(0xFE0F); // VS16 to make wide { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("❤️❤️", str); } @@ -2306,7 +2306,7 @@ test "Terminal: VS16 doesn't make character with 2027 disabled" { try t.print(0xFE0F); // VS16 to make wide { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("❤️", str); } @@ -2420,7 +2420,7 @@ test "Terminal: soft wrap" { try testing.expectEqual(@as(usize, 1), t.screen.cursor.y); try testing.expectEqual(@as(usize, 2), t.screen.cursor.x); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hel\nlo", str); } @@ -2440,7 +2440,7 @@ test "Terminal: print writes to bottom if scrolled" { try t.index(); try t.index(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("", str); } @@ -2448,7 +2448,7 @@ test "Terminal: print writes to bottom if scrolled" { // Scroll to the top try t.scrollViewport(.{ .top = {} }); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hello", str); } @@ -2457,7 +2457,7 @@ test "Terminal: print writes to bottom if scrolled" { try t.print('A'); try t.scrollViewport(.{ .bottom = {} }); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nA", str); } @@ -2481,7 +2481,7 @@ test "Terminal: print charset" { t.configureCharset(.G0, .dec_special); try t.print('`'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("```◆", str); } @@ -2501,7 +2501,7 @@ test "Terminal: print charset outside of ASCII" { try t.print('`'); try t.print(0x1F600); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("◆ ", str); } @@ -2521,7 +2521,7 @@ test "Terminal: print invoke charset" { t.invokeCharset(.GL, .G0, false); try t.print('`'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("`◆◆`", str); } @@ -2539,7 +2539,7 @@ test "Terminal: print invoke charset single" { try t.print('`'); try t.print('`'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("`◆`", str); } @@ -2556,7 +2556,7 @@ test "Terminal: print right margin wrap" { try t.printString("XY"); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("1234X6789\n Y", str); } @@ -2573,7 +2573,7 @@ test "Terminal: print right margin outside" { try t.printString("XY"); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("12345XY89", str); } @@ -2590,7 +2590,7 @@ test "Terminal: print right margin outside wrap" { try t.printString("XY"); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("123456789X\n Y", str); } @@ -2608,7 +2608,7 @@ test "Terminal: linefeed and carriage return" { try testing.expectEqual(@as(usize, 1), t.screen.cursor.y); try testing.expectEqual(@as(usize, 5), t.screen.cursor.x); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hello\nworld", str); } @@ -2635,7 +2635,7 @@ test "Terminal: linefeed mode automatic carriage return" { try t.linefeed(); try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("123456\nX", str); } @@ -2694,7 +2694,7 @@ test "Terminal: backspace" { try testing.expectEqual(@as(usize, 0), t.screen.cursor.y); try testing.expectEqual(@as(usize, 5), t.screen.cursor.x); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("helly", str); } @@ -2733,7 +2733,7 @@ test "Terminal: horizontal tabs starting on tabstop" { try t.print('A'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X A", str); } @@ -2752,7 +2752,7 @@ test "Terminal: horizontal tabs with right margin" { try t.print('A'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X A", str); } @@ -2793,7 +2793,7 @@ test "Terminal: horizontal tabs back starting on tabstop" { try t.print('A'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A X", str); } @@ -2813,7 +2813,7 @@ test "Terminal: horizontal tabs with left margin in origin mode" { try t.print('A'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" AX", str); } @@ -2833,7 +2833,7 @@ test "Terminal: horizontal tab back with cursor before left margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X", str); } @@ -2851,7 +2851,7 @@ test "Terminal: cursorPos resets wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("XBCDE", str); } @@ -2866,7 +2866,7 @@ test "Terminal: cursorPos off the screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n\n\n X", str); } @@ -2884,7 +2884,7 @@ test "Terminal: cursorPos relative to origin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\nX", str); } @@ -2904,7 +2904,7 @@ test "Terminal: cursorPos relative to origin with left/right" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n X", str); } @@ -2924,7 +2924,7 @@ test "Terminal: cursorPos limits with full scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n\n X", str); } @@ -2998,7 +2998,7 @@ test "Terminal: setTopAndBottomMargin simple" { try t.scrollDown(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nABC\nDEF\nGHI", str); } @@ -3020,7 +3020,7 @@ test "Terminal: setTopAndBottomMargin top only" { try t.scrollDown(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\n\nDEF\nGHI", str); } @@ -3042,7 +3042,7 @@ test "Terminal: setTopAndBottomMargin top and bottom" { try t.scrollDown(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nABC\nGHI", str); } @@ -3064,7 +3064,7 @@ test "Terminal: setTopAndBottomMargin top equal to bottom" { try t.scrollDown(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nABC\nDEF\nGHI", str); } @@ -3087,7 +3087,7 @@ test "Terminal: setLeftAndRightMargin simple" { t.eraseChars(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" BC\nDEF\nGHI", str); } @@ -3113,7 +3113,7 @@ test "Terminal: setLeftAndRightMargin left only" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nDBC\nGEF\n HI", str); } @@ -3137,7 +3137,7 @@ test "Terminal: setLeftAndRightMargin left and right" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" C\nABF\nDEI\nGH", str); } @@ -3161,7 +3161,7 @@ test "Terminal: setLeftAndRightMargin left equal right" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nABC\nDEF\nGHI", str); } @@ -3185,7 +3185,7 @@ test "Terminal: setLeftAndRightMargin mode 69 unset" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nABC\nDEF\nGHI", str); } @@ -3220,7 +3220,7 @@ test "Terminal: deleteLines" { try testing.expectEqual(@as(usize, 2), t.screen.cursor.y); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nE\nD", str); } @@ -3256,7 +3256,7 @@ test "Terminal: deleteLines with scroll region" { // try testing.expectEqual(@as(usize, 2), t.screen.cursor.y); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("E\nC\n\nD", str); } @@ -3292,7 +3292,7 @@ test "Terminal: deleteLines with scroll region, large count" { // try testing.expectEqual(@as(usize, 2), t.screen.cursor.y); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("E\n\n\nD", str); } @@ -3320,7 +3320,7 @@ test "Terminal: deleteLines with scroll region, cursor outside of region" { try t.deleteLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nB\nC\nD", str); } @@ -3338,7 +3338,7 @@ test "Terminal: deleteLines resets wrap" { try t.print('B'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("B", str); } @@ -3360,7 +3360,7 @@ test "Terminal: deleteLines simple" { try t.deleteLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nGHI", str); } @@ -3384,7 +3384,7 @@ test "Terminal: deleteLines left/right scroll region" { try t.deleteLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC123\nDHI756\nG 89", str); } @@ -3427,7 +3427,7 @@ test "Terminal: deleteLines left/right scroll region from top" { try t.deleteLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AEF423\nDHI756\nG 89", str); } @@ -3451,7 +3451,7 @@ test "Terminal: deleteLines left/right scroll region high count" { try t.deleteLines(100); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC123\nD 56\nG 89", str); } @@ -3473,7 +3473,7 @@ test "Terminal: insertLines simple" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\n\nDEF\nGHI", str); } @@ -3496,7 +3496,7 @@ test "Terminal: insertLines outside of scroll region" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\nGHI", str); } @@ -3522,7 +3522,7 @@ test "Terminal: insertLines top/bottom scroll region" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\n\nDEF\n123", str); } @@ -3546,7 +3546,7 @@ test "Terminal: insertLines left/right scroll region" { try t.insertLines(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC123\nD 56\nGEF489\n HI7", str); } @@ -3579,7 +3579,7 @@ test "Terminal: insertLines" { try t.insertLines(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n\n\nB\nC", str); } @@ -3622,7 +3622,7 @@ test "Terminal: insertLines with scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X\nA\nC\nD\nE", str); } @@ -3655,7 +3655,7 @@ test "Terminal: insertLines more than remaining" { try t.insertLines(20); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A", str); } @@ -3673,7 +3673,7 @@ test "Terminal: insertLines resets wrap" { try t.print('B'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("B\nABCDE", str); } @@ -3700,7 +3700,7 @@ test "Terminal: reverseIndex" { try t.linefeed(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nBD\nC", str); } @@ -3733,7 +3733,7 @@ test "Terminal: reverseIndex from the top" { try t.linefeed(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("E\nD\nA\nB", str); } @@ -3766,7 +3766,7 @@ test "Terminal: reverseIndex top of scrolling region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nX\nA\nB\nC", str); } @@ -3787,7 +3787,7 @@ test "Terminal: reverseIndex top of screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X\nA\nB\nC", str); } @@ -3808,7 +3808,7 @@ test "Terminal: reverseIndex not top of screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X\nB\nC", str); } @@ -3829,7 +3829,7 @@ test "Terminal: reverseIndex top/bottom margins" { try t.reverseIndex(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n\nB", str); } @@ -3850,7 +3850,7 @@ test "Terminal: reverseIndex outside top/bottom margins" { try t.reverseIndex(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nB\nC", str); } @@ -3872,7 +3872,7 @@ test "Terminal: reverseIndex left/right margins" { try t.reverseIndex(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nDBC\nGEF\n HI", str); } @@ -3894,7 +3894,7 @@ test "Terminal: reverseIndex outside left/right margins" { try t.reverseIndex(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\nGHI", str); } @@ -3909,7 +3909,7 @@ test "Terminal: index" { try t.print('A'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nA", str); } @@ -3928,7 +3928,7 @@ test "Terminal: index from the bottom" { try t.print('B'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n\nA\nB", str); } @@ -3957,7 +3957,7 @@ test "Terminal: index from the bottom outside of scroll region" { try t.print('B'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n\n\nAB", str); } @@ -3973,7 +3973,7 @@ test "Terminal: index no scroll region, top of screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n X", str); } @@ -3990,7 +3990,7 @@ test "Terminal: index bottom of primary screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n\nA\n X", str); } @@ -4012,7 +4012,7 @@ test "Terminal: index bottom of primary screen background sgr" { try t.index(); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\n\nA", str); for (0..5) |x| { @@ -4033,7 +4033,7 @@ test "Terminal: index inside scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n X", str); } @@ -4053,7 +4053,7 @@ test "Terminal: index bottom of scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nA\n X\nB", str); } @@ -4074,7 +4074,7 @@ test "Terminal: index bottom of primary screen with scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\nA\n\nX", str); } @@ -4095,7 +4095,7 @@ test "Terminal: index outside left/right margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\nX A", str); } @@ -4123,7 +4123,7 @@ test "Terminal: index inside left/right margin" { try testing.expectEqual(@as(usize, 0), t.screen.cursor.x); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AAAAAA\nAAAAAA\n AAA", str); } @@ -4145,7 +4145,7 @@ test "Terminal: DECALN" { try testing.expectEqual(@as(usize, 0), t.screen.cursor.x); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("EE\nEE", str); } @@ -4163,7 +4163,7 @@ test "Terminal: decaln reset margins" { try t.scrollDown(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nEEE\nEEE", str); } @@ -4187,7 +4187,7 @@ test "Terminal: decaln preserves color" { try t.scrollDown(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nEEE\nEEE", str); const cell = t.screen.getCell(.active, 0, 0); @@ -4210,7 +4210,7 @@ test "Terminal: insertBlanks" { t.insertBlanks(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" ABC", str); const cell = t.screen.getCell(.active, 0, 0); @@ -4232,7 +4232,7 @@ test "Terminal: insertBlanks pushes off end" { t.insertBlanks(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" A", str); } @@ -4252,7 +4252,7 @@ test "Terminal: insertBlanks more than size" { t.insertBlanks(5); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("", str); } @@ -4268,7 +4268,7 @@ test "Terminal: insertBlanks no scroll region, fits" { t.insertBlanks(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" ABC", str); } @@ -4290,7 +4290,7 @@ test "Terminal: insertBlanks preserves background sgr" { t.insertBlanks(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" ABC", str); const cell = t.screen.getCell(.active, 0, 0); @@ -4309,7 +4309,7 @@ test "Terminal: insertBlanks shift off screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X A", str); } @@ -4326,7 +4326,7 @@ test "Terminal: insertBlanks split multi-cell character" { t.insertBlanks(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" 123", str); } @@ -4346,7 +4346,7 @@ test "Terminal: insertBlanks inside left/right scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X A", str); } @@ -4367,7 +4367,7 @@ test "Terminal: insertBlanks outside left/right scroll region" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" ABX", str); } @@ -4386,7 +4386,7 @@ test "Terminal: insertBlanks left/right scroll region large count" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -4403,7 +4403,7 @@ test "Terminal: insert mode with space" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hXello", str); } @@ -4420,7 +4420,7 @@ test "Terminal: insert mode doesn't wrap pushed characters" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hXell", str); } @@ -4436,7 +4436,7 @@ test "Terminal: insert mode does nothing at the end of the line" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("hello\nX", str); } @@ -4453,7 +4453,7 @@ test "Terminal: insert mode with wide characters" { try t.print('😀'); // 0x1F600 { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("h😀el", str); } @@ -4469,7 +4469,7 @@ test "Terminal: insert mode with wide characters at end" { try t.print('😀'); // 0x1F600 { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("well\n😀", str); } @@ -4487,7 +4487,7 @@ test "Terminal: insert mode pushing off wide character" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X123", str); } @@ -4560,7 +4560,7 @@ test "Terminal: deleteChars" { try t.deleteChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ADE", str); @@ -4579,7 +4579,7 @@ test "Terminal: deleteChars zero count" { try t.deleteChars(0); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDE", str); } @@ -4595,7 +4595,7 @@ test "Terminal: deleteChars more than half" { try t.deleteChars(3); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AE", str); } @@ -4611,7 +4611,7 @@ test "Terminal: deleteChars more than line width" { try t.deleteChars(10); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A", str); } @@ -4627,7 +4627,7 @@ test "Terminal: deleteChars should shift left" { try t.deleteChars(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ACDE", str); } @@ -4645,7 +4645,7 @@ test "Terminal: deleteChars resets wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX", str); } @@ -4661,7 +4661,7 @@ test "Terminal: deleteChars simple operation" { try t.deleteChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AB23", str); } @@ -4683,7 +4683,7 @@ test "Terminal: deleteChars background sgr" { try t.deleteChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AB23", str); for (t.cols - 2..t.cols) |x| { @@ -4706,7 +4706,7 @@ test "Terminal: deleteChars outside scroll region" { try testing.expect(t.screen.cursor.pending_wrap); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC123", str); } @@ -4724,7 +4724,7 @@ test "Terminal: deleteChars inside scroll region" { try t.deleteChars(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC2 3", str); } @@ -4740,7 +4740,7 @@ test "Terminal: deleteChars split wide character" { try t.deleteChars(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A 123", str); } @@ -4758,7 +4758,7 @@ test "Terminal: deleteChars split wide character tail" { try t.print('0'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("0", str); } @@ -4776,7 +4776,7 @@ test "Terminal: eraseChars resets wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX", str); } @@ -4793,7 +4793,7 @@ test "Terminal: eraseChars simple operation" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X C", str); } @@ -4810,7 +4810,7 @@ test "Terminal: eraseChars minimum one" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("XBC", str); } @@ -4826,7 +4826,7 @@ test "Terminal: eraseChars beyond screen edge" { t.eraseChars(10); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" A", str); } @@ -4848,7 +4848,7 @@ test "Terminal: eraseChars preserves background sgr" { t.eraseChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" C", str); { @@ -4874,7 +4874,7 @@ test "Terminal: eraseChars wide character" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X BC", str); } @@ -4891,7 +4891,7 @@ test "Terminal: eraseChars protected attributes respected with iso" { t.eraseChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC", str); } @@ -4910,7 +4910,7 @@ test "Terminal: eraseChars protected attributes ignored with dec most recent" { t.eraseChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" C", str); } @@ -4927,7 +4927,7 @@ test "Terminal: eraseChars protected attributes ignored with dec set" { t.eraseChars(2); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" C", str); } @@ -5029,7 +5029,7 @@ test "Terminal: saveCursor position" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("B AX", str); } @@ -5049,7 +5049,7 @@ test "Terminal: saveCursor pending wrap state" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("B A\nX", str); } @@ -5069,7 +5069,7 @@ test "Terminal: saveCursor origin mode" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X", str); } @@ -5087,7 +5087,7 @@ test "Terminal: saveCursor resize" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -5119,7 +5119,7 @@ test "Terminal: eraseLine simple erase right" { t.eraseLine(.right, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AB", str); } @@ -5137,7 +5137,7 @@ test "Terminal: eraseLine resets wrap" { try t.print('B'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDB", str); } @@ -5159,7 +5159,7 @@ test "Terminal: eraseLine right preserves background sgr" { t.eraseLine(.right, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A", str); for (1..5) |x| { @@ -5181,7 +5181,7 @@ test "Terminal: eraseLine right wide character" { t.eraseLine(.right, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AB", str); } @@ -5198,7 +5198,7 @@ test "Terminal: eraseLine right protected attributes respected with iso" { t.eraseLine(.right, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC", str); } @@ -5217,7 +5217,7 @@ test "Terminal: eraseLine right protected attributes ignored with dec most recen t.eraseLine(.right, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A", str); } @@ -5234,7 +5234,7 @@ test "Terminal: eraseLine right protected attributes ignored with dec set" { t.eraseLine(.right, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A", str); } @@ -5253,7 +5253,7 @@ test "Terminal: eraseLine right protected requested" { t.eraseLine(.right, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("123 X", str); } @@ -5269,7 +5269,7 @@ test "Terminal: eraseLine simple erase left" { t.eraseLine(.left, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" DE", str); } @@ -5287,7 +5287,7 @@ test "Terminal: eraseLine left resets wrap" { try t.print('B'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" B", str); } @@ -5309,7 +5309,7 @@ test "Terminal: eraseLine left preserves background sgr" { t.eraseLine(.left, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" CDE", str); for (0..2) |x| { @@ -5331,7 +5331,7 @@ test "Terminal: eraseLine left wide character" { t.eraseLine(.left, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" DE", str); } @@ -5348,7 +5348,7 @@ test "Terminal: eraseLine left protected attributes respected with iso" { t.eraseLine(.left, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC", str); } @@ -5367,7 +5367,7 @@ test "Terminal: eraseLine left protected attributes ignored with dec most recent t.eraseLine(.left, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" C", str); } @@ -5384,7 +5384,7 @@ test "Terminal: eraseLine left protected attributes ignored with dec set" { t.eraseLine(.left, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" C", str); } @@ -5403,7 +5403,7 @@ test "Terminal: eraseLine left protected requested" { t.eraseLine(.left, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X 9", str); } @@ -5425,7 +5425,7 @@ test "Terminal: eraseLine complete preserves background sgr" { t.eraseLine(.complete, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("", str); for (0..5) |x| { @@ -5446,7 +5446,7 @@ test "Terminal: eraseLine complete protected attributes respected with iso" { t.eraseLine(.complete, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC", str); } @@ -5465,7 +5465,7 @@ test "Terminal: eraseLine complete protected attributes ignored with dec most re t.eraseLine(.complete, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("", str); } @@ -5482,7 +5482,7 @@ test "Terminal: eraseLine complete protected attributes ignored with dec set" { t.eraseLine(.complete, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("", str); } @@ -5501,7 +5501,7 @@ test "Terminal: eraseLine complete protected requested" { t.eraseLine(.complete, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -5523,7 +5523,7 @@ test "Terminal: eraseDisplay simple erase below" { t.eraseDisplay(alloc, .below, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nD", str); } @@ -5552,7 +5552,7 @@ test "Terminal: eraseDisplay erase below preserves SGR bg" { t.eraseDisplay(alloc, .below, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nD", str); for (1..5) |x| { @@ -5578,7 +5578,7 @@ test "Terminal: eraseDisplay below split multi-cell" { t.eraseDisplay(alloc, .below, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AB橋C\nDE", str); } @@ -5601,7 +5601,7 @@ test "Terminal: eraseDisplay below protected attributes respected with iso" { t.eraseDisplay(alloc, .below, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\nGHI", str); } @@ -5626,7 +5626,7 @@ test "Terminal: eraseDisplay below protected attributes ignored with dec most re t.eraseDisplay(alloc, .below, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nD", str); } @@ -5649,7 +5649,7 @@ test "Terminal: eraseDisplay below protected attributes ignored with dec set" { t.eraseDisplay(alloc, .below, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nD", str); } @@ -5671,7 +5671,7 @@ test "Terminal: eraseDisplay simple erase above" { t.eraseDisplay(alloc, .above, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n F\nGHI", str); } @@ -5694,7 +5694,7 @@ test "Terminal: eraseDisplay below protected attributes respected with force" { t.eraseDisplay(alloc, .below, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\nGHI", str); } @@ -5723,7 +5723,7 @@ test "Terminal: eraseDisplay erase above preserves SGR bg" { t.eraseDisplay(alloc, .above, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n F\nGHI", str); for (0..2) |x| { @@ -5749,7 +5749,7 @@ test "Terminal: eraseDisplay above split multi-cell" { t.eraseDisplay(alloc, .above, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n F\nGH橋I", str); } @@ -5772,7 +5772,7 @@ test "Terminal: eraseDisplay above protected attributes respected with iso" { t.eraseDisplay(alloc, .above, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\nGHI", str); } @@ -5797,7 +5797,7 @@ test "Terminal: eraseDisplay above protected attributes ignored with dec most re t.eraseDisplay(alloc, .above, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n F\nGHI", str); } @@ -5820,7 +5820,7 @@ test "Terminal: eraseDisplay above protected attributes ignored with dec set" { t.eraseDisplay(alloc, .above, false); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n F\nGHI", str); } @@ -5843,7 +5843,7 @@ test "Terminal: eraseDisplay above protected attributes respected with force" { t.eraseDisplay(alloc, .above, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\nGHI", str); } @@ -5984,7 +5984,7 @@ test "Terminal: eraseDisplay protected complete" { t.eraseDisplay(alloc, .complete, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n X", str); } @@ -6006,7 +6006,7 @@ test "Terminal: eraseDisplay protected below" { t.eraseDisplay(alloc, .below, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n123 X", str); } @@ -6028,7 +6028,7 @@ test "Terminal: eraseDisplay protected above" { t.eraseDisplay(alloc, .above, true); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n X 9", str); } @@ -6046,7 +6046,7 @@ test "Terminal: cursorLeft no wrap" { t.cursorLeft(10); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\nB", str); } @@ -6064,7 +6064,7 @@ test "Terminal: cursorLeft unsets pending wrap state" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX", str); } @@ -6082,7 +6082,7 @@ test "Terminal: cursorLeft unsets pending wrap state with longer jump" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABXDE", str); } @@ -6102,7 +6102,7 @@ test "Terminal: cursorLeft reverse wrap" { try testing.expect(t.screen.cursor.pending_wrap); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX\n1", str); } @@ -6124,7 +6124,7 @@ test "Terminal: cursorLeft reverse wrap with no soft wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDE\nX", str); } @@ -6142,7 +6142,7 @@ test "Terminal: cursorLeft reverse wrap before left margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n\nX", str); } @@ -6164,7 +6164,7 @@ test "Terminal: cursorLeft extended reverse wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX\n1", str); } @@ -6186,7 +6186,7 @@ test "Terminal: cursorLeft extended reverse wrap bottom wraparound" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDE\n1\n X", str); } @@ -6209,7 +6209,7 @@ test "Terminal: cursorLeft extended reverse wrap is priority if both set" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDE\n1\n X", str); } @@ -6257,7 +6257,7 @@ test "Terminal: cursorDown basic" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n\n\n\n X", str); } @@ -6274,7 +6274,7 @@ test "Terminal: cursorDown above bottom scroll margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n\n X", str); } @@ -6292,7 +6292,7 @@ test "Terminal: cursorDown below bottom scroll margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A\n\n\n\nX", str); } @@ -6310,7 +6310,7 @@ test "Terminal: cursorDown resets wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDE\n X", str); } @@ -6327,7 +6327,7 @@ test "Terminal: cursorUp basic" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X\n\nA", str); } @@ -6345,7 +6345,7 @@ test "Terminal: cursorUp below top scroll margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n X\nA", str); } @@ -6364,7 +6364,7 @@ test "Terminal: cursorUp above top scroll margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("X\n\nA", str); } @@ -6382,7 +6382,7 @@ test "Terminal: cursorUp resets wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX", str); } @@ -6400,7 +6400,7 @@ test "Terminal: cursorRight resets wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABCDX", str); } @@ -6415,7 +6415,7 @@ test "Terminal: cursorRight to the edge of screen" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -6431,7 +6431,7 @@ test "Terminal: cursorRight left of right margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -6448,7 +6448,7 @@ test "Terminal: cursorRight right of right margin" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" X", str); } @@ -6472,7 +6472,7 @@ test "Terminal: scrollDown simple" { try testing.expectEqual(cursor, t.screen.cursor); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\nABC\nDEF\nGHI", str); } @@ -6497,7 +6497,7 @@ test "Terminal: scrollDown outside of scroll region" { try testing.expectEqual(cursor, t.screen.cursor); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nDEF\n\nGHI", str); } @@ -6523,7 +6523,7 @@ test "Terminal: scrollDown left/right scroll region" { try testing.expectEqual(cursor, t.screen.cursor); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A 23\nDBC156\nGEF489\n HI7", str); } @@ -6549,7 +6549,7 @@ test "Terminal: scrollDown outside of left/right scroll region" { try testing.expectEqual(cursor, t.screen.cursor); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("A 23\nDBC156\nGEF489\n HI7", str); } @@ -6570,7 +6570,7 @@ test "Terminal: scrollDown preserves pending wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("\n A\n B\nX C", str); } @@ -6594,7 +6594,7 @@ test "Terminal: scrollUp simple" { try testing.expectEqual(cursor, t.screen.cursor); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("DEF\nGHI", str); } @@ -6617,7 +6617,7 @@ test "Terminal: scrollUp top/bottom scroll region" { try t.scrollUp(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ABC\nGHI", str); } @@ -6643,7 +6643,7 @@ test "Terminal: scrollUp left/right scroll region" { try testing.expectEqual(cursor, t.screen.cursor); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AEF423\nDHI756\nG 89", str); } @@ -6664,7 +6664,7 @@ test "Terminal: scrollUp preserves pending wrap" { try t.print('X'); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" B\n C\n\nX", str); } @@ -6682,7 +6682,7 @@ test "Terminal: scrollUp full top/bottom region" { try t.scrollUp(4); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("top", str); } @@ -6702,7 +6702,7 @@ test "Terminal: scrollUp full top/bottomleft/right scroll region" { try t.scrollUp(4); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("top\n\n\n\nA E", str); } @@ -6740,7 +6740,7 @@ test "Terminal: printRepeat simple" { try t.printRepeat(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("AA", str); } @@ -6755,7 +6755,7 @@ test "Terminal: printRepeat wrap" { try t.printRepeat(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings(" A\nA", str); } @@ -6769,7 +6769,7 @@ test "Terminal: printRepeat no previous character" { try t.printRepeat(1); { - var str = try t.plainString(testing.allocator); + const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("", str); } diff --git a/src/terminal/kitty/graphics_image.zig b/src/terminal/kitty/graphics_image.zig index d924bbdba..58c7eb676 100644 --- a/src/terminal/kitty/graphics_image.zig +++ b/src/terminal/kitty/graphics_image.zig @@ -454,7 +454,7 @@ pub const Rect = struct { /// Easy base64 encoding function. fn testB64(alloc: Allocator, data: []const u8) ![]const u8 { const B64Encoder = std.base64.standard.Encoder; - var b64 = try alloc.alloc(u8, B64Encoder.calcSize(data.len)); + const b64 = try alloc.alloc(u8, B64Encoder.calcSize(data.len)); errdefer alloc.free(b64); return B64Encoder.encode(b64, data); } @@ -462,7 +462,7 @@ fn testB64(alloc: Allocator, data: []const u8) ![]const u8 { /// Easy base64 decoding function. fn testB64Decode(alloc: Allocator, data: []const u8) ![]const u8 { const B64Decoder = std.base64.standard.Decoder; - var result = try alloc.alloc(u8, try B64Decoder.calcSizeForSlice(data)); + const result = try alloc.alloc(u8, try B64Decoder.calcSizeForSlice(data)); errdefer alloc.free(result); try B64Decoder.decode(result, data); return result; diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index f0b2d707a..2b8f5eee9 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -855,7 +855,7 @@ const Subprocess = struct { // We have to copy the cwd because there is no guarantee that // pointers in full_config remain valid. - var cwd: ?[]u8 = if (opts.full_config.@"working-directory") |cwd| + const cwd: ?[]u8 = if (opts.full_config.@"working-directory") |cwd| try alloc.dupe(u8, cwd) else null; @@ -2096,7 +2096,7 @@ const StreamHandler = struct { build_config.version_string, }, ); - var msg = try termio.Message.writeReq(self.alloc, resp); + const msg = try termio.Message.writeReq(self.alloc, resp); self.messageWriter(msg); } diff --git a/src/termio/message.zig b/src/termio/message.zig index 25dbf0993..e449960ad 100644 --- a/src/termio/message.zig +++ b/src/termio/message.zig @@ -140,7 +140,7 @@ pub fn MessageData(comptime Elem: type, comptime small_size: comptime_int) type } // Otherwise, allocate - var buf = try alloc.dupe(Elem, data); + const buf = try alloc.dupe(Elem, data); errdefer alloc.free(buf); return Self{ .alloc = .{