]> git.lyx.org Git - lyx.git/blob - src/frontends/Selection.h
Fix completion in math when inline completion was not yet shown (take 2)
[lyx.git] / src / frontends / Selection.h
1 // -*- C++ -*-
2 /**
3  * \file Selection.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef SELECTION_H
15 #define SELECTION_H
16
17 #include "support/strfwd.h"
18
19 namespace lyx {
20 namespace frontend {
21
22 /**
23  * A Selection class manages the selection.
24  */
25 class Selection
26 {
27 public:
28         virtual ~Selection() {}
29
30         /**
31          * Returns true if the underlying system supports mouse selection
32          * (basically X11 and Wayland).
33          */
34         virtual bool supported() const = 0;
35         /**
36          * Tell the window system whether we set or cleared our selection.
37          * This is a noop on systems that don't have a selection.
38          * This should be called by the kernel whenever a selection is
39          * created, changed or cleared.
40          * \param own
41          * If true: Tell that we got a valid selection.
42          * If false: Tell that we cleared our selection.
43          */
44         virtual void haveSelection(bool) = 0;
45         /**
46          * Get the X selection contents.
47          * This is a noop on systems that don't have a selection.
48          * The format is plain text.
49          * This should be called when the user presses the middle mouse
50          * button.
51          */
52         virtual docstring const get() const = 0;
53         /**
54          * Fill the X selection.
55          * The format is plain text.
56          * Does nothing on systems that don't have a selection.
57          * Since the X selection protocol is asynchronous this should never be
58          * called from the kernel.
59          * If another application requests the current selection a
60          * SelectionRequest XEvent will be triggered. The response of the
61          * frontend to this event should be to retrieve the current selection
62          * from the kernel and push it to X with this method.
63          */
64         virtual void put(docstring const &) = 0;
65         /**
66          * Is the X selection empty?
67          * This does always return true on systems that don't have a real
68          * selection.
69          */
70         virtual bool empty() const = 0;
71 };
72
73 } // namespace frontend
74
75 /// Implementation is in Application.cpp
76 extern frontend::Selection & theSelection();
77
78 } // namespace lyx
79
80
81 #endif // SELECTION_H