X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2FSelection.h;h=ac902ffc1eaafcaef57e201ddf59fd9ff5d8ab73;hb=1f10969bb5c5f36017bf5ba8671381b09945cf57;hp=45ce213cd0556adbcfe65e1a305d89a89441fb5c;hpb=c9c6ed0b7fbccbbed8b5ef48d05cfefa5acfb99e;p=lyx.git diff --git a/src/frontends/Selection.h b/src/frontends/Selection.h index 45ce213cd0..ac902ffc1e 100644 --- a/src/frontends/Selection.h +++ b/src/frontends/Selection.h @@ -11,10 +11,10 @@ * Full author contact details are available in file CREDITS. */ -#ifndef BASE_SELECTION_H -#define BASE_SELECTION_H +#ifndef SELECTION_H +#define SELECTION_H -#include +#include "support/strfwd.h" namespace lyx { namespace frontend { @@ -27,7 +27,15 @@ class Selection public: virtual ~Selection() {} - /// Tell the window system whether we have a selection. + /** + * Tell the window system whether we set or cleared our selection. + * This is a noop on systems that don't have a selection. + * This should be called by the kernel whenever a selection is + * created, changed or cleared. + * \param own + * If true: Tell that we got a valid selection. + * If false: Tell that we cleared our selection. + */ virtual void haveSelection(bool) = 0; /** * Get the X selection contents. @@ -36,16 +44,33 @@ public: * This should be called when the user presses the middle mouse * button. */ - virtual std::string const get() const = 0; + virtual docstring const get() const = 0; /** * Fill the X selection. + * The format is plain text. * Does nothing on systems that don't have a selection. - * This should be called whenever some text is highlighted. + * Since the X selection protocol is asyncronous this should never be + * called from the kernel. + * If another application requests the current selection a + * SelectionRequest XEvent will be triggered. The response of the + * frontend to this event should be to retrieve the current selection + * from the kernel and push it to X with this method. */ - virtual void put(std::string const &) = 0; + virtual void put(docstring const &) = 0; + /** + * Is the X selection empty? + * This does always return true on systems that don't have a real + * selection. + */ + virtual bool empty() const = 0; }; } // namespace frontend + +/// Implementation is in Application.cpp +extern frontend::Selection & theSelection(); + } // namespace lyx -#endif // BASE_SELECTION_H + +#endif // SELECTION_H