mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
added pinvoke functions to query terminal size
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "pal.h"
|
||||
|
||||
PAL_BEGIN_EXTERNC
|
||||
|
||||
INT32 GetTerminalWidth();
|
||||
INT32 GetTerminalHeight();
|
||||
|
||||
PAL_END_EXTERNC
|
||||
|
||||
Reference in New Issue
Block a user