remove some unused defines

This commit is contained in:
2026-08-12 14:04:49 +03:00
parent 8bf7738e8a
commit e2c0445c1b
15 changed files with 77 additions and 128 deletions
+50 -55
View File
@@ -22,11 +22,9 @@
#include "piliterals_time.h"
// clang-format off
#ifndef WINDOWS
#ifndef PICO_SDK
# include <fcntl.h>
# include <sys/ioctl.h>
# include <termios.h>
#endif // PICO_SDK
#else
# include <wingdi.h>
# include <wincon.h>
@@ -37,12 +35,11 @@
// clang-format on
#if !defined(PICO_SDK)
using namespace PIScreenTypes;
PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
# ifdef WINDOWS
#ifdef WINDOWS
void * hOut;
CONSOLE_SCREEN_BUFFER_INFO sbi, csbi;
CONSOLE_CURSOR_INFO curinfo;
@@ -51,7 +48,7 @@ PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
WORD dattr;
DWORD smode, written;
PIVector<CHAR_INFO> chars;
# endif
#endif
PRIVATE_DEFINITION_END(PIScreen::SystemConsole)
@@ -62,16 +59,16 @@ PIScreen::SystemConsole::SystemConsole() {
PIScreen::SystemConsole::~SystemConsole() {
# ifdef WINDOWS
#ifdef WINDOWS
SetConsoleMode(PRIVATE->hOut, PRIVATE->smode);
SetConsoleTextAttribute(PRIVATE->hOut, PRIVATE->dattr);
# endif
#endif
}
void PIScreen::SystemConsole::begin() {
int w, h;
# ifdef WINDOWS
#ifdef WINDOWS
PRIVATE->ulcoord.X = 0;
PRIVATE->hOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
@@ -81,24 +78,24 @@ void PIScreen::SystemConsole::begin() {
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
# else
# ifdef PIP_EMBEDDED
#else
# ifdef PIP_EMBEDDED
w = 80;
h = 24;
# else
# else
winsize ws;
ioctl(0, TIOCGWINSZ, &ws);
w = ws.ws_col;
h = ws.ws_row;
# endif
# endif
#endif
resize(w, h);
# ifdef WINDOWS
#ifdef WINDOWS
SetConsoleMode(PRIVATE->hOut, ENABLE_WRAP_AT_EOL_OUTPUT);
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
PRIVATE->bc.X = 0;
PRIVATE->bc.Y = 0;
# endif
#endif
clear();
clearScreen();
hideCursor();
@@ -106,11 +103,11 @@ void PIScreen::SystemConsole::begin() {
void PIScreen::SystemConsole::end() {
# ifdef WINDOWS
#ifdef WINDOWS
SetConsoleTextAttribute(PRIVATE->hOut, PRIVATE->dattr);
# else
#else
printf("\e[0m");
# endif
#endif
moveTo(0, height);
showCursor();
}
@@ -118,18 +115,18 @@ void PIScreen::SystemConsole::end() {
void PIScreen::SystemConsole::prepare() {
int w = 80, h = 24;
# ifdef WINDOWS
#ifdef WINDOWS
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
w = PRIVATE->csbi.srWindow.Right - PRIVATE->csbi.srWindow.Left + 1;
h = PRIVATE->csbi.srWindow.Bottom - PRIVATE->csbi.srWindow.Top + 1;
# else
# ifndef PIP_EMBEDDED
#else
# ifndef PIP_EMBEDDED
winsize ws;
ioctl(0, TIOCGWINSZ, &ws);
w = ws.ws_col;
h = ws.ws_row;
# endif
# endif
#endif
resize(w, h);
}
@@ -152,10 +149,10 @@ void PIScreen::SystemConsole::resize(int w, int h) {
cells[i].resize(width);
pcells[i].resize(width, Cell(PIChar()));
}
# ifdef WINDOWS
#ifdef WINDOWS
PRIVATE->sbi.srWindow = PRIVATE->csbi.srWindow;
PRIVATE->chars.resize(width * height);
# endif
#endif
for (int i = 0; i < pcells.size_s(); ++i)
pcells[i].fill(Cell());
clear();
@@ -167,7 +164,7 @@ void PIScreen::SystemConsole::print() {
if (mouse_x >= 0 && mouse_x < width && mouse_y >= 0 && mouse_y < height) {
/// cells[mouse_y][mouse_x].format.flags ^= Inverse;
}
# ifdef WINDOWS
#ifdef WINDOWS
PRIVATE->srect = PRIVATE->sbi.srWindow;
int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1;
for (int j = 0; j < height; ++j) {
@@ -204,7 +201,7 @@ void PIScreen::SystemConsole::print() {
PRIVATE->srect.Right -= width - dx1 - 1;
PRIVATE->srect.Bottom -= height - dy1 - 1;
WriteConsoleOutputW(PRIVATE->hOut, PRIVATE->chars.data(), PRIVATE->bs, PRIVATE->bc, &PRIVATE->srect);
# else
#else
PIString s;
int si = 0, sj = 0;
CellFormat prf(0xFFFF);
@@ -241,14 +238,14 @@ void PIScreen::SystemConsole::print() {
}
printf("\e[0m");
fflush(0);
# endif
#endif
pcells = cells;
}
# ifdef WINDOWS
# define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
# define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
#ifdef WINDOWS
# define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
# define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
WORD attr = PRIVATE->dattr;
if (c.format.flags & Bold)
@@ -287,8 +284,8 @@ ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
}
return attr;
}
# undef FOREGROUND_MASK
# undef BACKGROUND_MASK
# undef FOREGROUND_MASK
# undef BACKGROUND_MASK
void PIScreen::SystemConsole::getWinCurCoord() {
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
@@ -307,7 +304,7 @@ void PIScreen::SystemConsole::newLine() {
PRIVATE->ccoord.Y++;
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
}
# else // WINDOWS
#else // WINDOWS
PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
PIString ts = PIStringAscii("\e[0");
switch (c.format.color_char) {
@@ -336,39 +333,39 @@ PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
if ((c.format.flags & Inverse) == Inverse) ts += PIStringAscii(";7");
return ts + 'm';
}
# endif // WINDOWS
#endif // WINDOWS
void PIScreen::SystemConsole::toUpperLeft() {
# ifdef WINDOWS
#ifdef WINDOWS
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);
# else
#else
printf("\e[H");
# endif
#endif
}
void PIScreen::SystemConsole::moveTo(int x, int y) {
# ifdef WINDOWS
#ifdef WINDOWS
PRIVATE->ccoord.X = x;
PRIVATE->ccoord.Y = PRIVATE->ulcoord.Y + y;
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
# else
#else
printf("\e[%d;%dH", y + 1, x + 1);
# endif
#endif
}
void PIScreen::SystemConsole::clearScreen() {
# ifdef WINDOWS
#ifdef WINDOWS
toUpperLeft();
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
# else
#else
printf("\e[0m\e[H\e[J");
# endif
#endif
}
void PIScreen::SystemConsole::clearScreenLower() {
# ifdef WINDOWS
#ifdef WINDOWS
getWinCurCoord();
FillConsoleOutputAttribute(PRIVATE->hOut,
PRIVATE->dattr,
@@ -380,27 +377,27 @@ void PIScreen::SystemConsole::clearScreenLower() {
width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X,
PRIVATE->ccoord,
&PRIVATE->written);
# else
#else
printf("\e[0m\e[J");
# endif
#endif
}
void PIScreen::SystemConsole::hideCursor() {
# ifdef WINDOWS
#ifdef WINDOWS
PRIVATE->curinfo.bVisible = false;
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
# else
#else
printf("\e[?25l");
# endif
#endif
}
void PIScreen::SystemConsole::showCursor() {
# ifdef WINDOWS
#ifdef WINDOWS
PRIVATE->curinfo.bVisible = true;
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
# else
#else
printf("\e[?25h");
# endif
#endif
}
@@ -605,9 +602,9 @@ void PIScreen::start(bool wait) {
void PIScreen::stop(bool clear) {
PIThread::stopAndWait();
if (clear) console.clearScreen();
# ifndef WINDOWS
#ifndef WINDOWS
fflush(0);
# endif
#endif
}
@@ -660,5 +657,3 @@ PIScreenTile * PIScreen::tileByName(const PIString & name) {
if (t->name() == name) return t;
return 0;
}
#endif // !PICO_SDK