Skip to content

Commit

Permalink
reverted to vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
unxed committed Dec 23, 2024
1 parent cbb06da commit 3ecf059
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 87 deletions.
29 changes: 0 additions & 29 deletions WinPort/src/Backend/TTY/TTYInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
#include "WinPort.h"
#include <utils.h>

#include <string>
#include <iostream>
#include <fstream>
#include <unistd.h> // For getuid() and getpwuid()
#include <pwd.h> // For struct passwd

TTYInput::TTYInput(ITTYInputSpecialSequenceHandler *handler) :
_parser(handler), _handler(handler)
Expand Down Expand Up @@ -94,30 +89,6 @@ void TTYInput::OnBufUpdated(bool idle)

void TTYInput::OnInput(const char *data, size_t len)
{

// Get home directory
struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir;

// Construct log file path
std::string logFilePath = std::string(homedir) + "/far2l_ttyin.log";

// Open log file in append mode
std::ofstream logFile(logFilePath, std::ios::app);

if (logFile.is_open()) {
for (size_t i = 0; i < len; ++i) {
if (data[i] == '\033') { // Check for escape character (27 in decimal or 033 in octal)
logFile << std::endl; // Add newline before ESC
}
logFile << data[i];
}
logFile << std::flush; // Ensure data is written to the file immediately
logFile.close();
} else {
std::cerr << "Error opening log file: " << logFilePath << std::endl;
}

if (len) try {
_buf.reserve(_buf.size() + len);

Expand Down
12 changes: 0 additions & 12 deletions WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,6 @@ size_t TTYInputSequenceParser::ParseIntoPending(const char *s, size_t l)

size_t TTYInputSequenceParser::Parse(const char *s, size_t l, bool idle_expired)
{
// Workaround for some weird win32-input-mode setups
if (
(l > 8 && s[1] == '[' && s[2] == '2' && s[3] == '7' && s[4] == ';' && s[10] == '0')
&& _win32_accumulate) {

AddPendingKeyEvent(TTYInputKey{VK_ESCAPE, 0});

_win32_accumulate = false;
_win_double_buffer.clear();
return 16; // на самом деле искать ближайший _
}

//work-around for double encoded events in win32-input mode
//we encountered sequence \x1B[0;0;27;1;0;1_ it is \x1B encoded in win32 input
//following codes are part of some double encoded input sequence and must be parsed in separate buffer
Expand Down
46 changes: 0 additions & 46 deletions WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,52 +446,6 @@ size_t TTYInputSequenceParser::TryParseAsWinTermEscapeSequence(const char *s, si
}
}

// Workarounds for some weird win32-input-mode setups
// Todo: add scan codes
// Ctrl+letters
if (
(!args[0] && args[2] >= 1 && args[2] <= 26 && !(args[4] & LEFT_CTRL_PRESSED)) ||
( args[0] && args[2] >= 1 && args[2] <= 26 && (args[4] & LEFT_CTRL_PRESSED))
) {
args[0] = args[2] + 64;
args[2] = (args[4] & SHIFT_PRESSED) ? args[0] : tolower(args[0]);
args[4] |= LEFT_CTRL_PRESSED;
fprintf(stderr, "W32I: Ctrl+letter hack\n");
}
// Ctrl+BS
if (args[0] == 0 && args[2] == 0x7F && args[3]) {
args[0] = VK_BACK;
args[2] = args[0];
args[4] |= LEFT_CTRL_PRESSED;
fprintf(stderr, "W32I: Ctrl+BS hack\n");
}
// Esc
if (args[0] == 0 && args[2] == 0x1B && args[3]) {
args[0] = VK_ESCAPE;
fprintf(stderr, "W32I: Esc hack\n");
}
// Enter
if (args[0] == 0 && args[2] == 0x0D && args[3]) {
args[0] = VK_RETURN;
fprintf(stderr, "W32I: Enter hack\n");
}
// Enter#2: Ctrl+M encoded as win32-input-mode seq, 77 0 109 1 8 1
if (args[0] == 'M' && !args[1] && args[2] == 'm' && args[3] && (args[4] & LEFT_CTRL_PRESSED)) {
args[0] = VK_RETURN;
args[2] = 0x0D;
args[4] = 0;
fprintf(stderr, "W32I: Enter hack #2\n");
}

fprintf(stderr, "W32I: parsed %i %i %i %i %i %i\n", args[0], args[1], args[2], args[3], args[4], args[5]);

/*
// problematic sequences:
Enter: \x1b[0;0;13;1;0;1_ \x1b[13;28;13;0;0;1_
Ctrl-C: \x1b[17;29;0;1;8;1_ \x1b[0;0;3;1;0;1_ \x1b[67;46;3;0;8;1_ \x1b[17;29;0;0;0;1_
Esc: \x1b[0;0;27;1;0;1_ \x1b[27;1;27;0;0;1_
*/

INPUT_RECORD ir = {};
ir.EventType = KEY_EVENT;
ir.Event.KeyEvent.wVirtualKeyCode = args[0] ? args[0] : VK_UNASSIGNED;
Expand Down

0 comments on commit 3ecf059

Please sign in to comment.