added pinvoke functions to query terminal size

This commit is contained in:
Peter Honeder
2015-07-07 18:04:23 -07:00
parent 078b07c7e0
commit a756ecaadf
4 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(../ext-src/gtest/fused-src impl)
link_directories(${monad_native_BINARY_DIR})
set(LIB_SOURCE_FILES impl/getcurrentprocessorid.cpp impl/getusername.cpp)
set(LIB_SOURCE_FILES impl/getcurrentprocessorid.cpp impl/getusername.cpp impl/terminal.cpp)
set(TEST_SOURCE_FILES tests/test-getcurrentprocessid.cpp)
set(SOURCE_FILES main.cpp ../ext-src/gtest/fused-src/gtest/gtest-all.cc)
+1
View File
@@ -54,6 +54,7 @@
typedef char BOOL;
typedef unsigned short WCHAR_T;
typedef unsigned int UINT32;
typedef int INT32;
typedef unsigned long HRESULT;
typedef const wchar_t *PCWSTR;
typedef wchar_t *PWSTR;
+21
View File
@@ -0,0 +1,21 @@
#include "terminal.h"
#include <sys/ioctl.h>
INT32 GetTerminalWidth()
{
struct winsize ws;
if (-1 == ioctl(0,TIOCGWINSZ,&ws))
return -1;
return ws.ws_col;
}
INT32 GetTerminalHeight()
{
struct winsize ws;
if (-1 == ioctl(0,TIOCGWINSZ,&ws))
return -1;
return ws.ws_row;
}
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include "pal.h"
PAL_BEGIN_EXTERNC
INT32 GetTerminalWidth();
INT32 GetTerminalHeight();
PAL_END_EXTERNC