}
-void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, unsigned int state)
+void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, key_modifier::state state)
{
bv_->owner()->getLyXFunc()->processKeySym(keysym, state);
}
-void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
+void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state state)
{
// Only use motion with button 1
- if (!(state & Button1MotionMask))
+ if (!(state & mouse_button::button1))
return;
if (!buffer_ || !screen_.get()) return;
// Single-click on work area
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
- unsigned int button)
+ mouse_button::state button)
{
if (!buffer_ || !screen_.get())
return;
// ok ok, this is a hack.
- // Why??? (Jug20020424)
- if (button == 4 || button == 5) {
- switch (button) {
- case 4:
- scrollUp(lyxrc.wheel_jump); // default 100, set in lyxrc
- break;
- case 5:
- scrollDown(lyxrc.wheel_jump);
- break;
- }
+
+ if (button == mouse_button::button4) {
+ scrollUp(lyxrc.wheel_jump);
+ // We shouldn't go further down as we really should only do the
+ // scrolling and be done with this. Otherwise we may open some
+ // dialogs (Jug 20020424).
+ return;
+ } else if (button == mouse_button::button5) {
+ scrollDown(lyxrc.wheel_jump);
// We shouldn't go further down as we really should only do the
// scrolling and be done with this. Otherwise we may open some
// dialogs (Jug 20020424).
return;
}
-
+
Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos);
// Middle button press pastes if we have a selection
// it could get cleared on the unlocking of the inset so
// we have to check this first
bool paste_internally = false;
- if (button == 2 && bv_->getLyXText()->selection.set()) {
+ if (button == mouse_button::button2 && bv_->getLyXText()->selection.set()) {
owner_->getLyXFunc()->dispatch(LFUN_COPY);
paste_internally = true;
}
// I'm not sure we should continue here if we hit an inset (Jug20020403)
// Right click on a footnote flag opens float menu
- if (button == 3) {
+ if (button == mouse_button::button3) {
selection_possible = false;
return;
}
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,
// insert this
- if (button == 2) {
+ if (button == mouse_button::button2) {
if (paste_internally)
owner_->getLyXFunc()->dispatch(LFUN_PASTE);
else
}
-void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
+void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, mouse_button::state button)
{
- // select a word
if (!buffer_)
return;
if (text->bv_owner && bv_->theLockingInset())
return;
- if (screen_.get() && button == 1) {
+ if (screen_.get() && button == mouse_button::button1) {
if (text->bv_owner) {
screen_->hideCursor();
screen_->toggleSelection(text, bv_);
}
-void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
+void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, mouse_button::state button)
{
- // select a line
if (!buffer_)
return;
if (text->bv_owner && bv_->theLockingInset())
return;
- if (screen_.get() && (button == 1)) {
+ if (screen_.get() && (button == mouse_button::button1)) {
if (text->bv_owner) {
screen_->hideCursor();
screen_->toggleSelection(text, bv_);
void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
- unsigned int button)
+ mouse_button::state button)
{
// do nothing if we used the mouse wheel
- if (!buffer_ || !screen_.get() || button == 4 || button == 5)
+ if (!buffer_ || !screen_.get() || button == mouse_button::button4 || button == mouse_button::button5)
return;
// If we hit an inset, we have the inset coordinates in these
selection_possible = false;
- if (button == 2)
+ if (button == mouse_button::button2)
return;
// finish selection
- if (button == 1) {
+ if (button == mouse_button::button1) {
workarea_.haveSelection(bv_->getLyXText()->selection.set());
}
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) {
- bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, 0);
+ bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, mouse_button::none);
}
return;
#include "BufferView.h"
#include "commandtags.h"
+#include "frontends/mouse_state.h"
#include "frontends/Timeout.h"
// FIXME remove me
#include "frontends/WorkArea.h"
///
int scrollDown(long time);
///
- void workAreaKeyPress(KeySym, unsigned int state);
+ void workAreaKeyPress(KeySym, key_modifier::state state);
///
- void workAreaMotionNotify(int x, int y, unsigned int state);
+ void workAreaMotionNotify(int x, int y, mouse_button::state state);
///
- void workAreaButtonPress(int x, int y, unsigned int button);
+ void workAreaButtonPress(int x, int y, mouse_button::state button);
///
- void workAreaButtonRelease(int x, int y, unsigned int button);
+ void workAreaButtonRelease(int x, int y, mouse_button::state button);
///
- void doubleClick(int x, int y, unsigned int button);
+ void doubleClick(int x, int y, mouse_button::state button);
///
- void tripleClick(int x, int y, unsigned int button);
+ void tripleClick(int x, int y, mouse_button::state button);
///
void selectionRequested();
///
+2002-05-26 John Levon <moz@compsoc.man.ac.uk>
+
+ * BufferView_pimpl.h:
+ * BufferView_pimpl.C:
+ * kbmap.h:
+ * kbmap.C:
+ * kbsequence.h:
+ * kbsequence.C:
+ * lyxfunc.h:
+ * lyxfunc.C:
+ * text2.C: use key_state/mouse_state
+
2002-05-25 Lars Gullik Bjønnes <larsbj@birdstep.com>
* vc-backend.C (scanMaster): use boost regex and get rid of LRegex
+2002-05-26 John Levon <moz@compsoc.man.ac.uk>
+
+ * key_state.h:
+ * mouse_state.h: add
+
+ * Makefile.am:
+ * WorkArea.h:
+ * WorkArea.C: use above
+
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
WorkArea.h \
font_loader.h \
font_metrics.h \
+ key_state.h \
+ mouse_state.h \
screen.C \
screen.h
XSync(fl_get_display(), 0);
}
+// FIXME !
+mouse_button::state x_button_state(unsigned int button)
+{
+ mouse_button::state b = mouse_button::none;
+ switch (button) {
+ case Button1:
+ b = mouse_button::button1;
+ break;
+ case Button2:
+ b = mouse_button::button2;
+ break;
+ case Button3:
+ b = mouse_button::button3;
+ break;
+ case Button4:
+ b = mouse_button::button4;
+ break;
+ case Button5:
+ b = mouse_button::button5;
+ break;
+ default: // FIXME
+ break;
+ }
+ return b;
+}
+
+
+// FIXME
+mouse_button::state x_motion_state(unsigned int state)
+{
+ mouse_button::state b = mouse_button::none;
+ if (state & Button1MotionMask)
+ b |= mouse_button::button1;
+ if (state & Button2MotionMask)
+ b |= mouse_button::button2;
+ if (state & Button3MotionMask)
+ b |= mouse_button::button3;
+ if (state & Button4MotionMask)
+ b |= mouse_button::button4;
+ if (state & Button5MotionMask)
+ b |= mouse_button::button5;
+ return b;
+}
+
+
+key_modifier::state x_key_state(unsigned int state)
+{
+ key_modifier::state k = key_modifier::none;
+ if (state & ControlMask)
+ k |= key_modifier::ctrl;
+ if (state & ShiftMask)
+ k |= key_modifier::shift;
+ if (state & Mod1Mask)
+ k |= key_modifier::alt;
+ return k;
+}
+
+
} // anon namespace
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
area->workAreaButtonPress(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
- ev->xbutton.button);
- //area->workAreaKeyPress(XK_Pointer_Button1, ev->xbutton.state);
+ x_button_state(ev->xbutton.button));
break;
case FL_RELEASE:
if (!ev || ev->xbutton.button == 0) break;
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
area->workAreaButtonRelease(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
- ev->xbutton.button);
+ x_button_state(ev->xbutton.button));
break;
#if FL_REVISION < 89
case FL_MOUSE:
lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl;
area->workAreaMotionNotify(ev->xmotion.x - ob->x,
ev->xmotion.y - ob->y,
- ev->xbutton.state);
+ x_motion_state(ev->xbutton.state));
}
break;
#if FL_REVISION < 89
last_key_pressed = xke->keycode;
last_state_pressed = ret_state;
- area->workAreaKeyPress(ret_key, ret_state);
+ area->workAreaKeyPress(ret_key, x_key_state(ret_state));
}
break;
lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
area->workAreaDoubleClick(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
- ev->xbutton.button);
+ x_button_state(ev->xbutton.button));
break;
case FL_TRPLCLICK:
if (!ev) break;
lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
area->workAreaTripleClick(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
- ev->xbutton.button);
+ x_button_state(ev->xbutton.button));
break;
case FL_OTHER:
if (!ev) break;
#include FORMS_H_LOCATION
#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
+#include "frontends/key_state.h"
///
class WorkArea {
///
SigC::Signal1<void, double> scrollCB;
///
- SigC::Signal2<void, KeySym, unsigned int> workAreaKeyPress;
+ SigC::Signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
///
- SigC::Signal3<void, int, int, unsigned int> workAreaButtonPress;
+ SigC::Signal3<void, int, int, mouse_button::state> workAreaButtonPress;
///
- SigC::Signal3<void, int, int, unsigned int> workAreaButtonRelease;
+ SigC::Signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
///
- SigC::Signal3<void, int, int, unsigned int> workAreaMotionNotify;
+ SigC::Signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
///
SigC::Signal0<void> workAreaFocus;
///
///
SigC::Signal0<void> workAreaLeave;
///
- SigC::Signal3<void, int, int, unsigned int> workAreaDoubleClick;
+ SigC::Signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
///
- SigC::Signal3<void, int, int, unsigned int> workAreaTripleClick;
+ SigC::Signal3<void, int, int, mouse_button::state> workAreaTripleClick;
/// emitted when an X client has requested our selection
SigC::Signal0<void> selectionRequested;
/// emitted when another X client has stolen our selection
--- /dev/null
+/**
+ * \file key_state.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Keyboard modifier state representation.
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef KEY_STATE_H
+#define KEY_STATE_H
+
+/// modifier key states
+namespace key_modifier {
+ enum state {
+ none = 0, //< no modifiers held
+ ctrl = 1, //< control button held
+ alt = 2, //< alt/meta key held
+ shift = 4 //< shift key held
+ };
+
+
+inline state operator|(state const & s1, state const & s2)
+{
+ int const i1(static_cast<int>(s1));
+ int const i2(static_cast<int>(s2));
+ return static_cast<state>(i1 | i2);
+}
+
+
+inline void operator|=(state & s1, state s2)
+{
+ s1 = static_cast<state>(s1 | s2);
+}
+
+} // namespace key_modifier
+
+#endif // KEY_STATE_H
--- /dev/null
+/**
+ * \file mouse_state.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * GUII representation of mouse presses and
+ * mouse button states
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef MOUSE_STATE_H
+#define MOUSE_STATE_H
+
+/// used both for presses and held during motion
+namespace mouse_button {
+
+ enum state {
+ none = 0, //< no buttons held
+ button1 = 1, //< mouse button 1 pressed
+ button2 = 2,
+ button3 = 4,
+ button4 = 8,
+ button5 = 16
+ };
+
+inline void operator|=(state & s1, state s2)
+{
+ s1 = static_cast<state>(s1 | s2);
+}
+
+} // namespace mouse_button
+
+#endif // MOUSE_STATE_H
+2002-05-26 John Levon <moz@compsoc.man.ac.uk>
+
+ * inset.C:
+ * inset.h:
+ * insetbib.C:
+ * insetbib.h:
+ * insetcite.h:
+ * insetcite.C:
+ * insetcollapsable.C:
+ * insetcollapsable.h:
+ * inseterror.C:
+ * inseterror.h:
+ * insetert.C:
+ * insetert.h:
+ * insetexternal.C:
+ * insetexternal.h:
+ * insetfloatlist.C:
+ * insetfloatlist.h:
+ * insetgraphics.C:
+ * insetgraphics.h:
+ * insetinclude.C:
+ * insetinclude.h:
+ * insetindex.C:
+ * insetindex.h:
+ * insetlabel.C:
+ * insetlabel.h:
+ * insetparent.C:
+ * insetparent.h:
+ * insetref.C:
+ * insetref.h:
+ * insettabular.C:
+ * insettabular.h:
+ * insettext.C:
+ * insettext.h:
+ * insettoc.C:
+ * insettoc.h:
+ * inseturl.C:
+ * inseturl.h: use mouse_state. Kill insetKeyPress
+
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* insetbib.C:
#include "BufferView.h"
#include "support/lstrings.h"
#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
#include "commandtags.h"
#include "support/lstrings.h"
#include "gettext.h"
}
-void Inset::edit(BufferView *, int, int, unsigned int)
+void Inset::edit(BufferView *, int, int, mouse_button::state)
{}
{}
-void UpdatableInset::insetButtonPress(BufferView *, int x, int y, int button)
+void UpdatableInset::insetButtonPress(BufferView *, int x, int y, mouse_button::state button)
{
lyxerr[Debug::INFO] << "Inset Button Press x=" << x
<< ", y=" << y << ", button=" << button << endl;
}
-bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button)
+bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, mouse_button::state button)
{
lyxerr[Debug::INFO] << "Inset Button Release x=" << x
<< ", y=" << y << ", button=" << button << endl;
}
-void UpdatableInset::insetKeyPress(XKeyEvent *)
-{
- lyxerr[Debug::INFO] << "Inset Keypress" << endl;
-}
-
-
-void UpdatableInset::insetMotionNotify(BufferView *, int x, int y, int state)
+void UpdatableInset::insetMotionNotify(BufferView *, int x, int y, mouse_button::state state)
{
lyxerr[Debug::INFO] << "Inset Motion Notify x=" << x
<< ", y=" << y << ", state=" << state << endl;
{}
-void UpdatableInset::edit(BufferView *, int, int, unsigned int)
+void UpdatableInset::edit(BufferView *, int, int, mouse_button::state)
{}
#include <vector>
#include "LString.h"
-#include <X11/Xlib.h>
#include "commandtags.h"
+#include "frontends/mouse_state.h"
#include "LColor.h"
class LyXFont;
/// what appears in the minibuffer when opening
virtual string const editMessage() const;
///
- virtual void edit(BufferView *, int x, int y, unsigned int button);
+ virtual void edit(BufferView *, int x, int y, mouse_button::state button);
///
virtual void edit(BufferView *, bool front = true);
///
virtual EDITABLE editable() const;
/// This is called when the user clicks inside an inset
- virtual void insetButtonPress(BufferView *, int, int, int) {}
+ virtual void insetButtonPress(BufferView *, int, int, mouse_button::state) {}
/// This is called when the user releases the button inside an inset
// the bool return is used to see if we opened a dialog so that we can
// check this from an outer inset and open the dialog of the
// outer inset if that one has one!
- virtual bool insetButtonRelease(BufferView *, int, int, int)
+ virtual bool insetButtonRelease(BufferView *, int, int, mouse_button::state)
{ return editable() == IS_EDITABLE; }
/// This is called when the user moves the mouse inside an inset
- virtual void insetMotionNotify(BufferView *, int , int , int) {}
+ virtual void insetMotionNotify(BufferView *, int , int, mouse_button::state) {}
///
virtual bool isTextInset() const { return false; }
///
///
virtual void getCursorPos(BufferView *, int &, int &) const {}
///
- virtual void insetButtonPress(BufferView *, int x, int y, int button);
+ virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
///
// the bool return is used to see if we opened a dialog so that we can
// check this from an outer inset and open the dialog of the outer inset
// if that one has one!
///
virtual bool insetButtonRelease(BufferView *,
- int x, int y, int button);
+ int x, int y, mouse_button::state button);
///
- virtual void insetKeyPress(XKeyEvent * ev);
- ///
- virtual void insetMotionNotify(BufferView *, int x, int y, int state);
+ virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
///
virtual void insetUnlock(BufferView *);
///
- virtual void edit(BufferView *, int x, int y, unsigned int button);
+ virtual void edit(BufferView *, int x, int y, mouse_button::state button);
///
virtual void edit(BufferView *, bool front = true);
///
}
-void InsetBibKey::edit(BufferView * bv, int, int, unsigned int)
+void InsetBibKey::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showBibitem(this);
}
void InsetBibKey::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
}
-void InsetBibtex::edit(BufferView * bv, int, int, unsigned int)
+void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showBibtex(this);
}
void InsetBibtex::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
virtual string const getScreenLabel(Buffer const *) const;
///
- void edit(BufferView *, int x, int y, unsigned int button);
+ void edit(BufferView *, int x, int y, mouse_button::state button);
///
void edit(BufferView * bv, bool front = true);
///
///
Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
///
- void edit(BufferView *, int x, int y, unsigned int button);
+ void edit(BufferView *, int x, int y, mouse_button::state button);
///
void edit(BufferView * bv, bool front = true);
///
}
-void InsetCitation::edit(BufferView * bv, int, int, unsigned int)
+void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state)
{
// A call to edit() indicates that we're no longer loading the
// buffer but doing some real work.
void InsetCitation::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
Inset::Code lyxCode() const { return Inset::CITE_CODE; }
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
- unsigned int button)
+ mouse_button::state button)
{
UpdatableInset::edit(bv, xp, yp, button);
void InsetCollapsable::insetButtonPress(BufferView * bv,
- int x, int y, int button)
+ int x, int y, mouse_button::state button)
{
if (!collapsed_ && (y > button_bottom_y)) {
LyXFont font(LyXFont::ALL_SANE);
bool InsetCollapsable::insetButtonRelease(BufferView * bv,
- int x, int y, int button)
+ int x, int y, mouse_button::state button)
{
bool ret = false;
- if ((button != 3) && (x >= 0) && (x < button_length) &&
+ if ((button != mouse_button::button3) && (x < button_length) &&
(y >= button_top_y) && (y <= button_bottom_y))
{
if (collapsed_) {
inset.ascent(bv, font));
ret = inset.insetButtonRelease(bv, x, yy, button);
}
- if ((button == 3) && !ret) {
+ if ((button == mouse_button::button3) && !ret) {
return showInsetDialog(bv);
}
return ret;
void InsetCollapsable::insetMotionNotify(BufferView * bv,
- int x, int y, int state)
+ int x, int y, mouse_button::state state)
{
if (y > button_bottom_y) {
LyXFont font(LyXFont::ALL_SANE);
}
-void InsetCollapsable::insetKeyPress(XKeyEvent * xke)
-{
- inset.insetKeyPress(xke);
-}
-
-
int InsetCollapsable::latex(Buffer const * buf, ostream & os,
bool fragile, bool free_spc) const
{
///
void update(BufferView *, LyXFont const &, bool =false);
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView *, bool front = true);
///
///
int insetInInsetY() const;
///
- bool insetButtonRelease(BufferView *, int, int, int);
+ bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
///
- void insetButtonPress(BufferView *, int, int, int);
+ void insetButtonPress(BufferView *, int, int, mouse_button::state);
///
- void insetMotionNotify(BufferView *, int, int, int);
- ///
- void insetKeyPress(XKeyEvent *);
+ void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
string const &);
}
-void InsetError::edit(BufferView * bv, int, int, unsigned int)
+void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showError(this);
}
void InsetError::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
/// what appears in the minibuffer when opening
string const editMessage() const;
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
}
}
-
-void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
+void InsetERT::edit(BufferView * bv, int x, int y, mouse_button::state button)
{
- if (button == 3)
+ if (button == mouse_button::button3)
return;
if (status_ == Inlined) {
void InsetERT::insetButtonPress(BufferView * bv,
- int x, int y, int button)
+ int x, int y, mouse_button::state button)
{
if (status_ == Inlined) {
inset.insetButtonPress(bv, x, y, button);
}
-bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button)
+bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y,
+ mouse_button::state button)
{
- if (button == 3) {
+ if (button == mouse_button::button3) {
showInsetDialog(bv);
return true;
}
void InsetERT::insetMotionNotify(BufferView * bv,
- int x, int y, int state)
+ int x, int y, mouse_button::state state)
{
if (status_ == Inlined) {
inset.insetMotionNotify(bv, x, y, state);
void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
///
SigC::Signal0<void> hideDialog;
///
- void insetButtonPress(BufferView *, int x, int y, int button);
+ void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
///
- bool insetButtonRelease(BufferView * bv, int x, int y, int button);
+ bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
///
- void insetMotionNotify(BufferView *, int x, int y, int state);
+ void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
///
int latex(Buffer const *, std::ostream &, bool fragile,
bool free_spc) const;
void InsetExternal::edit(BufferView * bv,
- int /*x*/, int /*y*/, unsigned int /*button*/)
+ int /*x*/, int /*y*/, mouse_button::state)
{
view_ = bv;
view_->owner()->getDialogs()->showExternal(this);
void InsetExternal::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
/// what appears in the minibuffer when opening
virtual string const editMessage() const;
///
- virtual void edit(BufferView *, int x, int y, unsigned int button);
+ virtual void edit(BufferView *, int x, int y, mouse_button::state button);
///
virtual void edit(BufferView * bv, bool front = true);
///
}
-void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
+void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showTOC(this);
}
void InsetFloatList::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
string const getScreenLabel(Buffer const *) const;
///
- void edit(BufferView * bv, int, int, unsigned int);
+ void edit(BufferView * bv, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
}
-void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
+void InsetGraphics::edit(BufferView *bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showGraphics(this);
}
void InsetGraphics::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
}
-void InsetInclude::edit(BufferView * bv, int, int, unsigned int)
+void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showInclude(this);
}
void InsetInclude::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
/// This returns the list of bibkeys on the child buffer
std::vector< std::pair<string,string> > const getKeys() const;
///
- void edit(BufferView *, int x, int y, unsigned int button);
+ void edit(BufferView *, int x, int y, mouse_button::state button);
///
void edit(BufferView * bv, bool front = true);
///
}
-void InsetIndex::edit(BufferView * bv, int, int, unsigned int)
+void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showIndex(this);
}
void InsetIndex::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
EDITABLE editable() const { return IS_EDITABLE; }
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
/// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const;
///
- void edit(BufferView *, int, int, unsigned int) {}
+ void edit(BufferView *, int, int, mouse_button::state) {}
///
void edit(BufferView *, bool = true) {}
///
}
-void InsetLabel::edit(BufferView * bv, int, int, unsigned int)
+void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
{
pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents());
if (result.first) {
void InsetLabel::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
Inset::Code lyxCode() const { return Inset::LABEL_CODE; }
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
}
-void InsetParent::edit(BufferView * bv, int, int, unsigned int)
-{
+void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
+{
bv->owner()->getLyXFunc()->
dispatch(LFUN_CHILDOPEN, getContents());
}
void InsetParent::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
Inset::Code lyxCode() const { return Inset::PARENT_CODE; }
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
: InsetCommand(p), isLatex(buf.isLatex())
{}
-void InsetRef::edit(BufferView * bv, int, int, unsigned int button)
+void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
{
// Eventually trigger dialog with button 3 not 1
- if (button == 3)
+ if (button == mouse_button::button3)
bv->owner()->getLyXFunc()->
dispatch(LFUN_REF_GOTO, getContents());
- else if (button == 1)
+ else if (button == mouse_button::button1)
bv->owner()->getDialogs()->showRef(this);
}
///
Inset::Code lyxCode() const { return Inset::REF_CODE; }
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
}
-void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
+void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button)
{
UpdatableInset::edit(bv, x, y, button);
setPos(bv, x, y);
clearSelection();
finishUndo();
- if (insetHit(bv, x, y) && (button != 3)) {
+ if (insetHit(bv, x, y) && (button != mouse_button::button3)) {
activateCellInsetAbs(bv, x, y, button);
}
}
}
-void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
+void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button)
{
- if (hasSelection() && (button == 3))
+ if (hasSelection() && (button == mouse_button::button3))
return;
if (hasSelection()) {
updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
- if (button == 2) {
+ if (button == mouse_button::button2) {
localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
return;
}
bool InsetTabular::insetButtonRelease(BufferView * bv,
- int x, int y, int button)
+ int x, int y, mouse_button::state button)
{
bool ret = false;
if (the_locking_inset)
ret = the_locking_inset->insetButtonRelease(bv, x - inset_x,
y - inset_y, button);
- if (button == 3 && !ret) {
+ if (button == mouse_button::button3 && !ret) {
bv->owner()->getDialogs()->showTabular(this);
return true;
}
}
-void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
+void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state button)
{
if (the_locking_inset) {
the_locking_inset->insetMotionNotify(bv,
}
-void InsetTabular::insetKeyPress(XKeyEvent * xke)
-{
- if (the_locking_inset) {
- the_locking_inset->insetKeyPress(xke);
- return;
- }
-}
-
-
UpdatableInset::RESULT
InsetTabular::localDispatch(BufferView * bv, kb_action action,
string const & arg)
if (!moved)
return FINISHED;
if (lock) { // behind the inset
- if (activateCellInset(bv, 0, 0, 0, true))
+ if (activateCellInset(bv, 0, 0, mouse_button::none, true))
return DISPATCHED;
}
resetPos(bv);
if (lock) {
bool rtl = tabular->GetCellInset(actcell)->paragraph()->
isRightToLeftPar(bv->buffer()->params);
- activateCellInset(bv, 0, 0, 0, !rtl);
+ activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
}
resetPos(bv);
return true;
if (lock) {
bool rtl = tabular->GetCellInset(actcell)->paragraph()->
isRightToLeftPar(bv->buffer()->params);
- activateCellInset(bv, 0, 0, 0, !rtl);
+ activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
}
resetPos(bv);
return true;
}
-bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
+bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button::state button,
bool behind)
{
UpdatableInset * inset =
bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
- int button)
+ mouse_button::state button)
{
inset_x = cursor_.x()
- top_x + tabular->GetBeginningOfTextInCell(actcell);
// otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv, 0, 0, 0);
+ inset->edit(bv, 0, 0, mouse_button::none);
string const str(selectNextWordInt(bv, value));
nodraw(false);
if (!str.empty())
///
string const editMessage() const;
///
- void edit(BufferView *, int x, int y, unsigned int);
+ void edit(BufferView *, int x, int y, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
///
bool display() const { return tabular->IsLongTabular(); }
///
- bool insetButtonRelease(BufferView *, int, int, int);
+ bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
///
- void insetButtonPress(BufferView *, int, int, int);
+ void insetButtonPress(BufferView *, int, int, mouse_button::state);
///
- void insetMotionNotify(BufferView *, int, int, int);
- ///
- void insetKeyPress(XKeyEvent *);
+ void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
string const &);
}
///
bool activateCellInset(BufferView *, int x = 0, int y = 0,
- int button = 0,
+ mouse_button::state button = mouse_button::none,
bool behind = false);
///
bool activateCellInsetAbs(BufferView *, int x = 0, int y = 0,
- int button = 0);
+ mouse_button::state button = mouse_button::none);
///
bool insetHit(BufferView * bv, int x, int y) const;
///
}
-void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
+void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button)
{
UpdatableInset::edit(bv, x, y, button);
// we put here -1 and not button as now the button in the
// edit call should not be needed we will fix this in 1.3.x
// cycle hopefully (Jug 20020509)
- if (!checkAndActivateInset(bv, x, tmp_y, -1)) {
+ // FIXME: GUII I've changed this to none: probably WRONG
+ if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) {
lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent);
lt->cursor.x_fix(lt->cursor.x());
}
-void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
+void InsetText::insetButtonPress(BufferView * bv,
+ int x, int y, mouse_button::state button)
{
no_selection = true;
return;
}
}
- if (!inset) { // && (button == 2)) {
+ if (!inset) { // && (button == mouse_button::button2)) {
bool paste_internally = false;
- if ((button == 2) && getLyXText(bv)->selection.set()) {
+ if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) {
localDispatch(bv, LFUN_COPY, "");
paste_internally = true;
}
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,
// insert this
- if (button == 2) {
+ if (button == mouse_button::button2) {
if (paste_internally)
localDispatch(bv, LFUN_PASTE, "");
else
}
-bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
+bool InsetText::insetButtonRelease(BufferView * bv,
+ int x, int y, mouse_button::state button)
{
no_selection = true;
if (the_locking_inset) {
}
-void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
+void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state state)
{
if (the_locking_inset) {
the_locking_inset->insetMotionNotify(bv, x - inset_x,
}
-void InsetText::insetKeyPress(XKeyEvent * xke)
-{
- if (the_locking_inset) {
- the_locking_inset->insetKeyPress(xke);
- return;
- }
-}
-
-
UpdatableInset::RESULT
InsetText::localDispatch(BufferView * bv,
kb_action action, string const & arg)
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
- int button)
+ mouse_button::state button)
{
x -= drawTextXOffset;
int dummyx = x;
// we only do the edit() call if the inset was hit by the mouse
// or if it is a highly editable inset. So we should call this
// function from our own edit with button < 0.
- if (button < 0 && !isHighlyEditableInset(inset))
+ // FIXME: GUII jbl. I've changed this to ::none for now which is probably
+ // WRONG
+ if (button == mouse_button::none && !isHighlyEditableInset(inset))
return false;
if (inset) {
///
string const editMessage() const;
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView *, bool front = true);
///
///
bool updateInsetInInset(BufferView *, Inset *);
///
- bool insetButtonRelease(BufferView *, int, int, int);
+ bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
///
- void insetButtonPress(BufferView *, int, int, int);
+ void insetButtonPress(BufferView *, int, int, mouse_button::state);
///
- void insetMotionNotify(BufferView *, int, int, int);
- ///
- void insetKeyPress(XKeyEvent *);
+ void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
UpdatableInset::RESULT localDispatch(BufferView *,
kb_action, string const &);
bool checkAndActivateInset(BufferView * bv, bool front);
///
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
- int button = 0);
+ mouse_button::state button = mouse_button::none);
///
void removeNewlines();
///
}
-void InsetTOC::edit(BufferView * bv, int, int, unsigned int)
+void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showTOC(this);
}
void InsetTOC::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
string const getScreenLabel(Buffer const *) const;
///
- void edit(BufferView * bv, int, int, unsigned int);
+ void edit(BufferView * bv, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
{}
-void InsetUrl::edit(BufferView * bv, int, int, unsigned int)
+void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getDialogs()->showUrl(this);
}
void InsetUrl::edit(BufferView * bv, bool)
{
- edit(bv, 0, 0, 0);
+ edit(bv, 0, 0, mouse_button::none);
}
///
EDITABLE editable() const { return IS_EDITABLE; }
///
- void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-string const kb_keymap::printKeysym(unsigned int key, unsigned int mod)
+string const kb_keymap::printKeysym(unsigned int key, key_modifier::state mod)
{
string buf;
- mod &= ModsMask;
char const * const s = XKeysymToString(key);
- if (mod & ShiftMask) buf += "S-";
- if (mod & ControlMask) buf += "C-";
- if (mod & Mod1Mask) buf += "M-";
+ if (mod & key_modifier::shift) buf += "S-";
+ if (mod & key_modifier::ctrl) buf += "C-";
+ if (mod & key_modifier::alt) buf += "M-";
if (s) buf += s;
return buf;
}
string const kb_keymap::printKey(kb_key const & key) const
{
- return printKeysym(key.code, key.mod & 0xffff);
+ return printKeysym(key.code, key.mod.first);
}
int kb_keymap::lookup(unsigned int key,
- unsigned int mod, kb_sequence * seq) const
+ key_modifier::state mod, kb_sequence * seq) const
{
if (table.empty()) {
seq->curmap = seq->stdmap;
return LFUN_UNKNOWN_ACTION;
}
- //suppress modifier bits we do not handle
- mod &= ModsMask;
-
for (Table::const_iterator cit = table.begin();
cit != table.end(); ++cit) {
- unsigned int const msk1 = cit->mod & 0xffff;
- unsigned int const msk0 = (cit->mod >> 16) & 0xffff;
- if (cit->code == key && (mod & ~msk0) == msk1) {
+ key_modifier::state mask(cit->mod.second);
+ key_modifier::state check =
+ static_cast<key_modifier::state>(mod & ~mask);
+
+ if (cit->code == key && cit->mod.first == check) {
// match found
if (cit->table.get()) {
// this is a prefix key - set new map
unsigned int const code = seq->sequence[r];
if (code == NoSymbol) return;
- unsigned int const modmsk = seq->modifiers[r];
+ key_modifier::state const mod1 = seq->modifiers[r].first;
+ key_modifier::state const mod2 = seq->modifiers[r].second;
// check if key is already there
for (Table::iterator it = table.begin(); it != table.end(); ++it) {
- if (code == it->code && modmsk == it->mod) {
+ if (code == it->code && mod1 == it->mod.first && mod2 == it->mod.second) {
// overwrite binding
if (r + 1 == seq->length()) {
lyxerr[Debug::KBMAP]
Table::iterator newone = table.insert(table.end(), kb_key());
newone->code = code;
- newone->mod = modmsk;
+ newone->mod = seq->modifiers[r];
if (r + 1 == seq->length()) {
newone->action = action;
newone->table.reset();
#endif
#include "LString.h"
+#include "frontends/key_state.h"
#include <boost/shared_ptr.hpp>
* @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
*/
int lookup(unsigned int key,
- unsigned int mod, kb_sequence * seq) const;
+ key_modifier::state mod, kb_sequence * seq) const;
/// Given an action, find all keybindings.
string const findbinding(int action,
* @param key the key
* @param mod the modifiers
*/
- static string const printKeysym(unsigned int key, unsigned int mod);
+ static string const printKeysym(unsigned int key, key_modifier::state mod);
/// return the ISO value of a keysym
static char getiso(unsigned int i);
private:
+ typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
+
///
struct kb_key {
/// Keysym
unsigned int code;
/// Modifier masks
- unsigned int mod;
+ modifier_pair mod;
/// Keymap for prefix keys
boost::shared_ptr<kb_keymap> table;
#pragma implementation
#endif
+#include "frontends/mouse_state.h"
#include "kbsequence.h"
#include "kbmap.h"
#include "commandtags.h"
#include "debug.h"
+using std::make_pair;
using std::vector;
using std::endl;
using std::hex;
enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
+int kb_sequence::addkey(unsigned int key, key_modifier::state mod, key_modifier::state nmod)
{
// adding a key to a deleted sequence
// starts a new sequence
modifiers.clear();
}
- modifiers.push_back(mod + (nmod << 16));
+ modifiers.push_back(make_pair(mod, nmod));
sequence.push_back(key);
++length_;
if (s.empty()) return 1;
string::size_type i = 0;
- unsigned int mod = 0;
- unsigned int nmod = 0;
+ key_modifier::state mod = key_modifier::none;
+ key_modifier::state nmod = key_modifier::none;
while (i < s.length()) {
if (s[i] == ' ')
++i;
if (i + 1 < s.length() && s[i + 1] == '-') {
switch (s[i]) {
case 's': case 'S':
- mod |= ShiftMask;
+ mod |= key_modifier::shift;
i += 2;
continue;
case 'c': case 'C':
- mod |= ControlMask;
+ mod |= key_modifier::ctrl;
i += 2;
continue;
case 'm': case 'M':
- mod |= Mod1Mask;
+ mod |= key_modifier::alt;
i += 2;
continue;
default:
&& s[i + 2] == '-') {
switch (s[i + 1]) {
case 's': case 'S':
- nmod |= ShiftMask;
+ nmod |= key_modifier::shift;
i += 3;
continue;
case 'c': case 'C':
- nmod |= ControlMask;
+ nmod |= key_modifier::ctrl;
i += 3;
continue;
case 'm': case 'M':
- nmod |= Mod1Mask;
+ nmod |= key_modifier::alt;
i += 3;
continue;
default:
i = j;
addkey(key, mod, nmod);
- mod = 0;
+ mod = key_modifier::none;
}
}
// return buf;
for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
- buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff);
+ buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
// append a blank
if (i + 1 < length_) {
#pragma interface
#endif
-#include <vector>
+#include <config.h>
+
+#include "frontends/key_state.h"
#include "LString.h"
+#include <vector>
+
class kb_keymap;
/// Holds a key sequence and the current and standard keymaps
/**
* Add a key to the key sequence and look it up in the curmap
* if the latter is defined.
+ * @param text the text from the key event
* @param mod modifier mask
* @param nmod which modifiers to mask out for equality test
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
*/
- int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
+ int addkey(unsigned int text, key_modifier::state mod,
+ key_modifier::state nmod = key_modifier::none);
/**
* Add a sequence of keys from a string to the sequence
*/
std::vector<unsigned int> sequence;
+ typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
/// modifiers for keys in the sequence
- std::vector<unsigned int> modifiers;
+ std::vector<modifier_pair> modifiers;
/// Current length of key sequence
std::vector<unsigned int>::size_type length_;
keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
{
- meta_fake_bit = 0;
+ meta_fake_bit = key_modifier::none;
lyx_dead_action = LFUN_NOACTION;
lyx_calling_dead_action = LFUN_NOACTION;
}
}
-void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
+void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state)
{
string argument;
lyxerr << "KeySym is "
<< stm
<< "["
- << keysym << "] State is ["
- << state << "]"
+ << keysym
<< endl;
}
// Do nothing if we have nothing (JMarc)
// cancel and meta-fake keys. RVDK_PATCH_5
cancel_meta_seq.reset();
- int action = cancel_meta_seq.addkey(keysym, state
- &(ShiftMask|ControlMask
- |Mod1Mask));
+ int action = cancel_meta_seq.addkey(keysym, state);
if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "action first set to [" << action << "]" << endl;
}
// When not cancel or meta-fake, do the normal lookup.
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
- // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
+ // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
+#if 0
if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "meta_fake_bit is ["
<< meta_fake_bit << "]" << endl;
}
+#endif
// remove Caps Lock and Mod2 as a modifiers
- action = keyseq.addkey(keysym,
- (state | meta_fake_bit)
- &(ShiftMask|ControlMask
- |Mod1Mask));
+ action = keyseq.addkey(keysym, (state | meta_fake_bit));
if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "action now set to ["
<< action << "]" << endl;
}
}
// Dont remove this unless you know what you are doing.
- meta_fake_bit = 0;
+ meta_fake_bit = key_modifier::none;
// can this happen now ?
if (action == LFUN_NOACTION) {
if (action == LFUN_UNKNOWN_ACTION) {
// It is unknown, but what if we remove all
// the modifiers? (Lgb)
- action = keyseq.addkey(keysym, 0);
+ action = keyseq.addkey(keysym, key_modifier::none);
if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "Removing modifiers...\n"
case LFUN_CANCEL: // RVDK_PATCH_5
keyseq.reset();
- meta_fake_bit = 0;
+ meta_fake_bit = key_modifier::none;
if (owner->view()->available())
// cancel any selection
dispatch(LFUN_MARK_OFF);
case LFUN_META_FAKE: // RVDK_PATCH_5
{
- meta_fake_bit = Mod1Mask;
+ meta_fake_bit = key_modifier::alt;
setMessage(keyseq.print());
}
break;
#include <X11/Xlib.h>
#include <sigc++/signal_system.h>
+#include "frontends/mouse_state.h"
+#include "frontends/key_state.h"
#include "commandtags.h" // for kb_action enum
#include "FuncStatus.h"
#include "kbsequence.h"
void initMiniBuffer();
///
- void processKeySym(KeySym k, unsigned int state);
+ void processKeySym(KeySym key, key_modifier::state state);
/// we need one internal which is called from inside LyXAction and
/// can contain the string argument.
///
kb_sequence cancel_meta_seq;
///
- unsigned meta_fake_bit;
+ key_modifier::state meta_fake_bit;
///
void moveCursorUpdate(bool flag = true, bool selecting = false);
///
inline
bool LyXFunc::wasMetaKey() const
{
- return (meta_fake_bit != 0);
+ return (meta_fake_bit != key_modifier::none);
}
+2002-05-26 John Levon <moz@compsoc.man.ac.uk>
+
+ * formulabase.C:
+ * formulabase.h:
+ * math_inset.h: use mouse_state. Kill insetKeyPress
+
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* math_support.C: font loader moved
#include "math_support.h"
#include "support/lstrings.h"
#include "frontends/LyXView.h"
-#include "frontends/Painter.h"
#include "frontends/font_metrics.h"
+#include "frontends/mouse_state.h"
#include "Lsstream.h"
#include "math_arrayinset.h"
#include "math_charinset.h"
delete new_inset;
return false;
}
- new_inset->edit(bv, 0, 0, 0);
+ new_inset->edit(bv, 0, 0, mouse_button::none);
return true;
}
}
-void InsetFormulaBase::edit(BufferView * bv, int x, int y, unsigned int)
+void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
{
if (!bv->lockInset(this))
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
- int /*x*/, int /*y*/, int button)
+ int /*x*/, int /*y*/, mouse_button::state button)
{
//lyxerr << "insetButtonRelease: " << x << " " << y << "\n";
showInsetCursor(bv);
bv->updateInset(this, false);
- if (button == 3) {
+ if (button == mouse_button::button3) {
// launch math panel for right mouse button
bv->owner()->getDialogs()->showMathPanel();
return true;
void InsetFormulaBase::insetButtonPress(BufferView * bv,
- int x, int y, int button)
+ int x, int y, mouse_button::state button)
{
//lyxerr << "insetButtonPress: "
// << x << " " << y << " but: " << button << "\n";
break;
}
#else
- if (button == 1 || !mathcursor) {
+ if (button == mouse_button::button1 || !mathcursor) {
delete mathcursor;
mathcursor = new MathCursor(this, x == 0);
metrics(bv);
void InsetFormulaBase::insetMotionNotify(BufferView * bv,
- int x, int y, int /*button*/)
+ int x, int y, mouse_button::state)
{
if (!mathcursor)
return;
}
-void InsetFormulaBase::insetKeyPress(XKeyEvent *)
-{
- lyxerr[Debug::MATHED] << "Used InsetFormulaBase::InsetKeyPress." << endl;
-}
-
-
UpdatableInset::RESULT
InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
string const & arg)
#include <iosfwd>
#include "insets/inset.h"
+#include "frontends/mouse_state.h"
#include "lyxfont.h"
// only for getType():
/// what appears in the minibuffer when opening
virtual string const editMessage() const;
///
- virtual void edit(BufferView *, int x, int y, unsigned int button);
+ virtual void edit(BufferView *, int x, int y, mouse_button::state button);
///
virtual void edit(BufferView *, bool front = true);
///
///
virtual void toggleInsetSelection(BufferView * bv);
///
- virtual void insetButtonPress(BufferView *, int x, int y, int button);
+ virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
///
- virtual bool insetButtonRelease(BufferView *, int x, int y, int button);
+ virtual bool insetButtonRelease(BufferView *, int x, int y, mouse_button::state button);
///
- virtual void insetKeyPress(XKeyEvent * ev);
- ///
- virtual void insetMotionNotify(BufferView *, int x, int y, int state);
+ virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
///
virtual void insetUnlock(BufferView *);
#pragma interface
#endif
+#include "frontends/mouse_state.h"
#include "math_xdata.h"
#include "math_defs.h"
virtual bool needsBraces() const { return true; }
///
- virtual void edit(BufferView *, int, int, unsigned int) {}
+ virtual void edit(BufferView *, int, int, mouse_button::state) {}
/// request "external features"
virtual void validate(LaTeXFeatures & features) const;
Inset * inset_hit =
bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit)) {
- inset_hit->edit(bview, x, y - (y2 - y1), 0);
+ inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
}
}
#else
Inset * inset_hit =
bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit)) {
- inset_hit->edit(bview, x, y - (y2 - y1), 0);
+ inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
}
}
#else