]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlCommandBuffer.h
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlCommandBuffer.h
1 // -*- C++ -*-
2 /**
3  * \file ControlCommandBuffer.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars
8  * \author Asger and Jürgen
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef CONTROLCOMMANDBUFFER_H
15 #define CONTROLCOMMANDBUFFER_H
16
17 #include <string>
18 #include <vector>
19
20
21 class LyXView;
22
23 namespace lyx {
24 namespace frontend {
25
26 /**
27  * ControlCommandBuffer
28  *
29  * This provides methods for the use of a toolkit's
30  * minibuffer/command buffer
31  */
32 class ControlCommandBuffer {
33 public:
34         ControlCommandBuffer(LyXView & lv);
35
36         /// return the previous history entry if any
37         std::string const historyUp();
38
39         /// return the next history entry if any
40         std::string const historyDown();
41
42         /// return the font and depth in the active BufferView as a message.
43         std::string const getCurrentState() const;
44
45         /// return the possible completions
46         std::vector<std::string> const completions(std::string const & prefix,
47                                               std::string & new_prefix);
48
49         /// dispatch a command
50         void dispatch(std::string const & str);
51 private:
52         /// controlling LyXView
53         LyXView & lv_;
54
55         /// available command names
56         std::vector<std::string> commands_;
57
58         /// command history
59         std::vector<std::string> history_;
60
61         /// current position in command history
62         std::vector<std::string>::const_iterator history_pos_;
63 };
64
65 } // namespace frontend
66 } // namespace lyx
67
68 #endif // CONTROLCOMMANDBUFFER_H