Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 1182 Lines • ▼ Show 20 Line(s) | |||||
1183 | * Line <- [0-9]+ | 1183 | * Line <- [0-9]+ | ||
1184 | * LastLine <- "$" | 1184 | * LastLine <- "$" | ||
1185 | * ThisLine <- "." | 1185 | * ThisLine <- "." | ||
1186 | * Mark <- "'" [a-z] | 1186 | * Mark <- "'" [a-z] | ||
1187 | */ | 1187 | */ | ||
1188 | 1188 | | |||
1189 | void KateCmdLineEdit::slotReturnPressed(const QString &text) | 1189 | void KateCmdLineEdit::slotReturnPressed(const QString &text) | ||
1190 | { | 1190 | { | ||
1191 | static const QRegularExpression focusChangingCommands(QStringLiteral("^(buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$")); | ||||
kossebau: Refactoring to one static object will be separate commit. | |||||
I would have no issue with this to be in this commit ;=) cullmann: I would have no issue with this to be in this commit ;=)
That saves me review time :P | |||||
1192 | | ||||
1191 | if (text.isEmpty()) { | 1193 | if (text.isEmpty()) { | ||
1192 | return; | 1194 | return; | ||
1193 | } | 1195 | } | ||
1194 | // silently ignore leading space characters | 1196 | // silently ignore leading space characters | ||
1195 | uint n = 0; | 1197 | uint n = 0; | ||
1196 | const uint textlen = text.length(); | 1198 | const uint textlen = text.length(); | ||
1197 | while ((n < textlen) && (text[n].isSpace())) { | 1199 | while ((n < textlen) && (text[n].isSpace())) { | ||
1198 | n++; | 1200 | n++; | ||
Show All 20 Lines | |||||
1219 | } | 1221 | } | ||
1220 | 1222 | | |||
1221 | if (cmd.length() > 0) { | 1223 | if (cmd.length() > 0) { | ||
1222 | KTextEditor::Command *p = KateCmd::self()->queryCommand(cmd); | 1224 | KTextEditor::Command *p = KateCmd::self()->queryCommand(cmd); | ||
1223 | 1225 | | |||
1224 | m_oldText = leadingRangeExpression + cmd; | 1226 | m_oldText = leadingRangeExpression + cmd; | ||
1225 | m_msgMode = true; | 1227 | m_msgMode = true; | ||
1226 | 1228 | | |||
1227 | // the following commands changes the focus themselves, so bar should be hidden before execution. | 1229 | // if the command changes the focus itself, the bar should be hidden before execution. | ||
1228 | if (QRegularExpression(QLatin1String("^(buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$")).match(cmd.split(QLatin1Char(' ')).at(0)).hasMatch()) { | 1230 | if (focusChangingCommands.match(cmd.leftRef(cmd.indexOf(QLatin1Char(' ')))).hasMatch()) { | ||
1229 | emit hideRequested(); | 1231 | emit hideRequested(); | ||
1230 | } | 1232 | } | ||
1231 | 1233 | | |||
1232 | if (!p) { | 1234 | if (!p) { | ||
1233 | setText(i18n("No such command: \"%1\"", cmd)); | 1235 | setText(i18n("No such command: \"%1\"", cmd)); | ||
1234 | } else if (range.isValid() && !p->supportsRange(cmd)) { | 1236 | } else if (range.isValid() && !p->supportsRange(cmd)) { | ||
1235 | // Raise message, when the command does not support ranges. | 1237 | // Raise message, when the command does not support ranges. | ||
1236 | setText(i18n("Error: No range allowed for command \"%1\".", cmd)); | 1238 | setText(i18n("Error: No range allowed for command \"%1\".", cmd)); | ||
Show All 31 Lines | |||||
1268 | if (completionObject() != KateCmd::self()->commandCompletionObject()) { | 1270 | if (completionObject() != KateCmd::self()->commandCompletionObject()) { | ||
1269 | KCompletion *c = completionObject(); | 1271 | KCompletion *c = completionObject(); | ||
1270 | setCompletionObject(KateCmd::self()->commandCompletionObject()); | 1272 | setCompletionObject(KateCmd::self()->commandCompletionObject()); | ||
1271 | delete c; | 1273 | delete c; | ||
1272 | } | 1274 | } | ||
1273 | m_command = nullptr; | 1275 | m_command = nullptr; | ||
1274 | m_cmdend = 0; | 1276 | m_cmdend = 0; | ||
1275 | 1277 | | |||
1276 | // the following commands change the focus themselves | 1278 | if (!focusChangingCommands.match(cmd.leftRef(cmd.indexOf(QLatin1Char(' ')))).hasMatch()) { | ||
1277 | if (!QRegularExpression(QLatin1String("^(buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$")).match(cmd.split(QLatin1Char(' ')).at(0)).hasMatch()) { | | |||
1278 | m_view->setFocus(); | 1279 | m_view->setFocus(); | ||
1279 | } | 1280 | } | ||
1280 | 1281 | | |||
1281 | if (isVisible()) { | 1282 | if (isVisible()) { | ||
1282 | m_hideTimer->start(4000); | 1283 | m_hideTimer->start(4000); | ||
1283 | } | 1284 | } | ||
1284 | } | 1285 | } | ||
1285 | 1286 | | |||
▲ Show 20 Lines • Show All 1822 Lines • Show Last 20 Lines |
Refactoring to one static object will be separate commit.