mod(pane) example layout pane has top and bottom empty row

Fix corresponding RawText line control (i.e. last line and changes to
the window size in regards to the current line).
This commit is contained in:
2024-11-09 01:52:37 +01:00
parent 9d711ea047
commit ba01bf00bb
2 changed files with 6 additions and 4 deletions

View File

@@ -54,10 +54,9 @@ pub fn Layout(comptime Event: type) type {
}
pub fn content(this: *@This()) !*std.ArrayList(u8) {
const widget_content = try this.widget.content();
this.c.clearRetainingCapacity();
try this.c.appendSlice("\n");
try this.c.appendSlice(widget_content);
try this.c.appendSlice(try this.widget.content());
try this.c.appendSlice("\n");
return &this.c;
}

View File

@@ -39,6 +39,9 @@ pub fn Widget(comptime Event: type) type {
// store the received size
.resize => |size| {
this.size = size;
if (this.line > this.line_index.items.len - 1 - size.rows) {
this.line = this.line_index.items.len - 1 - size.rows;
}
},
.key => |key| {
if (key.matches(.{ .cp = 'g' })) {
@@ -47,11 +50,11 @@ pub fn Widget(comptime Event: type) type {
}
if (key.matches(.{ .cp = 'G' })) {
// bottom
this.line = this.line_index.items.len - 1;
this.line = this.line_index.items.len - 1 - this.size.rows;
}
if (key.matches(.{ .cp = 'j' })) {
// down
if (this.line < this.line_index.items.len - 1) {
if (this.line < this.line_index.items.len - 1 - this.size.rows) {
this.line +|= 1;
}
}