mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00

- Put the MIT copyright at the end. - Move the directory /other -> tools - Various improvements.
41 lines
925 B
C++
41 lines
925 B
C++
#include "ftxui/screen/terminal.hpp"
|
|
|
|
#include <stdio.h>
|
|
|
|
#if defined(_WIN32)
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#define NOMINMAX
|
|
#include <Windows.h>
|
|
#else
|
|
#include <sys/ioctl.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <iostream>
|
|
|
|
namespace ftxui {
|
|
|
|
Terminal::Dimensions Terminal::Size() {
|
|
#if defined(__EMSCRIPTEN__)
|
|
return Dimensions{80, 43};
|
|
#elif defined(_WIN32)
|
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
|
int columns, rows;
|
|
|
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
|
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
|
rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
|
return Dimensions{columns, rows};
|
|
#else
|
|
winsize w;
|
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
|
return Dimensions{w.ws_col, w.ws_row};
|
|
#endif
|
|
}
|
|
|
|
} // namespace ftxui
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
// the LICENSE file.
|