mod: replace Layout.content with Layout.render
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 30s

The App.Renderer is used for the new `Layout.render` method. Each layout
renders itself now with corresponding renderers which might only update
parts of the screen, etc.
This commit is contained in:
2024-11-10 14:34:28 +01:00
parent b32556720e
commit b314ff7813
12 changed files with 112 additions and 92 deletions

View File

@@ -46,7 +46,6 @@ pub fn Widget(comptime Event: type) type {
// store the received size
.resize => |size| {
this.size = size;
log.debug("Using size: {{ .cols = {d}, .rows = {d} }}", .{ size.cols, size.rows });
if (this.line > this.line_index.items.len -| 1 -| size.rows) {
this.line = this.line_index.items.len -| 1 -| size.rows;
}
@@ -82,11 +81,12 @@ pub fn Widget(comptime Event: type) type {
} else {
// more rows than we can display
const i = this.line_index.items[this.line];
log.debug("i := {d} this.line := {d}", .{ i, this.line });
const e = this.size.rows + this.line;
const e = this.size.rows + this.line + 1;
if (e >= this.line_index.items.len) {
return this.contents.items[i..];
}
// last line should not end with the last character (likely a newline character)
// FIX: what about files which do not end with a newline?
const x = this.line_index.items[e] - 1;
return this.contents.items[i..x];
}