Files
lunch-games/source/lunch/term.d
2025-11-27 03:11:44 +01:00

39 lines
643 B
D

module lunch.term;
version (Windows)
{
import core.sys.windows.windows;
}
struct TermSize
{
int width, height;
}
TermSize termSize()
{
version (Windows)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
int columns, rows;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
return TermSize(
csbi.srWindow.Right - csbi.srWindow.Left + 1,
csbi.srWindow.Bottom - csbi.srWindow.Top + 1,
);
}
return TermSize(80, 25); // Default for windows cmd
}
int termWidth()
{
return termSize().width;
}
int termHeight()
{
return termSize().height;
}