CanvasBuffer constructor

CanvasBuffer({
  1. required int width,
  2. required int height,
  3. bool isFullscreen = false,
})

Creates a CanvasBuffer with the specified width and height.

Initializes the internal buffer with empty spaces and prepares a previous frame buffer for diff-based rendering.

If isFullscreen is true, the terminal is switched into fullscreen mode using TerminalFunctions.enterFullScreen, hiding scrollback and occupying the entire screen.

The isFullscreen parameter allows the buffer to be immediately ready for fullscreen rendering, otherwise it uses the current terminal viewport.

Implementation

CanvasBuffer({
  required this.width,
  required this.height,
  this.isFullscreen = false,
}) : _screenBuffer = List.generate(
       height,
       (_) => List.filled(width, BufferCell(char: ' ')),
     ),
     _previousFrame = List.generate(
       height,
       (_) => List.filled(width, BufferCell(char: '')),
     ) {
  if (isFullscreen) TerminalFunctions.enterFullScreen();
}