MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / Handler

Method Handler

app/src/Console/Handler.cpp:66–121  ·  view source on GitHub ↗

* @brief Constructs the console handler singleton. */

Source from the content-addressed store, hash-verified

64 * @brief Constructs the console handler singleton.
65 */
66Console::Handler::Handler()
67 : m_dataMode(DataMode::DataUTF8)
68 , m_lineEnding(LineEnding::NoLineEnding)
69 , m_displayMode(DisplayMode::DisplayPlainText)
70 , m_encoding(SerialStudio::EncUtf8)
71 , m_historyItem(0)
72 , m_checksumMethod(0)
73 , m_echo(true)
74 , m_showTimestamp(false)
75 , m_ansiColorsEnabled(false)
76 , m_vt100Emulation(true)
77 , m_ansiColors(true)
78 , m_isStartingLine(true)
79 , m_lastCharWasCR(false)
80 , m_currentDeviceId(-1)
81 , m_fontFamilyIndex(0)
82 , m_textBuffer(10 * 1024)
83{
84 clear();
85 const auto defaultFont = Misc::CommonFonts::instance().monoFont();
86 m_fontFamily = m_settings.value("Console/FontFamily", defaultFont.family()).toString();
87 m_fontSize = m_settings.value("Console/FontSize", defaultFont.pointSize()).toInt();
88 m_echo = m_settings.value("Console/Echo", true).toBool();
89 m_showTimestamp = m_settings.value("Console/ShowTimestamp", false).toBool();
90 m_vt100Emulation = m_settings.value("Console/VT100Emulation", true).toBool();
91 m_ansiColors = m_settings.value("Console/AnsiColors", true).toBool();
92 m_checksumMethod = m_settings.value("Console/ChecksumMethod", 0).toInt();
93 m_dataMode = static_cast<DataMode>(m_settings.value("Console/DataMode", 0).toInt());
94 m_lineEnding = static_cast<LineEnding>(m_settings.value("Console/LineEnding", 0).toInt());
95 m_displayMode = static_cast<DisplayMode>(m_settings.value("Console/DisplayMode", 0).toInt());
96
97 const int encInt = m_settings.value("Console/Encoding", 0).toInt();
98 if (encInt >= 0 && encInt <= SerialStudio::EncEucKr)
99 m_encoding = static_cast<SerialStudio::TextEncoding>(encInt);
100
101 if (m_fontSize < 6)
102 m_fontSize = 6;
103 else if (m_fontSize > 72)
104 m_fontSize = 72;
105
106 const int checksumCount = IO::availableChecksums().count();
107 if (m_checksumMethod < 0 || m_checksumMethod >= checksumCount)
108 m_checksumMethod = 0;
109
110 m_ansiColorsEnabled = m_vt100Emulation && m_ansiColors;
111 m_fontFamilyIndex = availableFonts().indexOf(m_fontFamily);
112
113 connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::uiTimeout, this, [this]() {
114 if (!m_pendingDisplay.isEmpty()) {
115 Q_EMIT displayString(m_pendingDisplay);
116 m_pendingDisplay.clear();
117 }
118 });
119
120 updateFont();
121}
122
123/**

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
valueMethod · 0.45
countMethod · 0.45
indexOfMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected