summaryrefslogtreecommitdiff
path: root/src/Buffer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Buffer.zig')
-rw-r--r--src/Buffer.zig11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Buffer.zig b/src/Buffer.zig
index 5bf319c..d0546c0 100644
--- a/src/Buffer.zig
+++ b/src/Buffer.zig
@@ -394,7 +394,8 @@ pub fn nextLine(self: *Buffer) void {
394 } 394 }
395} 395}
396 396
397pub fn pageDown(self: *Buffer, screenrows: usize) void { 397pub fn pageDown(self: *Buffer, editor: Editor) void {
398 const screenrows = editor.screenrows;
398 self.cy = std.math.clamp( 399 self.cy = std.math.clamp(
399 self.rowoff + screenrows - 1 - self.config.page_overlap, 400 self.rowoff + screenrows - 1 - self.config.page_overlap,
400 0, 401 0,
@@ -406,7 +407,8 @@ pub fn pageDown(self: *Buffer, screenrows: usize) void {
406 } 407 }
407} 408}
408 409
409pub fn pageUp(self: *Buffer, screenrows: usize) void { 410pub fn pageUp(self: *Buffer, editor: Editor) void {
411 const screenrows = editor.screenrows;
410 self.cy = std.math.min(self.rows.items.len, self.rowoff + self.config.page_overlap); 412 self.cy = std.math.min(self.rows.items.len, self.rowoff + self.config.page_overlap);
411 var i: usize = 0; 413 var i: usize = 0;
412 while (i < screenrows) : (i += 1) { 414 while (i < screenrows) : (i += 1) {
@@ -423,8 +425,11 @@ pub fn previousLine(self: *Buffer) void {
423 self.cx = self.rows.items[self.cy].rxToCx(self.config, self.rx); 425 self.cx = self.rows.items[self.cy].rxToCx(self.config, self.rx);
424} 426}
425 427
426pub fn recenterTopBottom(self: *Buffer, screenrows: usize) void { 428pub fn recenterTopBottom(self: *Buffer, editor: *Editor) !void {
427 // TODO: Currently only recenters 429 // TODO: Currently only recenters
430 try editor.refreshWindowSize();
431
432 const screenrows = editor.screenrows;
428 if (self.cy >= screenrows / 2) { 433 if (self.cy >= screenrows / 2) {
429 self.rowoff = self.cy - screenrows / 2; 434 self.rowoff = self.cy - screenrows / 2;
430 } else { 435 } else {