]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCommandBuffer.h
Introducing TextClassPtr.h to minimize header dependencies.
[lyx.git] / src / frontends / qt4 / GuiCommandBuffer.h
1 // -*- C++ -*-
2 /**
3  * \file GuiCommandBuffer.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 GUICOMMANDBUFFER_H
15 #define GUICOMMANDBUFFER_H
16
17 #include "support/docstring.h"
18
19 #include <QWidget>
20
21 #include <vector>
22
23 class QListWidgetItem;
24
25 namespace lyx {
26 namespace frontend {
27
28 class LyXView;
29 class GuiView;
30 class GuiCommandEdit;
31
32 class GuiCommandBuffer : public QWidget
33 {
34         Q_OBJECT
35
36 public:
37         GuiCommandBuffer(GuiView * view);
38
39 public Q_SLOTS:
40         /// cancel command compose
41         void cancel();
42         /// dispatch a command
43         void dispatch();
44         /// tab-complete
45         void complete();
46         /// select-complete
47         void complete_selected(QListWidgetItem *);
48         /// up
49         void up();
50         /// down
51         void down();
52         /// leave and hide the command buffer
53         void hideParent();
54 private:
55         /// owning view
56         GuiView * view_;
57         ///
58         LyXView & lv_;
59         /// command widget
60         GuiCommandEdit * edit_;
61
62         /// return the previous history entry if any
63         std::string const historyUp();
64         /// return the next history entry if any
65         std::string const historyDown();
66
67         /// return the font and depth in the active BufferView as a message.
68         docstring const getCurrentState() const;
69
70         /// hide the command buffer.
71         void hide() const;
72
73         /// return the possible completions
74         std::vector<std::string> const completions(std::string const & prefix,
75                                               std::string & new_prefix);
76
77         /// dispatch a command
78         void dispatch(std::string const & str);
79
80         /// available command names
81         std::vector<std::string> commands_;
82
83         /// command history
84         std::vector<std::string> history_;
85
86         /// current position in command history
87         std::vector<std::string>::const_iterator history_pos_;
88 };
89
90 } // namespace frontend
91 } // namespace lyx
92
93 #endif // GUICOMMANDBUFFER_H