Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Context not available. | |||||
3293 | } | 3293 | } | ||
---|---|---|---|---|---|
3294 | } | 3294 | } | ||
3295 | 3295 | | |||
3296 | QStringList unsafeCharacters; | ||||
3297 | for (const QChar &c : text) { | ||||
3298 | if (!c.isPrint() && c != QLatin1Char('\t') && c != QLatin1Char('\n')) { | ||||
3299 | QString description; | ||||
3300 | switch(c.unicode()) { | ||||
3301 | case '\x03': | ||||
3302 | description = i18n("^C Interrupt: May abort the current process"); | ||||
3303 | break; | ||||
3304 | case '\x04': | ||||
3305 | description = i18n("^D End of transmission: May exit the current process"); | ||||
3306 | break; | ||||
3307 | case '\x07': | ||||
3308 | description = i18n("^G Bell: Will try to emit an audible warning"); | ||||
3309 | break; | ||||
3310 | case '\x08': | ||||
3311 | description = i18n("^H Backspace"); | ||||
3312 | break; | ||||
3313 | case '\x13': | ||||
3314 | description = i18n("^S Scroll lock: Locks terminal output"); | ||||
3315 | break; | ||||
3316 | case '\x1a': | ||||
3317 | description = i18n("^Z Suspend: Stops current process"); | ||||
3318 | break; | ||||
3319 | case '\x1b': | ||||
3320 | description = i18n("ESC: Used for special commands to the current process"); | ||||
3321 | break; | ||||
3322 | default: | ||||
3323 | description = i18n("Other unprintable character (\\x%1)").arg(QString::number(c.unicode(), 16)); | ||||
3324 | break; | ||||
3325 | } | ||||
3326 | unsafeCharacters.append(description); | ||||
3327 | } | ||||
3328 | } | ||||
3329 | unsafeCharacters.removeDuplicates(); | ||||
3330 | | ||||
3331 | if (!unsafeCharacters.isEmpty()) { | ||||
3332 | int result = KMessageBox::warningYesNoCancelList(window(), | ||||
3333 | i18n("The text you're trying to paste contains hidden unprintable characters, " | ||||
3334 | "do you want to filter them out?"), | ||||
3335 | unsafeCharacters, | ||||
3336 | i18nc("@title", "Filter"), | ||||
3337 | KGuiItem(i18nc("@action:button", | ||||
3338 | "&Remove unprintable"), | ||||
3339 | QStringLiteral("filter-symbolic")), | ||||
3340 | KGuiItem(i18nc("@action:button", | ||||
3341 | "Confirm &paste"), | ||||
3342 | QStringLiteral("edit-paste")), | ||||
3343 | KGuiItem(i18nc("@action:button", | ||||
3344 | "&Cancel paste"), | ||||
3345 | QStringLiteral("dialog-cancel")), | ||||
3346 | QStringLiteral("ShowPasteUnprintableWarning") | ||||
3347 | ); | ||||
3348 | switch(result){ | ||||
3349 | case KMessageBox::Cancel: | ||||
3350 | return; | ||||
3351 | case KMessageBox::Yes: { | ||||
3352 | QString sanitized; | ||||
3353 | for (const QChar &c : text) { | ||||
3354 | if (c.isPrint() || c == QLatin1Char('\t') || c == QLatin1Char('\n')) { | ||||
3355 | sanitized.append(c); | ||||
3356 | } | ||||
3357 | } | ||||
3358 | text = sanitized; | ||||
3359 | } | ||||
3360 | case KMessageBox::No: | ||||
3361 | break; | ||||
3362 | default: | ||||
3363 | break; | ||||
3364 | } | ||||
3365 | } | ||||
3366 | | ||||
3296 | if (!text.isEmpty()) { | 3367 | if (!text.isEmpty()) { | ||
3297 | text.replace(QLatin1Char('\n'), QLatin1Char('\r')); | 3368 | text.replace(QLatin1Char('\n'), QLatin1Char('\r')); | ||
3298 | if (bracketedPasteMode()) { | 3369 | if (bracketedPasteMode()) { | ||
Context not available. |