Line data Source code
1 :
2 : /* Copyright (c) 2017, Stefan.Eilemann@epfl.ch
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #include "term.h"
19 : #include "os.h"
20 :
21 : #ifndef _MSC_VER
22 : #include <stdio.h>
23 : #include <sys/ioctl.h>
24 : #include <unistd.h>
25 : #endif
26 :
27 : #include <iostream>
28 : namespace lunchbox
29 : {
30 : namespace term
31 : {
32 0 : size getSize()
33 : {
34 : #ifdef _MSC_VER
35 : CONSOLE_SCREEN_BUFFER_INFO info;
36 : if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info))
37 : return {info.dwSize.X, info.dwSize.Y};
38 : #else
39 : struct winsize w;
40 0 : if (::ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) >= 0)
41 0 : return {w.ws_col, w.ws_row};
42 : #endif
43 0 : return {120, 80};
44 : }
45 : }
46 75 : }
|