mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 21:47:40 -05:00
fix: Many issues and code style of the TTY console
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include <thread>
|
||||
#include <jthread.hpp>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
#include <wolv/container/interval_tree.hpp>
|
||||
|
||||
namespace hex::plugin::windows {
|
||||
|
||||
@@ -17,68 +19,64 @@ namespace hex::plugin::windows {
|
||||
void drawContent() override;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::wstring, std::wstring>> m_comPorts;
|
||||
void drawConsole();
|
||||
|
||||
std::vector<std::pair<std::wstring, std::wstring>> getAvailablePorts() const;
|
||||
bool connect();
|
||||
bool disconnect();
|
||||
|
||||
void transmitData(std::vector<char> &data);
|
||||
|
||||
void* m_portHandle = reinterpret_cast<void*>(-1);
|
||||
std::jthread m_receiveThread;
|
||||
|
||||
int m_selectedPort = 0;
|
||||
int m_selectedBaudRate = 11; // 115200
|
||||
int m_selectedNumBits = 3; // 8
|
||||
int m_selectedStopBits = 0; // 1
|
||||
int m_selectedParityBits = 0; // None
|
||||
bool m_hasCTSFlowControl = false; // No
|
||||
|
||||
bool m_shouldAutoScroll = true;
|
||||
|
||||
std::mutex m_receiveBufferMutex;
|
||||
std::vector<char> m_receiveDataBuffer, m_transmitDataBuffer;
|
||||
std::vector<u32> m_wrapPositions;
|
||||
bool m_transmitting = false;
|
||||
private:
|
||||
struct Port {
|
||||
std::string name;
|
||||
std::wstring path;
|
||||
};
|
||||
|
||||
constexpr static std::array BaudRates = {
|
||||
"110",
|
||||
"300",
|
||||
"600",
|
||||
"1200",
|
||||
"2400",
|
||||
"4800",
|
||||
"9600",
|
||||
"14400",
|
||||
"19200",
|
||||
"38400",
|
||||
"57600",
|
||||
"115200",
|
||||
"128000",
|
||||
"256000"
|
||||
110, 150, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
|
||||
};
|
||||
|
||||
constexpr static std::array NumBits = {
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8"
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8
|
||||
};
|
||||
|
||||
constexpr static std::array StopBits = {
|
||||
"1",
|
||||
"1.5",
|
||||
"2.0"
|
||||
enum class StopBits : u8 {
|
||||
_1_0 = ONESTOPBIT,
|
||||
_1_5 = ONE5STOPBITS,
|
||||
_2_0 = TWOSTOPBITS
|
||||
};
|
||||
|
||||
constexpr static std::array ParityBits = {
|
||||
"None",
|
||||
"Odd",
|
||||
"Even",
|
||||
"Mark",
|
||||
"Space"
|
||||
enum class ParityBits {
|
||||
None = NOPARITY,
|
||||
Odd = ODDPARITY,
|
||||
Even = EVENPARITY,
|
||||
Mark = MARKPARITY,
|
||||
Space = SPACEPARITY
|
||||
};
|
||||
|
||||
std::vector<Port> getAvailablePorts() const;
|
||||
bool connect();
|
||||
bool disconnect();
|
||||
|
||||
void transmitData(const std::string &data);
|
||||
|
||||
void* m_portHandle = INVALID_HANDLE_VALUE;
|
||||
std::jthread m_receiveThread;
|
||||
|
||||
u32 m_selectedPortIndex = 0;
|
||||
i32 m_selectedBaudRate = 115200;
|
||||
i32 m_selectedNumBits = 8;
|
||||
StopBits m_selectedStopBits = StopBits::_1_0;
|
||||
ParityBits m_selectedParityBits = ParityBits::None;
|
||||
bool m_hasCTSFlowControl = false;
|
||||
|
||||
bool m_shouldAutoScroll = true;
|
||||
i64 m_scrollPosition = 0;
|
||||
|
||||
std::mutex m_receiveBufferMutex;
|
||||
std::vector<std::string> m_receiveLines;
|
||||
std::vector<ImColor> m_receiveLinesColor;
|
||||
std::string m_transmitDataBuffer;
|
||||
bool m_transmitting = false;
|
||||
std::vector<Port> m_comPorts;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user