]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlCommandBuffer.C
convert author names and status messages to docstring
[lyx.git] / src / frontends / controllers / ControlCommandBuffer.C
index e87e1bd2b703c033baeb50cfee91f0e49c56ff23..ef4bcb6a281f0c45842c72d684907409fa5e330d 100644 (file)
@@ -4,31 +4,42 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Lars
- * \author Asger and Juergen
+ * \author Asger and JΓΌrgen
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "ControlCommandBuffer.h"
-#include "bufferview_funcs.h"
-#include "debug.h"
+
+#include "BufferView.h"
+#include "cursor.h"
 #include "lyxfunc.h"
 #include "LyXAction.h"
+#include "funcrequest.h"
+
 #include "frontends/LyXView.h"
+
 #include "support/lyxalgo.h"
 #include "support/lstrings.h"
 
-using std::vector;
 using std::back_inserter;
 using std::transform;
-using std::endl;
+using std::string;
+using std::vector;
+
+namespace lyx {
+
+using support::prefixIs;
+
+namespace frontend {
 
 namespace {
 
-struct prefix_p {
+class prefix_p {
+public:
        string p;
        prefix_p(string const & s)
                : p(s) {}
@@ -44,7 +55,7 @@ ControlCommandBuffer::ControlCommandBuffer(LyXView & lv)
        : lv_(lv), history_pos_(history_.end())
 {
        transform(lyxaction.func_begin(), lyxaction.func_end(),
-               back_inserter(commands_), lyx::firster());
+               back_inserter(commands_), firster());
 }
 
 
@@ -60,17 +71,17 @@ string const ControlCommandBuffer::historyUp()
 string const ControlCommandBuffer::historyDown()
 {
        if (history_pos_ == history_.end())
-               return "";
+               return string();
        if (history_pos_ + 1 == history_.end())
-               return "";
+               return string();
 
        return *(++history_pos_);
 }
 
 
-string const ControlCommandBuffer::getCurrentState() const
+docstring const ControlCommandBuffer::getCurrentState() const
 {
-       return currentState(lv_.view().get());
+       return lv_.view()->cursor().currentState();
 }
 
 
@@ -79,7 +90,7 @@ ControlCommandBuffer::completions(string const & prefix, string & new_prefix)
 {
        vector<string> comp;
 
-       lyx::copy_if(commands_.begin(), commands_.end(),
+       copy_if(commands_.begin(), commands_.end(),
                back_inserter(comp), prefix_p(prefix));
 
        if (comp.empty()) {
@@ -92,14 +103,14 @@ ControlCommandBuffer::completions(string const & prefix, string & new_prefix)
                return vector<string>();
        }
 
-       // find maximal avaliable prefix
+       // find maximal available prefix
        string const tmp = comp[0];
-       string test(prefix);
+       string test = prefix;
        if (tmp.length() > test.length())
                test += tmp[test.length()];
        while (test.length() < tmp.length()) {
                vector<string> vtmp;
-               lyx::copy_if(comp.begin(), comp.end(),
+               copy_if(comp.begin(), comp.end(),
                        back_inserter(vtmp), prefix_p(test));
                if (vtmp.size() != comp.size()) {
                        test.erase(test.length() - 1);
@@ -120,5 +131,10 @@ void ControlCommandBuffer::dispatch(string const & str)
 
        history_.push_back(str);
        history_pos_ = history_.end();
-       lv_.getLyXFunc().dispatch(str, true);
+       FuncRequest func = lyxaction.lookupFunc(str);
+       func.origin = FuncRequest::COMMANDBUFFER;
+       lv_.dispatch(func);
 }
+
+} // namespace frontend
+} // namespace lyx