-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTerminal.cpp
120 lines (98 loc) · 5.08 KB
/
Terminal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// ===========================================================================
/// <summary>
/// MacOs's terminal screen manipulations at runtime.
/// Terminal.cpp
/// ModernCplusPlus
/// created by Mehrdad Soleimanimajd on 12.01.2023
/// </summary>
/// <returns></returns>
/// <created>ʆϒʅ, 12.01.2023</created>
/// <changed>ʆϒʅ, 03.07.2023</changed>
// ===========================================================================
#include "pch.h"
#include "Terminal.h"
#ifdef __APPLE__
//// console screen properties (DLL internal state variables)
//HANDLE consoleOutput = GetStdHandle ( STD_OUTPUT_HANDLE ); // for simplification (constant calls to the function)
//CONSOLE_SCREEN_BUFFER_INFOEX screenBinfoEX;
//CONSOLE_SCREEN_BUFFER_INFOEX screenBinfoEXstorage;
//CONSOLE_FONT_INFOEX fontInfoEX;
//CONSOLE_CURSOR_INFO cursorInfo;
//HWND consoleWindow = GetConsoleWindow (); // for simplification (constant calls to the function)
void ConsoleFont (const char32_t* fontName)
{
// fontInfoEX.cbSize = sizeof ( fontInfoEX ); // getting the right size (important for many structures in the windows API)
// GetCurrentConsoleFontEx ( consoleOutput, false, &fontInfoEX );
// lstrcpyW ( fontInfoEX.FaceName, fontName ); // copies a specific number of characters from a source string to a buffer (the properties of wished font to the suitable field)
// SetCurrentConsoleFontEx ( consoleOutput, false, &fontInfoEX );
}
void ConsoleFontSize (const coordinateType fontSize)
{
// fontInfoEX.cbSize = sizeof ( fontInfoEX ); // getting the right size (important for many structures in the windows API)
// GetCurrentConsoleFontEx ( consoleOutput, false, &fontInfoEX );
// fontInfoEX.dwFontSize.X = fontSize.X; // for not true type fonts
// fontInfoEX.dwFontSize.Y = fontSize.Y; // Y is enough for the size of true type fonts
// SetCurrentConsoleFontEx ( consoleOutput, false, &fontInfoEX );
}
void ConsoleFontColour (const int16_t fontColour)
{
// SetConsoleTextAttribute ( consoleOutput, fontColour );
}
void ConsoleScreenPosition (const coordinateType screenPosition)
{
// // draw the window from the coordinate argument
// // and ignore the new width, height in pixels (cx, cy) i.e. (0, 0) by setting the SWP_NOSIZE flag
// // for other flags check MSDN
// SetWindowPos ( consoleWindow, HWND_TOP, screenPosition.X, screenPosition.Y, 0, 0, SWP_NOSIZE );
}
void ConsoleScreenSize (const coordinateType ColRowCount)
{
// // setting the new console screen size in pixels:
// // converting needed columns and rows numbers to needed screen size in pixel (the numbers are reckoned by trying different numbers)
// RECT consoleScreen;
// GetWindowRect ( consoleWindow, &consoleScreen );
// MoveWindow ( consoleWindow, consoleScreen.top, consoleScreen.left, static_cast<int> ( ColRowCount.X * 9.3 ), ColRowCount.Y * 22, true );
// screenBinfoEX.cbSize = sizeof ( screenBinfoEX ); // getting the right size (important for many structures in the windows API)
// GetConsoleScreenBufferInfoEx ( consoleOutput, &screenBinfoEX );
// screenBinfoEX.srWindow.Left = 0; // width 0 to
// screenBinfoEX.srWindow.Right = ColRowCount.X; // the number of columns (doesn't work: need legacy console tick)
// screenBinfoEX.srWindow.Top = 0; // height 0 to
// screenBinfoEX.srWindow.Bottom = ColRowCount.Y; // the number of rows
// SetConsoleScreenBufferInfoEx ( consoleOutput, &screenBinfoEX );
// SetConsoleWindowInfo ( consoleOutput, false, &screenBinfoEX.srWindow );
}
//void ConsoleScreenColour ( const COLORREF BGcolour )
//{
// screenBinfoEX.cbSize = sizeof ( screenBinfoEX ); // getting the right size (important for many structures in the windows API)
// GetConsoleScreenBufferInfoEx ( consoleOutput, &screenBinfoEX );
// //screenBinfoEX.srWindow.Left = 0; // width 0 to
// //screenBinfoEX.srWindow.Right = ColRowCount.X; // the number of columns (doesn't work: need legacy console tick)
// //screenBinfoEX.srWindow.Top = 0; // height 0 to
// //screenBinfoEX.srWindow.Bottom = ColRowCount.Y; // the number of rows
// screenBinfoEX.ColorTable [0] = BGcolour; // background colour
// SetConsoleScreenBufferInfoEx ( consoleOutput, &screenBinfoEX );
// SetConsoleWindowInfo ( consoleOutput, false, &screenBinfoEX.srWindow );
//}
void ConsoleCursorState (const bool CursorVisible)
{
// GetConsoleCursorInfo ( consoleOutput, &cursorInfo );
// cursorInfo.bVisible = CursorVisible;
// //cursorInfo.dwSize = _int;
// SetConsoleCursorInfo ( consoleOutput, &cursorInfo );
}
void ColourCouter (const std::string strCharacter, const std::string Colour, const bool Pick)
{
// GetConsoleScreenBufferInfoEx ( consoleOutput, &screenBinfoEX );
// screenBinfoEXstorage = screenBinfoEX;
// SetConsoleTextAttribute ( consoleOutput, Colour );
if (Pick)
{
std::cout << "\033[0m" << strCharacter;
} else
{
std::cout << Colour << strCharacter;
}
// SetConsoleTextAttribute ( consoleOutput, screenBinfoEXstorage.wAttributes );
// GetConsoleScreenBufferInfoEx ( consoleOutput, &screenBinfoEX );
}
#endif