mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 00:05:34 +00:00
Fix console behavior on win32
This commit is contained in:
parent
7fce274915
commit
747e948339
@ -119,6 +119,7 @@ void SetupConsole() {
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
static std::vector<std::string> ConsoleHistory {};
|
||||
static size_t ConsoleHistoryReadIndex { 0 };
|
||||
|
||||
@ -162,12 +163,14 @@ static void ProcessCompositeInput() {
|
||||
ConsoleHistoryReadIndex = ConsoleHistory.size();
|
||||
}
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
[[noreturn]] void ReadCin() {
|
||||
DebugPrintTID();
|
||||
while (true) {
|
||||
int In = _getch();
|
||||
//info(std::to_string(In));
|
||||
#ifndef WIN32
|
||||
if (CompositeInputExpected) {
|
||||
CompositeInput += In;
|
||||
if (CompositeInput.size() == 2) {
|
||||
@ -176,10 +179,13 @@ static void ProcessCompositeInput() {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif // WIN32
|
||||
if (In == 13 || In == '\n') {
|
||||
if (!CInputBuff.empty()) {
|
||||
HandleInput(CInputBuff);
|
||||
#ifndef WIN32
|
||||
ConsoleHistoryAdd(CInputBuff);
|
||||
#endif // WIN32
|
||||
CInputBuff.clear();
|
||||
}
|
||||
} else if (In == 8 || In == 127) {
|
||||
@ -189,10 +195,12 @@ static void ProcessCompositeInput() {
|
||||
CInputBuff = "exit";
|
||||
HandleInput(CInputBuff);
|
||||
CInputBuff.clear();
|
||||
#ifndef WIN32
|
||||
} else if (In == 27) {
|
||||
// escape char, assume stuff follows
|
||||
CompositeInputExpected = true;
|
||||
CompositeInput.clear();
|
||||
#endif // WIN32
|
||||
} else if (!isprint(In)) {
|
||||
// ignore
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user