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 <QPushButton> 20 #include <QWidget> 21 22 #include <vector> 23 24 class QListWidgetItem; 25 26 namespace lyx { 27 28 class DispatchResult; 29 30 namespace frontend { 31 32 class GuiView; 33 class GuiCommandEdit; 34 35 class GuiCommandBuffer : public QWidget 36 { 37 Q_OBJECT 38 39 public: 40 GuiCommandBuffer(GuiView * view); 41 42 public Q_SLOTS: 43 /// dispatch a command 44 void dispatch(); 45 /// tab-complete 46 void complete(); 47 /// show history 48 void listHistoryUp(); 49 /// called when an item in a list is selected 50 void itemSelected(QListWidgetItem *); 51 /// up 52 void up(); 53 /// down 54 void down(); 55 /// leave and hide the command buffer 56 void hideParent(); 57 private: 58 /// owning view 59 GuiView * view_; 60 /// command widget 61 GuiCommandEdit * edit_; 62 63 /// return the previous history entry if any 64 std::string const historyUp(); 65 /// return the next history entry if any 66 std::string const historyDown(); 67 68 /// open a listbox and show the contents of the list. When reversed 69 /// is true, the contents of the list is filled bottom-up. 70 void showList(std::vector<std::string> const & list, 71 QPoint const & pos, bool reversed = false) 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 DispatchResult const & 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 /// the button up 90 QPushButton * upPB; 91 92 /// the button down 93 QPushButton * downPB; 94 }; 95 96 } // namespace frontend 97 } // namespace lyx 98 99 #endif // GUICOMMANDBUFFER_H 100