getScreenBufferSize method

  1. @override
Point<int> getScreenBufferSize()
override

Returns the current size of the terminal screen buffer as a Point, where x is the number of columns and y is the number of rows.

Implementation

@override
Point<int> getScreenBufferSize() {
  final buff = calloc<CONSOLE_SCREEN_BUFFER_INFO>();
  try {
    if (!GetConsoleScreenBufferInfo(outputHandle, buff).value) {
      return const Point(-1, -1);
    }
    return Point(
      buff.ref.srWindow.Right - buff.ref.srWindow.Left + 1,
      buff.ref.srWindow.Bottom - buff.ref.srWindow.Top + 1,
    );
  } finally {
    calloc.free(buff);
  }
}