fix(renderer): direct renderer now enforces newlines to handle resizing correctly
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 2m42s
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 2m42s
This commit is contained in:
+3
-3
@@ -151,7 +151,7 @@ pub fn App(comptime M: type, comptime E: type) type {
|
|||||||
var fl_flags = posix.system.fcntl(posix.STDIN_FILENO, posix.F.GETFL, 0);
|
var fl_flags = posix.system.fcntl(posix.STDIN_FILENO, posix.F.GETFL, 0);
|
||||||
// Step 2: Remove O_NONBLOCK
|
// Step 2: Remove O_NONBLOCK
|
||||||
fl_flags ^= 1 << @bitOffsetOf(posix.system.O, "NONBLOCK");
|
fl_flags ^= 1 << @bitOffsetOf(posix.system.O, "NONBLOCK");
|
||||||
std.log.debug("end fl_flags: {any}", .{fl_flags});
|
// std.log.debug("end fl_flags: {any}", .{fl_flags});
|
||||||
// Step 3: Set new flags
|
// Step 3: Set new flags
|
||||||
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
|
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
|
||||||
}
|
}
|
||||||
@@ -190,9 +190,9 @@ pub fn App(comptime M: type, comptime E: type) type {
|
|||||||
{
|
{
|
||||||
// TODO is there a better way to do this through the `std.Io` interface?
|
// TODO is there a better way to do this through the `std.Io` interface?
|
||||||
var fl_flags = posix.system.fcntl(posix.STDIN_FILENO, posix.F.GETFL, 0);
|
var fl_flags = posix.system.fcntl(posix.STDIN_FILENO, posix.F.GETFL, 0);
|
||||||
std.log.debug("start fl_flags: {any}", .{fl_flags});
|
// std.log.debug("start fl_flags: {any}", .{fl_flags});
|
||||||
fl_flags |= 1 << @bitOffsetOf(posix.system.O, "NONBLOCK");
|
fl_flags |= 1 << @bitOffsetOf(posix.system.O, "NONBLOCK");
|
||||||
std.log.debug("setting of fl_flags: {any}", .{fl_flags});
|
// std.log.debug("setting of fl_flags: {any}", .{fl_flags});
|
||||||
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
|
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-10
@@ -159,16 +159,6 @@ pub const Direct = struct {
|
|||||||
try terminal.clearScreen();
|
try terminal.clearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn writeCtrlDWithNewline(this: *@This(), writer: *std.Io.Writer) !void {
|
|
||||||
_ = this;
|
|
||||||
_ = try terminal.write(writer, "^D\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn writeNewline(this: *@This(), writer: *std.Io.Writer) !void {
|
|
||||||
_ = this;
|
|
||||||
_ = try terminal.write(writer, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Render provided cells at size (anchor and dimension) into the *screen*.
|
/// Render provided cells at size (anchor and dimension) into the *screen*.
|
||||||
pub fn render(this: *@This(), comptime Container: type, container: *Container, comptime Model: type, model: *const Model) !void {
|
pub fn render(this: *@This(), comptime Container: type, container: *Container, comptime Model: type, model: *const Model) !void {
|
||||||
const size: Point = container.size;
|
const size: Point = container.size;
|
||||||
@@ -218,6 +208,7 @@ pub const Direct = struct {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if there is nothing more to draw we can simply end this row rendering and go to the next row
|
||||||
if (last_cell) {
|
if (last_cell) {
|
||||||
//std.log.debug("Found the last cell in row: {d} at column: {d}", .{row, col});
|
//std.log.debug("Found the last cell in row: {d} at column: {d}", .{row, col});
|
||||||
_ = try writer.write("\n");
|
_ = try writer.write("\n");
|
||||||
@@ -227,6 +218,8 @@ pub const Direct = struct {
|
|||||||
try cvs.value(writer);
|
try cvs.value(writer);
|
||||||
if (cvs.style.cursor) return; // that's where the cursor should be left!
|
if (cvs.style.cursor) return; // that's where the cursor should be left!
|
||||||
}
|
}
|
||||||
|
// write newline at the end of the row
|
||||||
|
_ = try writer.write("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user