Changeset View
Changeset View
Standalone View
Standalone View
src/script/katescriptmanager.cpp
Show All 27 Lines | |||||
28 | #include <QFileInfo> | 28 | #include <QFileInfo> | ||
29 | #include <QStringList> | 29 | #include <QStringList> | ||
30 | #include <QMap> | 30 | #include <QMap> | ||
31 | #include <QUuid> | 31 | #include <QUuid> | ||
32 | #include <QJsonDocument> | 32 | #include <QJsonDocument> | ||
33 | #include <QJsonValue> | 33 | #include <QJsonValue> | ||
34 | #include <QJsonObject> | 34 | #include <QJsonObject> | ||
35 | #include <QJsonArray> | 35 | #include <QJsonArray> | ||
36 | #include <QRegularExpression> | ||||
36 | 37 | | |||
37 | #include <KLocalizedString> | 38 | #include <KLocalizedString> | ||
38 | #include <KConfig> | 39 | #include <KConfig> | ||
39 | #include <KConfigGroup> | 40 | #include <KConfigGroup> | ||
40 | 41 | | |||
41 | #include "kateglobal.h" | 42 | #include "kateglobal.h" | ||
42 | #include "katecmd.h" | 43 | #include "katecmd.h" | ||
43 | #include "katepartdebug.h" | 44 | #include "katepartdebug.h" | ||
▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Line(s) | 303 | { | |||
303 | collect(); | 304 | collect(); | ||
304 | emit reloaded(); | 305 | emit reloaded(); | ||
305 | } | 306 | } | ||
306 | 307 | | |||
307 | /// Kate::Command stuff | 308 | /// Kate::Command stuff | ||
308 | 309 | | |||
309 | bool KateScriptManager::exec(KTextEditor::View *view, const QString &_cmd, QString &errorMsg, const KTextEditor::Range &) | 310 | bool KateScriptManager::exec(KTextEditor::View *view, const QString &_cmd, QString &errorMsg, const KTextEditor::Range &) | ||
310 | { | 311 | { | ||
311 | QStringList args(_cmd.split(QRegExp(QLatin1String("\\s+")), QString::SkipEmptyParts)); | 312 | Q_UNUSED(view) | ||
312 | QString cmd(args.first()); | | |||
313 | args.removeFirst(); | | |||
314 | 313 | | |||
315 | if (!view) { | 314 | QVector<QStringRef> args = _cmd.splitRef(QRegularExpression(QLatin1String("\\s+")), QString::SkipEmptyParts); | ||
316 | errorMsg = i18n("Could not access view"); | 315 | const QString cmd = args.first().toString(); | ||
317 | return false; | | |||
318 | } | | |||
319 | 316 | | |||
320 | if (cmd == QLatin1String("reload-scripts")) { | 317 | if (cmd == QLatin1String("reload-scripts")) { | ||
321 | reload(); | 318 | reload(); | ||
322 | return true; | 319 | return true; | ||
323 | } else { | | |||
324 | errorMsg = i18n("Command not found: %1", cmd); | | |||
325 | return false; | | |||
326 | } | 320 | } | ||
321 | | ||||
322 | return false; | ||||
327 | } | 323 | } | ||
328 | 324 | | |||
329 | bool KateScriptManager::help(KTextEditor::View *view, const QString &cmd, QString &msg) | 325 | bool KateScriptManager::help(KTextEditor::View *view, const QString &cmd, QString &msg) | ||
330 | { | 326 | { | ||
331 | Q_UNUSED(view) | 327 | Q_UNUSED(view) | ||
332 | 328 | | |||
333 | if (cmd == QLatin1String("reload-scripts")) { | 329 | if (cmd == QLatin1String("reload-scripts")) { | ||
334 | msg = i18n("Reload all JavaScript files (indenters, command line scripts, etc)."); | 330 | msg = i18n("Reload all JavaScript files (indenters, command line scripts, etc)."); | ||
335 | return true; | 331 | return true; | ||
336 | } else { | | |||
337 | msg = i18n("Command not found: %1", cmd); | | |||
338 | return false; | | |||
339 | } | 332 | } | ||
333 | | ||||
334 | return false; | ||||
340 | } | 335 | } | ||
341 | 336 | |