Changeset View
Changeset View
Standalone View
Standalone View
src/document/katedocument.cpp
Show First 20 Lines • Show All 2997 Lines • ▼ Show 20 Line(s) | |||||
2998 | 2998 | | |||
2999 | int KTextEditor::DocumentPrivate::fromVirtualColumn(const KTextEditor::Cursor &cursor) const | 2999 | int KTextEditor::DocumentPrivate::fromVirtualColumn(const KTextEditor::Cursor &cursor) const | ||
3000 | { | 3000 | { | ||
3001 | return fromVirtualColumn(cursor.line(), cursor.column()); | 3001 | return fromVirtualColumn(cursor.line(), cursor.column()); | ||
3002 | } | 3002 | } | ||
3003 | 3003 | | |||
3004 | bool KTextEditor::DocumentPrivate::typeChars(KTextEditor::ViewPrivate *view, const QString &realChars) | 3004 | bool KTextEditor::DocumentPrivate::typeChars(KTextEditor::ViewPrivate *view, const QString &realChars) | ||
3005 | { | 3005 | { | ||
3006 | /** | 3006 | QString chars = realChars; | ||
3007 | * filter out non-printable chars (convert to utf-32 to support surrogate pairs) | | |||
3008 | */ | | |||
3009 | const auto realUcs4Chars = realChars.toUcs4(); | | |||
3010 | QVector<uint> ucs4Chars; | | |||
3011 | Q_FOREACH (auto c, realUcs4Chars) | | |||
3012 | if (QChar::isPrint(c) || c == QChar::fromLatin1('\t') || c == QChar::fromLatin1('\n') || c == QChar::fromLatin1('\r')) { | | |||
3013 | ucs4Chars.append(c); | | |||
3014 | } | | |||
3015 | | ||||
3016 | /** | | |||
3017 | * no printable chars => nothing to insert! | | |||
3018 | */ | | |||
3019 | QString chars = QString::fromUcs4(ucs4Chars.data(), ucs4Chars.size()); | | |||
3020 | if (chars.isEmpty()) { | | |||
3021 | return false; | | |||
3022 | } | | |||
3023 | 3007 | | |||
3024 | // auto bracket handling | 3008 | // auto bracket handling | ||
3025 | QChar closingBracket; | 3009 | QChar closingBracket; | ||
3026 | if (view->config()->autoBrackets()) { | 3010 | if (view->config()->autoBrackets()) { | ||
3027 | // Check if entered closing bracket is already balanced | 3011 | // Check if entered closing bracket is already balanced | ||
3028 | const QChar typedChar = chars.at(0); | 3012 | const QChar typedChar = chars.at(0); | ||
3029 | const QChar openBracket = matchingStartBracket(typedChar); | 3013 | const QChar openBracket = matchingStartBracket(typedChar); | ||
3030 | if (!openBracket.isNull()) { | 3014 | if (!openBracket.isNull()) { | ||
▲ Show 20 Lines • Show All 3066 Lines • Show Last 20 Lines |