Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalCharacterDecoder.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | // Own | 22 | // Own | ||
23 | #include "TerminalCharacterDecoder.h" | 23 | #include "TerminalCharacterDecoder.h" | ||
24 | 24 | | |||
25 | // Qt | 25 | // Qt | ||
26 | #include <QTextStream> | 26 | #include <QTextStream> | ||
27 | 27 | | |||
28 | // Konsole | 28 | // Konsole | ||
29 | #include "konsole_wcwidth.h" | | |||
30 | #include "ExtendedCharTable.h" | 29 | #include "ExtendedCharTable.h" | ||
31 | #include "ColorScheme.h" | 30 | #include "ColorScheme.h" | ||
32 | 31 | | |||
33 | using namespace Konsole; | 32 | using namespace Konsole; | ||
34 | PlainTextDecoder::PlainTextDecoder() | 33 | PlainTextDecoder::PlainTextDecoder() | ||
35 | : _output(nullptr) | 34 | : _output(nullptr) | ||
36 | , _includeLeadingWhitespace(true) | 35 | , _includeLeadingWhitespace(true) | ||
37 | , _includeTrailingWhitespace(true) | 36 | , _includeTrailingWhitespace(true) | ||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 146 | } else { | |||
149 | // seen as real characters, even when they are technically marked as | 148 | // seen as real characters, even when they are technically marked as | ||
150 | // non-real. | 149 | // non-real. | ||
151 | // | 150 | // | ||
152 | // This feels tricky, but otherwise leading "whitespaces" may be | 151 | // This feels tricky, but otherwise leading "whitespaces" may be | ||
153 | // lost in some situation. One typical example is copying the result | 152 | // lost in some situation. One typical example is copying the result | ||
154 | // of `dialog --infobox "qwe" 10 10` . | 153 | // of `dialog --infobox "qwe" 10 10` . | ||
155 | if (characters[i].isRealCharacter || i <= realCharacterGuard) { | 154 | if (characters[i].isRealCharacter || i <= realCharacterGuard) { | ||
156 | plainText.append(QString::fromUcs4(&characters[i].character, 1)); | 155 | plainText.append(QString::fromUcs4(&characters[i].character, 1)); | ||
157 | i += qMax(1, konsole_wcwidth(characters[i].character)); | 156 | i += qMax(1, characters[i].width()); | ||
158 | } else { | 157 | } else { | ||
159 | ++i; // should we 'break' directly here? | 158 | ++i; // should we 'break' directly here? | ||
160 | } | 159 | } | ||
161 | } | 160 | } | ||
162 | } | 161 | } | ||
163 | *_output << plainText; | 162 | *_output << plainText; | ||
164 | } | 163 | } | ||
165 | 164 | | |||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |