this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

widgets(terminal): send a redraw event

+16 -1
+6
examples/vt.zig
··· 56 56 defer vt.deinit(); 57 57 try vt.spawn(); 58 58 59 + var redraw: bool = false; 59 60 while (true) { 60 61 std.time.sleep(8 * std.time.ns_per_ms); 61 62 // try vt events first 62 63 while (vt.tryEvent()) |event| { 64 + redraw = true; 63 65 switch (event) { 64 66 .bell => {}, 65 67 .title_change => {}, 66 68 .exited => return, 69 + .redraw => {}, 67 70 } 68 71 } 69 72 while (loop.tryEvent()) |event| { 73 + redraw = true; 70 74 switch (event) { 71 75 .key_press => |key| { 72 76 if (key.matches('c', .{ .ctrl = true })) return; ··· 77 81 }, 78 82 } 79 83 } 84 + if (!redraw) continue; 85 + redraw = false; 80 86 81 87 const win = vx.window(); 82 88 win.hideCursor();
+10 -1
src/widgets/terminal/Terminal.zig
··· 18 18 19 19 pub const Event = union(enum) { 20 20 exited, 21 + redraw, 21 22 bell, 22 23 title_change, 23 24 }; ··· 66 67 // only applies to primary screen 67 68 scroll_offset: usize = 0, 68 69 back_mutex: std.Thread.Mutex = .{}, 70 + // dirty is protected by back_mutex. Only access this field when you hold that mutex 71 + dirty: bool = false, 69 72 70 73 unicode: *const vaxis.Unicode, 71 74 should_quit: bool = false, ··· 192 195 defer self.back_mutex.unlock(); 193 196 // We keep this as a separate condition so we don't deadlock by obtaining the lock but not 194 197 // having sync 195 - if (!self.mode.sync) 198 + if (!self.mode.sync) { 196 199 try self.back_screen.copyTo(&self.front_screen); 200 + self.dirty = false; 201 + } 197 202 } 198 203 199 204 var row: usize = 0; ··· 260 265 const event = try parser.parseReader(&reader); 261 266 self.back_mutex.lock(); 262 267 defer self.back_mutex.unlock(); 268 + 269 + defer if (!self.dirty and self.event_queue.tryPush(.redraw)) { 270 + self.dirty = true; 271 + }; 263 272 264 273 switch (event) { 265 274 .print => |str| {