From e8138414c09898ad7964ec2cad68a626ed635a2e Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sun, 1 Mar 2026 20:42:47 +0000 Subject: [PATCH] Implement basic scrolling in emu.js --- emu.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/emu.js b/emu.js index a8752d8..823cf3c 100644 --- a/emu.js +++ b/emu.js @@ -142,6 +142,8 @@ class Emulator { this.cursor_move(1, 0); } else if (e.key == 'Enter') { this.cursor.y = this.range.end.y + 1; + if (this.cursor.y >= ROWS) + this.scroll(); this.cursor.x = 0; this.submit_line(); Object.assign(this.range.start, this.cursor); @@ -239,6 +241,8 @@ class Emulator { this.grid[cell.y][cell.x] = this.grid[prev.y][prev.x]; cell = prev; } + if (this.next_cell(this.range.end) == null) + this.scroll(); this.range.end = this.next_cell(this.range.end); } @@ -283,6 +287,14 @@ class Emulator { return c; } } + + scroll() { + this.grid.shift() + this.grid.push(new Array(COLS).fill(' ')); + this.cursor.y -= 1; + this.range.start.y -= 1; + this.range.end.y -= 1; + } } window.addEventListener('DOMContentLoaded', () => {