From cb15371de3d24873417e16e9b68f815bfc3dff11 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 8 Nov 2004 10:54:29 +0000 Subject: [PATCH] add possibility to specify the origin of a FuncRequest; use it to get rid of the "verbose" flag in dispatch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9205 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 14 +++++++++++ src/MenuBackend.C | 4 ++- src/ToolbarBackend.C | 1 + src/frontends/controllers/ChangeLog | 8 ++++++ .../controllers/ControlCommandBuffer.C | 4 ++- src/frontends/controllers/ControlRef.C | 4 +-- src/frontends/controllers/Kernel.C | 4 +-- src/frontends/controllers/Kernel.h | 4 +-- src/frontends/gtk/ChangeLog | 6 +++++ src/frontends/gtk/GMenubar.C | 2 +- src/frontends/gtk/GToolbar.C | 8 +++--- src/frontends/qt2/ChangeLog | 5 ++++ src/frontends/qt2/QLToolbar.C | 8 +++--- src/frontends/qt2/QtView.C | 2 +- src/frontends/xforms/ChangeLog | 6 +++++ src/frontends/xforms/XFormsMenubar.C | 2 +- src/frontends/xforms/XFormsToolbar.C | 8 +++--- src/funcrequest.C | 23 +++++++++-------- src/funcrequest.h | 25 ++++++++++++++----- src/kbmap.C | 1 + src/lyxfunc.C | 10 +++++--- src/lyxfunc.h | 4 +-- 22 files changed, 107 insertions(+), 46 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b3e2e373e0..0b60ab4ff0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2004-11-05 Jean-Marc Lasgouttes + + * lyxfunc.C (dispatch): remove the verbose argument + (sendDispatchMessage): ditto. Use the origin of the FuncRequest + instead + + * kbmap.C (defkey): set the origin of func to KEYBOARD + + * MenuBackend.C (MenuItem): + * ToolbarBackend.C (add): set the origin of func to UI + + * funcrequest.[Ch]: add origin member, which indicates which part + of LyX requests an action + 2004-11-07 Georg Baum * converter.C (move): don't lie in the error message diff --git a/src/MenuBackend.C b/src/MenuBackend.C index daa9cd040e..294599d1cf 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -105,7 +105,9 @@ MenuItem::MenuItem(Kind kind, string const & label, MenuItem::MenuItem(Kind kind, string const & label, FuncRequest const & func, bool optional) : kind_(kind), label_(label), func_(func), optional_(optional) -{} +{ + func_.origin = FuncRequest::UI; +} MenuItem::~MenuItem() diff --git a/src/ToolbarBackend.C b/src/ToolbarBackend.C index 1a616774cf..baa2ddfbcd 100644 --- a/src/ToolbarBackend.C +++ b/src/ToolbarBackend.C @@ -207,6 +207,7 @@ void ToolbarBackend::add(Toolbar & tb, FuncRequest const & func, string const & tooltip) { tb.items.push_back(make_pair(func, tooltip)); + tb.items.back().first.origin = FuncRequest::UI; } diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 58ffde7965..c9ef9cc8a6 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2004-11-05 Jean-Marc Lasgouttes + + * ControlRef.C (gotoRef, gotoBookmark): + * Kernel.C (dispatch): remove verbose argument + + * ControlCommandBuffer.C (dispatch): set origin of the lfun to + COMMANDBUFFER instead of using the old verbose argument to dispatch + 2004-10-29 Georg Baum * ControlInclude.C: s/getExtFromContents/getFormatFromContents/ diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index 68cdd703c1..c2951d69a0 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -130,7 +130,9 @@ void ControlCommandBuffer::dispatch(string const & str) history_.push_back(str); history_pos_ = history_.end(); - lv_.getLyXFunc().dispatch(lyxaction.lookupFunc(str), true); + FuncRequest func = lyxaction.lookupFunc(str); + func.origin = FuncRequest::COMMANDBUFFER; + lv_.getLyXFunc().dispatch(func); } } // namespace frontend diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index 61692c0f71..4a29acc379 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -47,14 +47,14 @@ vector const ControlRef::getLabelList(string const & name) const void ControlRef::gotoRef(string const & ref) { - kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false); + kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0")); kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref)); } void ControlRef::gotoBookmark() { - kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false); + kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0")); } diff --git a/src/frontends/controllers/Kernel.C b/src/frontends/controllers/Kernel.C index 3adb43ecaf..327ede82f3 100644 --- a/src/frontends/controllers/Kernel.C +++ b/src/frontends/controllers/Kernel.C @@ -30,9 +30,9 @@ Kernel::Kernel(LyXView & lyxview) {} -void Kernel::dispatch(FuncRequest const & fr, bool verbose) const +void Kernel::dispatch(FuncRequest const & fr) const { - lyxview_.getLyXFunc().dispatch(fr, verbose); + lyxview_.getLyXFunc().dispatch(fr); } diff --git a/src/frontends/controllers/Kernel.h b/src/frontends/controllers/Kernel.h index 7919a2fc20..c2526e3c45 100644 --- a/src/frontends/controllers/Kernel.h +++ b/src/frontends/controllers/Kernel.h @@ -37,10 +37,8 @@ public: * the "gateway" by which the dialog can send a request (of a * change in the data, for more information) to the kernel. * \param fr is the encoding of the request. - * \param verbose is set to true if the completed action should - * be displayed in the minibuffer. */ - void dispatch(FuncRequest const & fr, bool verbose = false) const; + void dispatch(FuncRequest const & fr) const; /** The dialog has received a request from the user * (who pressed the "Restore" buuton) to update contents. diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 0283904722..f1866ecb7f 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,9 @@ +2004-11-05 Jean-Marc Lasgouttes + + * GToolbar.C (selected, clicked): + * GMenubar.C (onCommandActivate): do not use the verbose argument + to dispatch + 2004-11-04 John Spray * GWorkArea.C: convert GdkEventButton->state from diff --git a/src/frontends/gtk/GMenubar.C b/src/frontends/gtk/GMenubar.C index 646947f47a..bd8bd8e6f0 100644 --- a/src/frontends/gtk/GMenubar.C +++ b/src/frontends/gtk/GMenubar.C @@ -208,7 +208,7 @@ void GMenubar::onSubMenuActivate(MenuItem const * item, void GMenubar::onCommandActivate(MenuItem const * item, Gtk::MenuItem * /*gitem*/) { - view_->getLyXFunc().dispatch(item->func(), true); + view_->getLyXFunc().dispatch(item->func()); } } // namespace frontend diff --git a/src/frontends/gtk/GToolbar.C b/src/frontends/gtk/GToolbar.C index da99d2c48b..caeaa43266 100644 --- a/src/frontends/gtk/GToolbar.C +++ b/src/frontends/gtk/GToolbar.C @@ -166,9 +166,9 @@ void GLayoutBox::selected() for (; it != end; ++it) { string const & name = (*it)->name(); if (name == layoutGuiName) { - owner_.getLyXFunc().dispatch( - FuncRequest(LFUN_LAYOUT, name), - true); + FunctRequest const func(LFUN_LAYOUT, name, + FuncRequest::UI); + owner_.getLyXFunc().dispatch(func); return; } } @@ -264,7 +264,7 @@ void GToolbar::add(FuncRequest const & func, string const & tooltip) void GToolbar::clicked(FuncRequest func) { - owner_.getLyXFunc().dispatch(func, true); + owner_.getLyXFunc().dispatch(func); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index b93e27aaf0..cfc738dce4 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2004-11-05 Jean-Marc Lasgouttes + + * QLToolbar.C (activated, clicked): + * QtView.C (activated): do not use the verbose argument to dispatch + 2004-11-08 Jürgen Spitzmüller * QPrefsDialog.C (new_format(), remove_format()): fix crash when diff --git a/src/frontends/qt2/QLToolbar.C b/src/frontends/qt2/QLToolbar.C index 72d4c2c16b..ce927eee24 100644 --- a/src/frontends/qt2/QLToolbar.C +++ b/src/frontends/qt2/QLToolbar.C @@ -155,9 +155,9 @@ void QLayoutBox::selected(const QString & str) string const & name = (*it)->name(); // Yes, the _() is correct if (_(name) == sel) { - owner_.getLyXFunc() - .dispatch(FuncRequest(LFUN_LAYOUT, name), - true); + FuncRequest const func(LFUN_LAYOUT, name, + FuncRequest::UI); + owner_.getLyXFunc().dispatch(func); return; } } @@ -261,7 +261,7 @@ void QLToolbar::clicked() ButtonMap::const_iterator it = map_.find(button); if (it != map_.end()) - owner_.getLyXFunc().dispatch(it->second, true); + owner_.getLyXFunc().dispatch(it->second); else lyxerr << "non existent tool button selected !" << endl; } diff --git a/src/frontends/qt2/QtView.C b/src/frontends/qt2/QtView.C index eefdfaf5de..7d3f2be43b 100644 --- a/src/frontends/qt2/QtView.C +++ b/src/frontends/qt2/QtView.C @@ -140,7 +140,7 @@ void QtView::update_view_state() void QtView::activated(FuncRequest const & func) { - getLyXFunc().dispatch(func, true); + getLyXFunc().dispatch(func); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index bf90f9985e..cd8e36b08d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2004-11-05 Jean-Marc Lasgouttes + + * XFormsToolbar.C (C_ToolbarCB, selected): + * XFormsMenubar.C (MenuCallback): do not use the verbose argument + to dispatch + 2004-11-06 Lars Gullik Bjonnes * RadioButtonGroup.C (set): use bind, equal_to instead of diff --git a/src/frontends/xforms/XFormsMenubar.C b/src/frontends/xforms/XFormsMenubar.C index 74a1d7843e..034aae29b1 100644 --- a/src/frontends/xforms/XFormsMenubar.C +++ b/src/frontends/xforms/XFormsMenubar.C @@ -400,7 +400,7 @@ void XFormsMenubar::MenuCallback(FL_OBJECT * ob, long button) // If the action value is too low, then it is not a // valid action, but something else. if (choice >= action_offset) { - view->getLyXFunc().dispatch(funcs[choice - action_offset], true); + view->getLyXFunc().dispatch(funcs[choice - action_offset]); } else { lyxerr[Debug::GUI] << "MenuCallback: ignoring bogus action " diff --git a/src/frontends/xforms/XFormsToolbar.C b/src/frontends/xforms/XFormsToolbar.C index bede7c00cf..44d8affc2f 100644 --- a/src/frontends/xforms/XFormsToolbar.C +++ b/src/frontends/xforms/XFormsToolbar.C @@ -276,7 +276,7 @@ void C_ToolbarCB(FL_OBJECT * ob, long ac) XFormsToolbar * ptr = static_cast(ob->u_vdata); XFormsView & owner = ptr->owner_; - owner.getLyXFunc().dispatch(ptr->funcs[ac], true); + owner.getLyXFunc().dispatch(ptr->funcs[ac]); } } // extern "C" @@ -528,9 +528,9 @@ void XLayoutBox::selected() for (; it != end; ++it) { string const & name = (*it)->name(); if (_(name) == layoutguiname) { - owner_.getLyXFunc() - .dispatch(FuncRequest(LFUN_LAYOUT, name), - true); + FuncRequest const func(LFUN_LAYOUT, name, + FuncRequest::UI); + owner_.getLyXFunc().dispatch(func); return; } } diff --git a/src/funcrequest.C b/src/funcrequest.C index 382ac4fa4a..3286d9329d 100644 --- a/src/funcrequest.C +++ b/src/funcrequest.C @@ -23,28 +23,31 @@ using std::vector; using std::string; -FuncRequest::FuncRequest() - : action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none) +FuncRequest::FuncRequest(Origin o) + : action(LFUN_NOACTION), origin(o), x(0), y(0), + button_(mouse_button::none) {} -FuncRequest::FuncRequest(kb_action act) - : action(act), x(0), y(0), button_(mouse_button::none) +FuncRequest::FuncRequest(kb_action act, Origin o) + : action(act), origin(o), x(0), y(0), button_(mouse_button::none) {} -FuncRequest::FuncRequest(kb_action act, string const & arg) - : action(act), argument(arg), x(0), y(0), button_(mouse_button::none) +FuncRequest::FuncRequest(kb_action act, string const & arg, Origin o) + : action(act), argument(arg), origin(o), x(0), y(0), + button_(mouse_button::none) {} -FuncRequest::FuncRequest(kb_action act, int ax, int ay, mouse_button::state but) - : action(act), x(ax), y(ay), button_(but) +FuncRequest::FuncRequest(kb_action act, int ax, int ay, + mouse_button::state but, Origin o) + : action(act), origin(o), x(ax), y(ay), button_(but) {} -FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg) - : action(cmd.action), argument(arg), +FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg, Origin o) + : action(cmd.action), argument(arg), origin(o), x(cmd.x), y(cmd.y), button_(cmd.button_) {} diff --git a/src/funcrequest.h b/src/funcrequest.h index d38ed13bfc..978eab20a9 100644 --- a/src/funcrequest.h +++ b/src/funcrequest.h @@ -25,16 +25,27 @@ */ class FuncRequest { public: - /// just for putting thes things in std::container - FuncRequest(); + /// Where the request came from + enum Origin { + INTERNAL, + UI, // The menu or the toolbar + KEYBOARD, // a keyboard binding + COMMANDBUFFER + }; + + /// just for putting these things in std::container + explicit FuncRequest(Origin o = INTERNAL); /// actions without extra argument - explicit FuncRequest(kb_action act); + explicit FuncRequest(kb_action act, Origin o = INTERNAL); /// actions without extra argument - FuncRequest(kb_action act, int x, int y, mouse_button::state button); + FuncRequest(kb_action act, int x, int y, mouse_button::state button, + Origin o = INTERNAL); /// actions with extra argument - FuncRequest(kb_action act, std::string const & arg); + FuncRequest(kb_action act, std::string const & arg, + Origin o = INTERNAL); /// for changing requests a bit - FuncRequest(FuncRequest const & cmd, std::string const & arg); + FuncRequest(FuncRequest const & cmd, std::string const & arg, + Origin o = INTERNAL); /// access to button mouse_button::state button() const; @@ -47,6 +58,8 @@ public: // should be private kb_action action; /// the action's std::string argument std::string argument; + /// who initiated the action + Origin origin; /// the x coordinate of a mouse press int x; /// the y coordinate of a mouse press diff --git a/src/kbmap.C b/src/kbmap.C index 9377be0c43..32fbdfd1c4 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -255,6 +255,7 @@ void kb_keymap::defkey(kb_sequence * seq, it->table.reset(); } it->func = func; + it->func.origin = FuncRequest::KEYBOARD; return; } else if (!it->table.get()) { lyxerr << "Error: New binding for '" << seq->print() diff --git a/src/lyxfunc.C b/src/lyxfunc.C index bbff9e1f5a..9995dcca01 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -588,7 +588,7 @@ void loadTextclass(string const & name) } //namespace anon -void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose) +void LyXFunc::dispatch(FuncRequest const & cmd) { string const argument = cmd.argument; kb_action const action = cmd.action; @@ -1463,18 +1463,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose) if (view()->cursor().inTexted()) { view()->owner()->updateLayoutChoice(); - sendDispatchMessage(getMessage(), cmd, verbose); + sendDispatchMessage(getMessage(), cmd); } } } -void LyXFunc::sendDispatchMessage(string const & msg, - FuncRequest const & cmd, bool verbose) +void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd) { owner->updateMenubar(); owner->updateToolbars(); + const bool verbose = (cmd.origin == FuncRequest::UI + || cmd.origin == FuncRequest::COMMANDBUFFER); + if (cmd.action == LFUN_SELFINSERT || !verbose) { lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl; if (!msg.empty()) diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 63a690f2a0..5b9a57bd7b 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -42,7 +42,7 @@ public: explicit LyXFunc(LyXView *); /// LyX dispatcher, executes lyx actions. - void dispatch(FuncRequest const &, bool verbose = false); + void dispatch(FuncRequest const &); /// return the status bar state string std::string const viewStatusMessage(); @@ -103,7 +103,7 @@ private: /// send a post-dispatch status message void sendDispatchMessage(std::string const & msg, - FuncRequest const & ev, bool verbose); + FuncRequest const & ev); // I think the following should be moved to BufferView. (Asger) /// -- 2.39.2