diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-27 10:12:29 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-27 10:12:29 +0200 |
commit | 314909776db599b2a90fecde6e85c9874768efeb (patch) | |
tree | 4e6c1f16be1271fba4b267bfbff4e6c8a31cbeed /sinksh/repl/replStates.cpp | |
parent | 01002ca7602b8d8a569c6d7191a1ba1ad03f3e65 (diff) | |
download | sink-314909776db599b2a90fecde6e85c9874768efeb.tar.gz sink-314909776db599b2a90fecde6e85c9874768efeb.zip |
A wrapper for linenoise
Because global variables in header files don't work if included from
multiple places.
Diffstat (limited to 'sinksh/repl/replStates.cpp')
-rw-r--r-- | sinksh/repl/replStates.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sinksh/repl/replStates.cpp b/sinksh/repl/replStates.cpp index c4b08b7..38ebdf2 100644 --- a/sinksh/repl/replStates.cpp +++ b/sinksh/repl/replStates.cpp | |||
@@ -24,14 +24,14 @@ | |||
24 | #include <QDebug> | 24 | #include <QDebug> |
25 | #include <QEvent> | 25 | #include <QEvent> |
26 | #include <QStateMachine> | 26 | #include <QStateMachine> |
27 | #include "linenoise.hpp" | ||
28 | 27 | ||
28 | #include "commandline.h" | ||
29 | #include "syntaxtree.h" | 29 | #include "syntaxtree.h" |
30 | 30 | ||
31 | ReadState::ReadState(QState *parent) | 31 | ReadState::ReadState(QState *parent) |
32 | : QState(parent) | 32 | : QState(parent) |
33 | { | 33 | { |
34 | linenoise::SetCompletionCallback([](const char* editBuffer, std::vector<std::string>& completions) { | 34 | Commandline::setCompletionCallback([](const char* editBuffer, std::vector<std::string>& completions) { |
35 | QStringList words = QString(editBuffer).split(" ", QString::SkipEmptyParts); | 35 | QStringList words = QString(editBuffer).split(" ", QString::SkipEmptyParts); |
36 | const QString fragment = words.takeLast(); | 36 | const QString fragment = words.takeLast(); |
37 | Syntax::List nearest = SyntaxTree::self()->nearestSyntax(words, fragment); | 37 | Syntax::List nearest = SyntaxTree::self()->nearestSyntax(words, fragment); |
@@ -56,7 +56,7 @@ void ReadState::onEntry(QEvent *event) | |||
56 | Q_UNUSED(event) | 56 | Q_UNUSED(event) |
57 | 57 | ||
58 | std::string line; | 58 | std::string line; |
59 | if (linenoise::Readline(prompt(), line)) { | 59 | if (Commandline::readline(prompt(), line)) { |
60 | std::cout << std::endl; | 60 | std::cout << std::endl; |
61 | emit exitRequested(); | 61 | emit exitRequested(); |
62 | return; | 62 | return; |
@@ -66,7 +66,7 @@ void ReadState::onEntry(QEvent *event) | |||
66 | const QString text = QString::fromStdString(line).simplified(); | 66 | const QString text = QString::fromStdString(line).simplified(); |
67 | 67 | ||
68 | if (text.length() > 0) { | 68 | if (text.length() > 0) { |
69 | linenoise::AddHistory(line.c_str()); | 69 | Commandline::addHistory(line); |
70 | } | 70 | } |
71 | 71 | ||
72 | emit command(text); | 72 | emit command(text); |