]> git.lyx.org Git - lyx.git/blob - src/frontends/MiniBuffer.h
Create a grfx::Loader class and so move large chunks of code out of
[lyx.git] / src / frontends / MiniBuffer.h
1 // -*- C++ -*-
2 /**
3  * \file MiniBuffer.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Lars
8  * \author Asger and Juergen
9  */
10
11 #ifndef MINIBUFFER_H
12 #define MINIBUFFER_H
13
14 #include "LString.h"
15
16 #include <boost/signals/signal0.hpp>
17 #include <boost/signals/signal1.hpp>
18 #include <boost/signals/trackable.hpp>
19
20 #include <vector>
21
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25
26 class LyXView;
27 class Timeout;
28
29 ///
30 class MiniBuffer : public boost::signals::trackable {
31 public:
32         ///
33         MiniBuffer(LyXView *);
34         
35         /// destructor
36         virtual ~MiniBuffer();
37         
38         /// Displays a text for 6 seconds
39         void message(string const & str);
40         
41         /**
42          * This will display a message for 6 seconds.
43          * It will remember the previous text that can be restored
44          * with messagePop. (You can only remember one message.)
45          */
46         void messagePush(string const & str);
47         
48         /**
49          * Restore the previous text that was messagePush'ed.
50          * for 6 seconds
51          */
52         void messagePop();
53         
54         /// Adds text to the text already displayed for 6 seconds
55         void addSet(string const &);
56         
57         /** Makes the minibuffer wait for a string to be inserted.
58             Waits for a string to be inserted into the minibuffer, when
59             the string has been inserted the signal stringReady is
60             emitted.
61         */
62         void prepareForInput(std::vector<string> const & completion,
63                              std::vector<string> & history);
64         
65         /// This is signalled when the user has input a string
66         boost::signal1<void, string const &> inputReady;
67         
68         /// This is signalled 6 seconds after a message has been displayed
69         boost::signal0<void> timeout;
70         
71 protected:
72         /// Are we in editing mode?
73         virtual bool isEditingMode() const = 0;
74         /// enter editing mode
75         virtual void editingMode() = 0;
76         /// enter message display mode
77         virtual void messageMode() = 0;
78         
79         /**
80          * This will show the info string for 1.5 seconds, after
81          * which it will revert to the input string.
82          * Use this in editing mode only. If the user presses a
83          * key in the 1.5 second interval, the information will
84          * disappear.
85          */
86         void show_information(string const & info, string const & input);
87         
88         /**
89          * This is called after information has been shown for 1.5 seconds
90          * to restore the input as given in the show_information call.
91          */
92         void restore_input();
93         
94         /**
95          * This is called when we tab-completed a command and it adds
96          * a space to the input so that we're ready to input any arguments.
97          */
98         void set_complete_input(string const &);
99         
100         /// set the minibuffer content in editing mode
101         virtual void set_input(string const &) = 0;
102         
103         /**
104          * This when a message has been displayed for 6 seconds and
105          * it will emit the timeout signal.
106          */
107         void message_timeout();
108         
109         /**
110          * This will be the input after the information will timeout
111          * in 1.5 seconds or we press a key and force the information
112          * to disappear.
113          */
114         string stored_input;
115         
116         /**
117          * This is true for 1.5 seconds while information is shown in
118          * editing mode. If the user presses a key while information
119          * is shown, the info will disappear.
120          */
121         bool information_displayed_;
122         
123         ///
124         LyXView * owner_;
125         
126         /// This is the text for the message display
127         string text;
128         
129         /// This is the last text after a messagePush()
130         string text_stored;
131         
132         /**
133          * This will emit the timeout signal after a message has been
134          * displayed for 6 seconds.
135          */
136         Timeout * timer;
137         
138         /**
139          * This will call restore_input after 1.5 seconds to restore
140          * the input after an information display.
141          */
142         Timeout * information_timer_;
143         
144         ///
145         std::vector<string> completion_;
146         ///
147         std::vector<string> * history_;
148         ///
149         std::vector<string>::iterator hist_iter;
150 };
151 #endif