this repo has no description
13
fork

Configure Feed

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

window: add hideCursor and showCursor

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+30 -1
+4
src/Screen.zig
··· 12 12 13 13 buf: []Cell = undefined, 14 14 15 + cursor_row: usize = 0, 16 + cursor_col: usize = 0, 17 + cursor_vis: bool = false, 18 + 15 19 /// sets each cell to the default cell 16 20 pub fn init(self: *Screen) void { 17 21 for (self.buf, 0..) |_, i| {
+15 -1
src/Window.zig
··· 63 63 /// writes a cell to the location in the window 64 64 pub fn writeCell(self: Window, col: usize, row: usize, cell: Cell) void { 65 65 if (self.height == 0 or self.width == 0) return; 66 - if (self.height < row or self.width < col) return; 66 + if (self.height <= row or self.width <= col) return; 67 67 self.screen.writeCell(col + self.x_off, row + self.y_off, cell); 68 68 } 69 69 ··· 81 81 self.screen.writeCell(col, row, cell); 82 82 } 83 83 } 84 + } 85 + 86 + /// hide the cursor 87 + pub fn hideCursor(self: Window) void { 88 + self.screen.cursor_vis = false; 89 + } 90 + 91 + /// show the cursor at the given coordinates, 0 indexed 92 + pub fn showCursor(self: Window, col: usize, row: usize) void { 93 + if (self.height == 0 or self.width == 0) return; 94 + if (self.height <= row or self.width <= col) return; 95 + self.screen.cursor_vis = true; 96 + self.screen.cursor_row = row + self.y_off; 97 + self.screen.cursor_col = col + self.x_off; 84 98 } 85 99 86 100 test "Window size set" {
+11
src/vaxis.zig
··· 370 370 } 371 371 _ = try tty.write(cell.char.grapheme); 372 372 } 373 + if (self.screen.cursor_vis) { 374 + try std.fmt.format( 375 + tty.buffered_writer.writer(), 376 + ctlseqs.cup, 377 + .{ 378 + self.screen.cursor_row + 1, 379 + self.screen.cursor_col + 1, 380 + }, 381 + ); 382 + _ = try tty.write(ctlseqs.show_cursor); 383 + } 373 384 } 374 385 }; 375 386 }