39
source/lunch/term.d
Normal file
39
source/lunch/term.d
Normal file
@ -0,0 +1,39 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user