summaryrefslogtreecommitdiffstats
path: root/akonadi2_cli
diff options
context:
space:
mode:
Diffstat (limited to 'akonadi2_cli')
-rw-r--r--akonadi2_cli/repl/replStates.cpp44
-rw-r--r--akonadi2_cli/repl/replStates.h4
2 files changed, 28 insertions, 20 deletions
diff --git a/akonadi2_cli/repl/replStates.cpp b/akonadi2_cli/repl/replStates.cpp
index efa1353..314cca8 100644
--- a/akonadi2_cli/repl/replStates.cpp
+++ b/akonadi2_cli/repl/replStates.cpp
@@ -81,8 +81,7 @@ const char *UnfinishedReadState::prompt() const
81} 81}
82 82
83EvalState::EvalState(QState *parent) 83EvalState::EvalState(QState *parent)
84 : QState(parent), 84 : QState(parent)
85 m_complete(false)
86{ 85{
87} 86}
88 87
@@ -90,29 +89,36 @@ void EvalState::onEntry(QEvent *event)
90{ 89{
91 QStateMachine::SignalEvent *e = dynamic_cast<QStateMachine::SignalEvent*>(event); 90 QStateMachine::SignalEvent *e = dynamic_cast<QStateMachine::SignalEvent*>(event);
92 91
93 if (!e || e->arguments().isEmpty()) { 92 const QString command = e ? e->arguments()[0].toString() : QString();
94 if (m_complete) { 93
95 emit completed(); 94 if (command.isEmpty()) {
96 } else { 95 complete();
97 emit continueInput();
98 }
99 return; 96 return;
100 } 97 }
101 98
102 //TODO: properly tokenize (e.g. "foo bar" should not become ['"foo', 'bar"'] 99 if (command.right(1) == "\\") {
103 const QString command = e->arguments()[0].toString(); 100 m_partial += " " + command.left(command.size() - 1);
104 101 continueInput();
105 if (!command.isEmpty()) { 102 } else {
106 m_complete = command.right(1) != "\\"; 103 m_partial += " " + command;
107 if (m_complete) { 104 complete();
108 //emit output("Processing ... " + command);
109 const QStringList commands = command.split(" ");
110 Module::self()->run(commands);
111 emit completed();
112 }
113 } 105 }
114} 106}
115 107
108void EvalState::complete()
109{
110 m_partial = m_partial.simplified();
111
112 if (!m_partial.isEmpty()) {
113 //emit output("Processing ... " + command);
114 const QStringList commands = Module::tokenize(m_partial);
115 Module::self()->run(commands);
116 m_partial.clear();
117 }
118
119 emit completed();
120}
121
116PrintState::PrintState(QState *parent) 122PrintState::PrintState(QState *parent)
117 : QState(parent) 123 : QState(parent)
118{ 124{
diff --git a/akonadi2_cli/repl/replStates.h b/akonadi2_cli/repl/replStates.h
index a019a37..a0d3f90 100644
--- a/akonadi2_cli/repl/replStates.h
+++ b/akonadi2_cli/repl/replStates.h
@@ -66,7 +66,9 @@ protected:
66 void onEntry(QEvent *event); 66 void onEntry(QEvent *event);
67 67
68private: 68private:
69 bool m_complete; 69 void complete();
70
71 QString m_partial;
70}; 72};
71 73
72class PrintState : public QState 74class PrintState : public QState