Rather than justify any of this, I'll just show it and let people
comment.

There's lots of things I don't really like (helpful comments are "why
not like this instead" not "this bit sucks"). "big picture" comments are
probably most useful

comments ?

john


? texput.log
? o
? lf.diff
? a.diff
? newfile8.lyx
? nmea.png
? newfile2.lyx
? newfile3.tex
? a.tex
? exemple.lyx
? a.lyx
? a.log
? cvs.log
? mb.diff
? lyx_posix_wrappers.tar.bz2
? xscreen.diff
? newfile3.lyx
? ; buffer-write-as
? physics18.lyx.gz
? physics18.lyx.gz.1
? newfile5.lyx
? poster.jpg
? lyxserver-guii.diff
? newfile1.lyx
? newfile4.lyx
? rh-magic.patch
? newfile7.lyx
? newfile6.lyx
? newfile9.lyx
? frontends/controllers/a.c
? frontends/controllers/a.diff
? frontends/qt2/cvs.log
? frontends/xforms/XWorkArea.new.C
? frontends/xforms/XWorkArea.new.h
? frontends/xforms/xscreen.new.C
? frontends/xforms/xw.diff
? frontends/xforms/a.diff
? frontends/xforms/XWorkArea.bak.C
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.273
diff -u -r1.273 BufferView_pimpl.C
--- BufferView_pimpl.C  28 Jul 2002 18:13:46 -0000      1.273
+++ BufferView_pimpl.C  31 Jul 2002 17:03:10 -0000
@@ -1815,10 +1815,6 @@
        break;
 
 
-       case LFUN_INSERT_LABEL:
-               MenuInsertLabel(bv_, argument);
-               break;
-
        case LFUN_REF_INSERT:
                if (argument.empty()) {
                        InsetCommandParams p("ref");
@@ -2035,22 +2031,6 @@
                update(lt,
                       BufferView::SELECT|BufferView::FITCUR);
                lt->cursorEnd(bv_);
-               finishUndo();
-               moveCursorUpdate(false);
-               owner_->view_state_changed();
-       }
-       break;
-
-       case LFUN_SHIFT_TAB:
-       case LFUN_TAB:
-       {
-               LyXText * lt = bv_->getLyXText();
-
-               if (!lt->selection.mark())
-                       beforeChange(lt);
-               update(lt,
-                      BufferView::SELECT|BufferView::FITCUR);
-               lt->cursorTab(bv_);
                finishUndo();
                moveCursorUpdate(false);
                owner_->view_state_changed();
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.847
diff -u -r1.847 ChangeLog
--- ChangeLog   30 Jul 2002 22:58:54 -0000      1.847
+++ ChangeLog   31 Jul 2002 17:03:33 -0000
@@ -1,3 +1,7 @@
+2002-07-31  John Levon  <[EMAIL PROTECTED]>
+
+       * LyXAction.C: "Tabular" -> "Table" 
+ 
 2002-07-30  John Levon  <[EMAIL PROTECTED]>
 
        * lyxfunc.C: disable character dialog in ERT inset (partial fix)
Index: LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.125
diff -u -r1.125 LyXAction.C
--- LyXAction.C 28 Jul 2002 22:50:02 -0000      1.125
+++ LyXAction.C 31 Jul 2002 17:03:36 -0000
@@ -368,9 +368,9 @@
                { LFUN_DIALOG_TABULAR_INSERT, "dialog-tabular-insert",
                  N_("Insert Table"), Noop },
                { LFUN_TABULAR_FEATURE, "tabular-feature",
-                 N_("Tabular Features"), Noop },
+                 N_("Table settings"), Noop },
                { LFUN_INSET_TABULAR, "tabular-insert",
-                 N_("Insert a new Tabular Inset"), Noop },
+                 N_("Insert a new table"), Noop },
 #if 0
                { LFUN_INSET_THEOREM, "theorem-insert", "", Noop },
 #endif
Index: LyXAction.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.h,v
retrieving revision 1.16
diff -u -r1.16 LyXAction.h
--- LyXAction.h 21 Mar 2002 17:25:08 -0000      1.16
+++ LyXAction.h 31 Jul 2002 17:03:37 -0000
@@ -123,4 +123,6 @@
        mutable arg_map lyx_arg_map;
 };
 
-#endif
+extern LyXAction lyxaction;
+ 
+#endif // LYXACTION_H
Index: Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v
retrieving revision 1.134
diff -u -r1.134 Makefile.am
--- Makefile.am 21 Jul 2002 15:51:03 -0000      1.134
+++ Makefile.am 31 Jul 2002 17:03:37 -0000
@@ -92,11 +92,15 @@
        Thesaurus.h \
        ToolbarDefaults.C \
        ToolbarDefaults.h \
+       action.h \
+       action.C \
        box.h \
        box.C \
        broken_headers.h \
        buffer.C \
        buffer.h \
+       buffer_actions.h \
+       buffer_actions.C \
        bufferlist.C \
        bufferlist.h \
        bufferparams.C \
@@ -134,6 +138,8 @@
        layout.h \
        lengthcommon.C \
        lengthcommon.h \
+       lv_actions.h \
+       lv_actions.C \
        lyx_cb.C \
        lyx_cb.h \
        lyx_main.C \
Index: MenuBackend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v
retrieving revision 1.47
diff -u -r1.47 MenuBackend.C
--- MenuBackend.C       25 Jul 2002 02:23:13 -0000      1.47
+++ MenuBackend.C       31 Jul 2002 17:03:38 -0000
@@ -34,7 +34,6 @@
 #include "support/lyxfunctional.h"
 #include "support/lstrings.h"
 
-extern LyXAction lyxaction;
 extern BufferList bufferlist;
 
 using std::endl;
Index: ToolbarDefaults.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ToolbarDefaults.C,v
retrieving revision 1.30
diff -u -r1.30 ToolbarDefaults.C
--- ToolbarDefaults.C   16 Jul 2002 21:17:08 -0000      1.30
+++ ToolbarDefaults.C   31 Jul 2002 17:03:38 -0000
@@ -24,7 +24,6 @@
 
 using std::endl;
 
-extern LyXAction lyxaction;
 ToolbarDefaults toolbardefaults;
 
 namespace {
Index: action.C
===================================================================
RCS file: action.C
diff -N action.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ action.C    31 Jul 2002 17:03:40 -0000
@@ -0,0 +1,182 @@
+/**
+ * \file action.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Handling of actions. An action is any event or 
+ * internal change.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#include "action.h"
+ 
+#include "frontends/LyXView.h"
+#include "LyXAction.h"
+#include "BufferView.h"
+#include "buffer.h"
+#include "lyxfunc.h"
+#include "gettext.h"
+#include "debug.h"
+
+#include <algorithm>
+ 
+using std::endl;
+using std::pair;
+using std::make_pair;
+ 
+action actions;
+action::context action::next_context = action::buffer_context + 1; 
+
+ 
+action::result::result()
+       : failed(false), message(""), post_action(LFUN_NOACTION)
+{
+}
+
+ 
+action::result::result(char const * str)
+       : failed(false), message(str), post_action(LFUN_NOACTION)
+{
+}
+
+ 
+action::result::result(string const & str, bool f, int post)
+       : failed(f), message(str), post_action(post)
+{
+}
+
+ 
+action::context action::get_context() const
+{
+       return next_context++;
+}
+ 
+ 
+void action::add(action::context context, int action, action::handler_base const * 
+def)
+{
+       if (find(context, action)) {
+               lyxerr << "already defined !" << endl;
+               return;
+       }
+
+       action_map[action][context] = def;
+}
+ 
+
+action::handler_base const * action::find(action::context context, int action)
+{
+       action_map_t::const_iterator it(action_map.find(action));
+       if (it == action_map.end())
+               return 0;
+
+       context_action_map_t::const_iterator it2(it->second.find(context));
+       if (it2 == it->second.end())
+               return 0;
+ 
+       return it2->second;
+}
+
+ 
+action::handler_base const * action::bv_find(int action)
+{
+       handler_base const * def = find(buffer_context, action);
+       if (!def)
+               def = find(lyxview_context, action);
+       return def;
+}
+
+ 
+pair<Inset *, action::handler_base const *> action::find(BufferView & bv, int action)
+{
+       if (!bv.theLockingInset()) {
+               return make_pair((Inset*)0, bv_find(action));
+       }
+
+       // if override is set, the immediate inset parent can snatch the
+       // action away from the real locking inset. For example, pressing
+       // "tab" activates the table, not the inner insettext.
+       Inset * i(bv.theLockingInset());
+       handler_base const * parent_def = 0;
+       if (i->owner())
+               parent_def = find(i->owner()->context_code(), action);
+       if (parent_def && (parent_def->flags() & action::override))
+               return make_pair(i->owner(), parent_def);
+
+       handler_base const * def = find(i->context_code(), action);
+       if (!def)
+               return make_pair((Inset *)0, bv_find(action));
+       return make_pair(i, def);
+}
+
+ 
+FuncStatus action::status(BufferView & bv, int action, bool & found)
+{
+       FuncStatus status;
+ 
+       LyXFunc * func = bv.owner()->getLyXFunc();
+ 
+       // FIXME: should be passing message as part of FuncStatus
+       if (action == LFUN_NOACTION) {
+               func->setStatusMessage(N_("Nothing to do"));
+               found = true;
+               return status.disabled(true);
+       }
+
+       if (action == LFUN_UNKNOWN_ACTION) {
+               func->setStatusMessage(N_("Unknown action"));
+               found = true;
+               return status.unknown(true);
+       }
+
+       // the default error message if we disable the command
+       func->setStatusMessage(N_("Command disabled"));
+
+       Buffer const * buffer(bv.buffer());
+       
+       // check whether we need a buffer
+       if (!lyxaction.funcHasFlag(kb_action(action), LyXAction::NoBuffer)) {
+               if (!buffer) {
+                       func->setStatusMessage(N_("Command not allowed without any 
+document open"));
+                       found = true;
+                       return status.disabled(true);
+               }
+ 
+               // check if we need a rw document
+               bool const ro = buffer->isReadonly();
+               if (ro && !lyxaction.funcHasFlag(kb_action(action), 
+LyXAction::ReadOnly)) {
+                       func->setStatusMessage(N_("Document is read-only"));
+                       found = true;
+                       return status.disabled(true);
+               }
+       }
+
+       // Now fall through to the new code.
+ 
+       pair<Inset *, handler_base const *> h(find(bv, action));
+       if (!h.second)
+               return status;
+
+       found = true;
+       return h.second->get_status(bv, h.first);
+}
+
+
+action::result action::dispatch(BufferView & bv, int action, string const & arg, bool 
+& found)
+{
+       pair<Inset *, handler_base const *> h(find(bv, action));
+
+       if (!h.second)
+               return result();
+ 
+       found = true;
+       action::result result;
+ 
+       result = (*h.second)(bv, h.first, arg);
+       if (result.post_action != LFUN_NOACTION) {
+               handler_base const * def(bv_find(result.post_action));
+               if (def)
+                       (*def)(bv, h.first, arg);
+       }
+       return result;
+}
Index: action.h
===================================================================
RCS file: action.h
diff -N action.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ action.h    31 Jul 2002 17:03:40 -0000
@@ -0,0 +1,84 @@
+/**
+ * \file action.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Handling of actions. An action is any event or 
+ * internal change.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#ifndef ACTION_H
+#define ACTION_H
+
+#include <config.h>
+
+#include <map> 
+#include <utility>
+ 
+#include "LString.h"
+#include "FuncStatus.h"
+ 
+class BufferView;
+class Inset;
+ 
+class action {
+public:
+       struct result {
+               result::result();
+               result::result(char const * str);
+               result::result(string const & str, bool failed = false, int = 0);
+               bool failed;
+               string message;
+               int post_action;
+       };
+ 
+       enum handler_flags {
+               no_flags = 0,
+               override = 1,
+       };
+ 
+       struct handler_base {
+               virtual result operator()(BufferView &, Inset *, string const &) const 
+{ return result(); }
+               virtual FuncStatus get_status(BufferView &, Inset *) const { return 
+FuncStatus(); }
+               virtual handler_flags flags() const { return no_flags; }
+       };
+
+       typedef unsigned int context;
+ 
+       static context const no_context = 0;
+       static context const lyxview_context = 1;
+       static context const buffer_context = 2;
+       static context next_context;
+ 
+       action::action() {};
+ 
+       context get_context() const;
+ 
+       void add(context context, int action, handler_base const * def);
+
+       handler_base const * find(context context, int action);
+
+       handler_base const * bv_find(int action);
+
+       std::pair<Inset *, handler_base const *> find(BufferView & bv, int action);
+ 
+       FuncStatus status(BufferView & bv, int, bool & found);
+ 
+       result dispatch(BufferView & bv, int, string const & arg, bool & found);
+
+private:
+       typedef std::map<context, handler_base const *> context_action_map_t;
+ 
+       typedef std::map<int, context_action_map_t> action_map_t;
+
+       action_map_t action_map;
+
+       BufferView * bv_;
+};
+
+/// singleton instance
+extern action actions;
+ 
+#endif // ACTION_H
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.358
diff -u -r1.358 buffer.C
--- buffer.C    28 Jul 2002 22:50:03 -0000      1.358
+++ buffer.C    31 Jul 2002 17:03:50 -0000
@@ -138,8 +138,6 @@
 // all these externs should eventually be removed.
 extern BufferList bufferlist;
 
-extern LyXAction lyxaction;
-
 namespace {
 
 const int LYX_FORMAT = 220;
Index: buffer_actions.C
===================================================================
RCS file: buffer_actions.C
diff -N buffer_actions.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ buffer_actions.C    31 Jul 2002 17:03:50 -0000
@@ -0,0 +1,124 @@
+/**
+ * \file buffer_actions.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Actions on a particular buffer
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#include <config.h>
+ 
+#include "gettext.h"
+#include "support/lstrings.h"
+#include "buffer_actions.h"
+#include "action.h"
+#include "lyxrc.h"
+#include "BufferView.h"
+#include "undo_funcs.h"
+#include "lyxtext.h"
+#include "paragraph.h"
+#include "lyxlayout_ptr_fwd.h"
+#include "lyxlayout.h"
+#include "insets/insetlabel.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
+
+using std::pair;
+ 
+namespace buffer_actions {
+
+struct lfun_insert_label : public action::handler_base {
+       virtual action::result operator()(BufferView & bv, Inset *, string const & 
+arg) const {
+               string label(arg);
+ 
+               if (label.empty()) {
+                       Paragraph * par = bv.getLyXText()->cursor.par();
+                       LyXLayout_ptr layout = par->layout();
+                       if (layout->latextype == LATEX_PARAGRAPH && par->previous()) {
+                               Paragraph * par2 = par->previous();
+                               LyXLayout_ptr const & layout2 = par2->layout();
+
+                               if (layout2->latextype != LATEX_PARAGRAPH) {
+                                       par = par2;
+                                       layout = layout2;
+                               }
+                       }
+        
+                       string const name = layout->latexname();
+                       LYX_LATEX_TYPES const type = layout->latextype;
+                        
+                       string text = name.substr(0, 3);
+        
+                       // Create a correct prefix for prettyref
+                       if (layout->latexname() == "theorem")
+                               text = "thm";
+
+                       text += ":";
+        
+                       // FIXME: label_init_length ? Are you kidding ??
+                       if (type == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
+                               text.erase();
+        
+                       string par_text = par->asString(bv.buffer(), false);
+                       for (int i = 0; i < lyxrc.label_init_length; ++i) {
+                               if (par_text.empty())
+                                       break;
+                               string head;
+                               par_text = split(par_text, head, ' ');
+                               if (i > 0)
+                                       text += '-';
+                               text += head;
+                       }
+                       label = text;
+               }
+        
+               if (label.empty()) {
+                       pair<bool, string> result =
+                               Alert::askForText(_("Enter new label to insert:"), 
+label);
+                       if (result.first) {
+                               label = trim(result.second);
+                       } else {
+                               return action::result(_("Cancelled"), true);
+                       }
+               }
+ 
+               InsetCommandParams p("label", label);
+               InsetLabel * inset = new InsetLabel(p);
+               bv.insertInset(inset);
+               return action::result(); 
+       }
+
+       virtual FuncStatus status_insert_label(BufferView &, Inset * inset) const {
+               FuncStatus status;
+               status.disabled(inset && !inset->insetAllowed(Inset::LABEL_CODE));
+               return status;
+       }
+} lfun_insert_label;
+
+
+struct lfun_tab : public action::handler_base {
+       virtual action::result operator()(BufferView & bv, Inset *, string const &) 
+const {
+               LyXText * lt = bv.getLyXText();
+               if (!lt->selection.mark())
+                       bv.beforeChange(lt);
+               bv.update(lt, BufferView::SELECT | BufferView::FITCUR);
+               lt->cursorTab(&bv);
+               finishUndo();
+               // FIXME bv.moveCursorUpdate(false);
+               bv.owner()->view_state_changed();
+               return action::result(); 
+       }
+} lfun_tab;
+ 
+
+void init()
+{
+       actions.add(action::buffer_context, LFUN_INSERT_LABEL, &lfun_insert_label);
+       actions.add(action::buffer_context, LFUN_TAB, &lfun_tab);
+       actions.add(action::buffer_context, LFUN_SHIFT_TAB, &lfun_tab);
+}
+ 
+};
Index: buffer_actions.h
===================================================================
RCS file: buffer_actions.h
diff -N buffer_actions.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ buffer_actions.h    31 Jul 2002 17:03:50 -0000
@@ -0,0 +1,20 @@
+/**
+ * \file buffer_actions.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Actions on a particular buffer
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#ifndef BUFFER_ACTIONS_H
+#define BUFFER_ACTIONS_H
+
+namespace buffer_actions {
+
+       void init();
+
+};
+ 
+#endif // BUFFER_ACTIONS_H
Index: lv_actions.C
===================================================================
RCS file: lv_actions.C
diff -N lv_actions.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lv_actions.C        31 Jul 2002 17:03:52 -0000
@@ -0,0 +1,47 @@
+/**
+ * \file lv_actions.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * LyXView-wide actions.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#include "lv_actions.h"
+#include "action.h"
+#include "gettext.h"
+#include "BufferView.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+
+namespace lv_actions {
+
+struct lfun_math_panel : public action::handler_base {
+       action::result operator()(BufferView & bv, Inset *, string const &) const {
+               bv.owner()->getDialogs()->showMathPanel();
+               return _("Shown math panel.");
+       }
+} lfun_math_panel;
+
+struct lfun_tooltips_toggle : public action::handler_base {
+       action::result operator()(BufferView & bv, Inset *, string const &) const {
+               bv.owner()->getDialogs()->toggleTooltips();
+               return _("Tooltips toggled.");
+       }
+
+       FuncStatus get_status(BufferView & bv, Inset *) const {
+               FuncStatus status;
+               status.setOnOff(bv.owner()->getDialogs()->tooltipsEnabled());
+               return status;
+       }
+} lfun_tooltips_toggle;
+
+
+void init()
+{
+       actions.add(action::lyxview_context, LFUN_MATH_PANEL, &lfun_math_panel);
+       actions.add(action::lyxview_context, LFUN_TOOLTIPS_TOGGLE, 
+&lfun_tooltips_toggle);
+}
+ 
+};
Index: lv_actions.h
===================================================================
RCS file: lv_actions.h
diff -N lv_actions.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lv_actions.h        31 Jul 2002 17:03:52 -0000
@@ -0,0 +1,20 @@
+/**
+ * \file lv_actions.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * LyXView-wide actions.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#ifndef LV_ACTIONS_H
+#define LV_ACTIONS_H
+
+namespace lv_actions {
+
+       void init();
+
+};
+ 
+#endif // LV_ACTIONS_H
Index: lyx_cb.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
retrieving revision 1.182
diff -u -r1.182 lyx_cb.C
--- lyx_cb.C    28 Jul 2002 22:50:03 -0000      1.182
+++ lyx_cb.C    31 Jul 2002 17:03:55 -0000
@@ -426,58 +426,6 @@
 }
 
 
-void MenuInsertLabel(BufferView * bv, string const & arg)
-{
-       string label(arg);
-       bv->owner()->prohibitInput();
-       if (label.empty()) {
-               Paragraph * par = bv->getLyXText()->cursor.par();
-               LyXLayout_ptr layout = par->layout();
-               if (layout->latextype == LATEX_PARAGRAPH && par->previous()) {
-                       Paragraph * par2 = par->previous();
-
-                       LyXLayout_ptr const & layout2 = par2->layout();
-
-                       if (layout2->latextype != LATEX_PARAGRAPH) {
-                               par = par2;
-                               layout = layout2;
-                       }
-               }
-               string text = layout->latexname().substr(0, 3);
-               if (layout->latexname() == "theorem")
-                       text = "thm"; // Create a correct prefix for prettyref
-
-               text += ":";
-               if (layout->latextype == LATEX_PARAGRAPH ||
-                   lyxrc.label_init_length < 0)
-                       text.erase();
-               string par_text = par->asString(bv->buffer(), false);
-               for (int i = 0; i < lyxrc.label_init_length; ++i) {
-                       if (par_text.empty())
-                               break;
-                       string head;
-                       par_text = split(par_text, head, ' ');
-                       if (i > 0)
-                               text += '-'; // Is it legal to use spaces in
-                                            // labels ?
-                       text += head;
-               }
-
-               pair<bool, string> result =
-                       Alert::askForText(_("Enter new label to insert:"), text);
-               if (result.first) {
-                       label = trim(result.second);
-               }
-       }
-       if (!label.empty()) {
-               InsetCommandParams p("label", label);
-               InsetLabel * inset = new InsetLabel(p);
-               bv->insertInset(inset);
-       }
-       bv->owner()->allowInput();
-}
-
-
 // This function runs "configure" and then rereads lyx.defaults to
 // reconfigure the automatic settings.
 void Reconfigure(BufferView * bv)
Index: lyx_cb.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.h,v
retrieving revision 1.26
diff -u -r1.26 lyx_cb.h
--- lyx_cb.h    21 Mar 2002 17:25:10 -0000      1.26
+++ lyx_cb.h    31 Jul 2002 17:03:55 -0000
@@ -33,7 +33,5 @@
 ///
 string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagraph);
 ///
-void MenuInsertLabel(BufferView * bv, string const & arg);
-///
 void Reconfigure(BufferView * bv);
 #endif
Index: lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.118
diff -u -r1.118 lyx_main.C
--- lyx_main.C  28 Jul 2002 22:50:04 -0000      1.118
+++ lyx_main.C  31 Jul 2002 17:03:55 -0000
@@ -28,6 +28,10 @@
 #include "lyxserver.h"
 #include "kbmap.h"
 #include "lyxfunc.h"
+#include "lv_actions.h"
+#include "buffer_actions.h"
+#include "insets/tabular_actions.h"
+#include "mathed/math_actions.h"
 #include "ToolbarDefaults.h"
 #include "MenuBackend.h"
 #include "language.h"
@@ -116,6 +120,11 @@
                files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
        }
 
+       lv_actions::init();
+       buffer_actions::init();
+       tabular_actions::init();
+       math_actions::init();
+ 
 #if 0 // FIXME: GUII
        // Execute batch commands if available
        if (!batch_command.empty()) {
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.354
diff -u -r1.354 lyxfunc.C
--- lyxfunc.C   30 Jul 2002 22:58:54 -0000      1.354
+++ lyxfunc.C   31 Jul 2002 17:04:01 -0000
@@ -15,6 +15,7 @@
 #endif
 
 #include "lyxfunc.h"
+#include "action.h"
 #include "version.h"
 #include "kbmap.h"
 #include "lyxrow.h"
@@ -114,7 +115,6 @@
 
 extern void show_symbols_form(LyXFunc *);
 
-extern LyXAction lyxaction;
 // (alkis)
 extern tex_accent_struct get_accent(kb_action action);
 
@@ -291,39 +291,10 @@
        FuncStatus flag;
        Buffer * buf = owner->buffer();
 
-       if (action == LFUN_NOACTION) {
-               setStatusMessage(N_("Nothing to do"));
-               return flag.disabled(true);
-       }
-
-       if (action == LFUN_UNKNOWN_ACTION) {
-               setStatusMessage(N_("Unknown action"));
-               return flag.unknown(true);
-       }
-
-       // the default error message if we disable the command
-       setStatusMessage(N_("Command disabled"));
-
-       // Check whether we need a buffer
-       if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
-               // Yes we need a buffer, do we have one?
-               if (buf) {
-                       // yes
-                       // Can we use a readonly buffer?
-                       if (buf->isReadonly() &&
-                           !lyxaction.funcHasFlag(action,
-                                                  LyXAction::ReadOnly)) {
-                               // no
-                               setStatusMessage(N_("Document is read-only"));
-                               flag.disabled(true);
-                       }
-               } else {
-                       // no
-                       setStatusMessage(N_("Command not allowed with"
-                                          "out any document open"));
-                       return flag.disabled(true);
-               }
-       }
+       bool actions_found = false; 
+       FuncStatus tmp = actions.status(*owner->view(), action, actions_found);
+       if (actions_found)
+               return tmp;
 
        UpdatableInset * tli = owner->view()->theLockingInset();
 
@@ -548,9 +519,6 @@
        case LFUN_INSERT_NOTE:
                code = Inset::IGNORE_CODE;
                break;
-       case LFUN_INSERT_LABEL:
-               code = Inset::LABEL_CODE;
-               break;
        case LFUN_REF_INSERT:
                code = Inset::REF_CODE;
                break;
@@ -610,10 +578,6 @@
 
        // A few general toggles
        switch (action) {
-       case LFUN_TOOLTIPS_TOGGLE:
-               flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
-               break;
-
        case LFUN_READ_ONLY_TOGGLE:
                flag.setOnOff(buf->isReadonly());
                break;
@@ -751,6 +715,16 @@
                goto exit_with_message;
        }
 
+       { 
+       bool actions_found = false;
+       action::result tmp = actions.dispatch(*owner->view(), action, argument, 
+actions_found);
+       if (actions_found) {
+               errorstat = tmp.failed; 
+               dispatch_buffer = tmp.message;
+               goto exit_with_message;
+       }
+       } 
+ 
        if (owner->view()->available() && owner->view()->theLockingInset()) {
                UpdatableInset::RESULT result;
                if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
@@ -1354,10 +1328,6 @@
                dispatch(LFUN_SELFINSERT, "^", false);
                break;
 
-       case LFUN_MATH_PANEL:
-               owner->getDialogs()->showMathPanel();
-               break;
-
        case LFUN_CITATION_CREATE:
        {
                InsetCommandParams p("cite");
@@ -1511,10 +1481,6 @@
                fcc.kill(pid);
                break;
        }
-
-       case LFUN_TOOLTIPS_TOGGLE:
-               owner->getDialogs()->toggleTooltips();
-               break;
 
        default:
                // Then if it was none of the above
Index: lyxrc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.C,v
retrieving revision 1.124
diff -u -r1.124 lyxrc.C
--- lyxrc.C     21 Jul 2002 21:20:56 -0000      1.124
+++ lyxrc.C     31 Jul 2002 17:04:07 -0000
@@ -40,7 +40,6 @@
 
 class kb_keymap;
 
-extern LyXAction lyxaction;
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
 
 namespace {
Index: frontends/Toolbar.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Toolbar.C,v
retrieving revision 1.13
diff -u -r1.13 Toolbar.C
--- frontends/Toolbar.C 22 Jul 2002 20:52:40 -0000      1.13
+++ frontends/Toolbar.C 31 Jul 2002 17:04:10 -0000
@@ -20,8 +20,6 @@
 
 using std::endl;
 
-extern LyXAction lyxaction;
-
 
 Toolbar::Toolbar(LyXView * o, Dialogs & d,
                 int x, int y, ToolbarDefaults const &tbd)
Index: frontends/controllers/ControlCommandBuffer.C
===================================================================
RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCommandBuffer.C,v
retrieving revision 1.2
diff -u -r1.2 ControlCommandBuffer.C
--- frontends/controllers/ControlCommandBuffer.C        20 Jul 2002 17:50:23 -0000     
 1.2
+++ frontends/controllers/ControlCommandBuffer.C        31 Jul 2002 17:04:11 -0000
@@ -24,8 +24,6 @@
 using std::transform;
 using std::endl;
  
-extern LyXAction lyxaction;
- 
 namespace {
  
 struct prefix_p {
Index: frontends/qt2/Menubar_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/Menubar_pimpl.C,v
retrieving revision 1.9
diff -u -r1.9 Menubar_pimpl.C
--- frontends/qt2/Menubar_pimpl.C       25 Jul 2002 02:24:36 -0000      1.9
+++ frontends/qt2/Menubar_pimpl.C       31 Jul 2002 17:04:11 -0000
@@ -63,7 +63,6 @@
 typedef vector<int>::size_type size_type;
 
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
-extern LyXAction lyxaction;
 
 
 Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe) 
Index: frontends/qt2/Toolbar_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/Toolbar_pimpl.C,v
retrieving revision 1.13
diff -u -r1.13 Toolbar_pimpl.C
--- frontends/qt2/Toolbar_pimpl.C       25 Jul 2002 05:04:01 -0000      1.13
+++ frontends/qt2/Toolbar_pimpl.C       31 Jul 2002 17:04:14 -0000
@@ -36,8 +36,6 @@
  
 using std::endl;
 
-extern LyXAction lyxaction;
-
 namespace {
  
 QPixmap getIconPixmap(int action)
Index: frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.501
diff -u -r1.501 ChangeLog
--- frontends/xforms/ChangeLog  30 Jul 2002 22:35:43 -0000      1.501
+++ frontends/xforms/ChangeLog  31 Jul 2002 17:04:26 -0000
@@ -1,3 +1,8 @@
+2002-07-31  John Levon  <[EMAIL PROTECTED]>
+
+       * FormTabular.C:
+       * FormTabularCreate.C: "Tabular" -> "Table"
+ 
 2002-07-30  John Levon  <[EMAIL PROTECTED]>
 
        * lyx_gui.C: implement remove_read_callback()
Index: frontends/xforms/FormTabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormTabular.C,v
retrieving revision 1.51
diff -u -r1.51 FormTabular.C
--- frontends/xforms/FormTabular.C      24 Jun 2002 20:28:10 -0000      1.51
+++ frontends/xforms/FormTabular.C      31 Jul 2002 17:04:29 -0000
@@ -40,7 +40,7 @@
 
 
 FormTabular::FormTabular(LyXView & lv, Dialogs & d)
-       : FormInset(&lv, &d, _("Tabular Layout")),
+       : FormInset(&lv, &d, _("Table Properties")),
          inset_(0), actCell_(-1), closing_(false)
 {
 }
@@ -135,7 +135,7 @@
        setPrehandler(cell_options_->input_mcolumn_width);
        setPrehandler(cell_options_->input_special_multialign);
 
-       fl_addto_tabfolder(dialog_->tabfolder, _("Tabular"),
+       fl_addto_tabfolder(dialog_->tabfolder, _("Table"),
                           tabular_options_->form);
        fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row"),
                           column_options_->form);
Index: frontends/xforms/FormTabularCreate.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormTabularCreate.C,v
retrieving revision 1.22
diff -u -r1.22 FormTabularCreate.C
--- frontends/xforms/FormTabularCreate.C        2 Jul 2002 19:23:10 -0000       1.22
+++ frontends/xforms/FormTabularCreate.C        31 Jul 2002 17:04:29 -0000
@@ -27,7 +27,7 @@
 typedef FormCB<ControlTabularCreate, FormDB<FD_tabular_create> > base_class;
 
 FormTabularCreate::FormTabularCreate(ControlTabularCreate & c, Dialogs & d)
-       : base_class(c, d, _("Insert Tabular"))
+       : base_class(c, d, _("Insert Table"))
 {}
 
 
Index: frontends/xforms/Menubar_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/Menubar_pimpl.C,v
retrieving revision 1.69
diff -u -r1.69 Menubar_pimpl.C
--- frontends/xforms/Menubar_pimpl.C    25 Jul 2002 14:00:29 -0000      1.69
+++ frontends/xforms/Menubar_pimpl.C    31 Jul 2002 17:04:29 -0000
@@ -38,7 +38,6 @@
 typedef vector<int>::size_type size_type;
 
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
-extern LyXAction lyxaction;
 
 namespace {
 
Index: frontends/xforms/Toolbar_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/Toolbar_pimpl.C,v
retrieving revision 1.52
diff -u -r1.52 Toolbar_pimpl.C
--- frontends/xforms/Toolbar_pimpl.C    22 Jul 2002 20:52:40 -0000      1.52
+++ frontends/xforms/Toolbar_pimpl.C    31 Jul 2002 17:04:32 -0000
@@ -37,8 +37,6 @@
 
 using std::endl;
 
-extern LyXAction lyxaction;
-
 // some constants
 const int standardspacing = 2; // the usual space between items
 const int sepspace = 6; // extra space
Index: insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.480
diff -u -r1.480 ChangeLog
--- insets/ChangeLog    28 Jul 2002 22:50:10 -0000      1.480
+++ insets/ChangeLog    31 Jul 2002 17:04:44 -0000
@@ -1,3 +1,7 @@
+2002-07-31  John Levon  <[EMAIL PROTECTED]>
+
+       * insettabular.C: change to "Table" not "Tabular"
+ 
 2002-07-29  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
        * several files: strip,frontStrip -> trim,ltrim,rtrim
Index: insets/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/Makefile.am,v
retrieving revision 1.47
diff -u -r1.47 Makefile.am
--- insets/Makefile.am  4 Jul 2002 13:54:28 -0000       1.47
+++ insets/Makefile.am  31 Jul 2002 17:04:44 -0000
@@ -78,7 +78,9 @@
        insettoc.C \
        insettoc.h \
        inseturl.C \
-       inseturl.h
+       inseturl.h \
+       tabular_actions.h \
+       tabular_actions.C
 #      insetlist.C \
 #      insetlist.h \
 #      insetsection.h \
Index: insets/inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v
retrieving revision 1.49
diff -u -r1.49 inset.h
--- insets/inset.h      23 Jul 2002 21:03:38 -0000      1.49
+++ insets/inset.h      31 Jul 2002 17:04:44 -0000
@@ -17,6 +17,7 @@
 
 #include <vector>
 #include "LString.h"
+#include "action.h"
 #include "commandtags.h"
 #include "frontends/mouse_state.h"
 #include "LColor.h"
@@ -289,6 +290,9 @@
        ///
        void id(int id_arg);
 
+       /// the context of the inset
+       virtual action::context context_code() const { return action::no_context; }
+ 
        /// used to toggle insets
        // is the inset open?
        virtual bool isOpen() const { return false; }
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.216
diff -u -r1.216 insettabular.C
--- insets/insettabular.C       28 Jul 2002 22:50:11 -0000      1.216
+++ insets/insettabular.C       31 Jul 2002 17:04:51 -0000
@@ -548,7 +548,7 @@
 
 string const InsetTabular::editMessage() const
 {
-       return _("Opened Tabular Inset");
+       return _("Opened table");
 }
 
 
@@ -876,6 +876,38 @@
 }
 
 
+void InsetTabular::nextCell(BufferView * bv)
+{
+       bool const hs = hasSelection();
+       hideInsetCursor(bv);
+       unlockInsetInInset(bv, the_locking_inset);
+       moveNextCell(bv, old_locking_inset != 0);
+       clearSelection();
+       if (hs)
+               updateLocal(bv, SELECTION, false);
+       if (!the_locking_inset) {
+               showInsetCursor(bv);
+               return /* FIXME DISPATCHED_NOUPDATE */;
+       }
+}
+
+
+void InsetTabular::previousCell(BufferView * bv)
+{
+       bool const hs = hasSelection();
+       hideInsetCursor(bv);
+       unlockInsetInInset(bv, the_locking_inset);
+       movePrevCell(bv, old_locking_inset != 0);
+       clearSelection();
+       if (hs)
+               updateLocal(bv, SELECTION, false);
+       if (!the_locking_inset) {
+               showInsetCursor(bv);
+               return /* FIXME DISPATCHED_NOUPDATE*/;
+       }
+}
+ 
+
 UpdatableInset::RESULT
 InsetTabular::localDispatch(BufferView * bv, kb_action action,
                            string const & arg)
@@ -896,31 +928,6 @@
        bool hs = hasSelection();
 
        result = DISPATCHED;
-       // this one have priority over the locked InsetText, if we're not already
-       // inside another tabular then that one get's priority!
-       if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
-               switch (action) {
-               case LFUN_SHIFT_TAB:
-               case LFUN_TAB:
-                       hideInsetCursor(bv);
-                       unlockInsetInInset(bv, the_locking_inset);
-                       if (action == LFUN_TAB)
-                               moveNextCell(bv, old_locking_inset != 0);
-                       else
-                               movePrevCell(bv, old_locking_inset != 0);
-                       clearSelection();
-                       if (hs)
-                               updateLocal(bv, SELECTION, false);
-                       if (!the_locking_inset) {
-                               showInsetCursor(bv);
-                               return DISPATCHED_NOUPDATE;
-                       }
-                       return result;
-               // this to avoid compiler warnings.
-               default:
-                       break;
-               }
-       }
 
        if (the_locking_inset) {
                result = the_locking_inset->localDispatch(bv, action, arg);
Index: insets/insettabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v
retrieving revision 1.92
diff -u -r1.92 insettabular.h
--- insets/insettabular.h       23 Jul 2002 21:03:38 -0000      1.92
+++ insets/insettabular.h       31 Jul 2002 17:04:55 -0000
@@ -53,7 +53,7 @@
 #include "tabular.h"
 #include "LString.h"
 #include "lyxcursor.h"
-#include "FuncStatus.h"
+#include "tabular_actions.h"
 
 #include <boost/scoped_ptr.hpp>
 
@@ -109,6 +109,8 @@
        ///
        void insetUnlock(BufferView *);
        ///
+       void hideInsetCursor(BufferView *);
+       ///
        void updateLocal(BufferView *, UpdateCodes, bool mark_dirty) const;
        ///
        bool lockInsetInInset(BufferView *, UpdatableInset *);
@@ -229,6 +231,14 @@
        // "normal" means without width set!
        bool forceDefaultParagraphs(Inset const * in) const;
 
+       /// move to the next cell. Returns true if update needed
+       void nextCell(BufferView * bv);
+
+       /// move to the previous cell. Returns true if update needed
+       void previousCell(BufferView * bv);
+ 
+       virtual action::context context_code() const { return 
+tabular_actions::context; }
+ 
        //
        // Public structures and variables
        ///
@@ -248,8 +258,6 @@
                               int row, int column, int cell) const;
        ///
        void showInsetCursor(BufferView *, bool show=true);
-       ///
-       void hideInsetCursor(BufferView *);
        ///
        void fitInsetCursor(BufferView *) const;
        ///
Index: insets/tabular_actions.C
===================================================================
RCS file: insets/tabular_actions.C
diff -N insets/tabular_actions.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ insets/tabular_actions.C    31 Jul 2002 17:04:55 -0000
@@ -0,0 +1,72 @@
+/**
+ * \file tabular_actions.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * LyXView-wide actions.
+ * Special actions for tabular insets.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#include "tabular_actions.h"
+#include "insettabular.h"
+#include "gettext.h"
+#include "BufferView.h"
+
+namespace tabular_actions {
+
+action::context context;
+ 
+struct tabular_action : public action::handler_base {
+       void pre(BufferView * bv, InsetTabular * i) const {
+               i->hideInsetCursor(bv);
+       }
+
+       void post() const {
+               // FIXME
+       }
+ 
+       virtual action::result handler(BufferView & bv, InsetTabular * i, string const 
+&) const = 0;
+ 
+       virtual action::result operator()(BufferView & bv, Inset * i, string const & 
+arg) const {
+               action::result result;
+               InsetTabular * tab(static_cast<InsetTabular*>(i));
+               pre(&bv, tab);
+               result = handler(bv, tab, arg);
+               post();
+               return result;
+       }
+};
+ 
+struct lfun_shift_tab : public tabular_action {
+       virtual action::result handler(BufferView & bv, InsetTabular * i, string const 
+&) const {
+               i->previousCell(&bv);
+               return action::result();
+       }
+ 
+       virtual action::handler_flags flags() const { return action::override; }
+ 
+} lfun_shift_tab;
+
+
+struct lfun_tab : public tabular_action {
+       virtual action::result handler(BufferView & bv, InsetTabular * i, string const 
+&) const {
+               i->nextCell(&bv);
+               return action::result();
+       }
+
+       virtual action::handler_flags flags() const { return action::override; }
+ 
+} lfun_tab;
+
+
+void init()
+{
+       context = actions.get_context();
+ 
+       actions.add(context, LFUN_SHIFT_TAB, &lfun_shift_tab);
+       actions.add(context, LFUN_TAB, &lfun_tab);
+}
+ 
+};
Index: insets/tabular_actions.h
===================================================================
RCS file: insets/tabular_actions.h
diff -N insets/tabular_actions.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ insets/tabular_actions.h    31 Jul 2002 17:04:55 -0000
@@ -0,0 +1,23 @@
+/**
+ * \file tabular_actions.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Special actions for tabular insets.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#ifndef TABULAR_ACTIONS_H
+#define TABULAR_ACTIONS_H
+
+#include "action.h"
+ 
+namespace tabular_actions {
+
+       extern action::context context;
+ 
+       void init();
+};
+ 
+#endif // TABULAR_ACTIONS_H
Index: mathed/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/Makefile.am,v
retrieving revision 1.104
diff -u -r1.104 Makefile.am
--- mathed/Makefile.am  17 Jul 2002 10:25:33 -0000      1.104
+++ mathed/Makefile.am  31 Jul 2002 17:04:55 -0000
@@ -15,6 +15,8 @@
        formula.h \
        formulamacro.C \
        formulamacro.h \
+       math_actions.h \
+       math_actions.C \
        math_amsarrayinset.C \
        math_amsarrayinset.h \
        math_arrayinset.C \
Index: mathed/formulabase.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v
retrieving revision 1.189
diff -u -r1.189 formulabase.C
--- mathed/formulabase.C        28 Jul 2002 22:50:12 -0000      1.189
+++ mathed/formulabase.C        31 Jul 2002 17:05:03 -0000
@@ -482,16 +482,6 @@
                updateLocal(bv, true);
                break;
 
-       case LFUN_TAB:
-               mathcursor->idxNext();
-               updateLocal(bv, false);
-               break;
-
-       case LFUN_SHIFT_TAB:
-               mathcursor->idxPrev();
-               updateLocal(bv, false);
-               break;
-
        case LFUN_TABINSERT:
                bv->lockedInsetStoreUndo(Undo::EDIT);
                mathcursor->splitCell();
@@ -719,10 +709,6 @@
                                result = mathcursor->interpret(arg) ? DISPATCHED : 
FINISHED_RIGHT;
                        updateLocal(bv, true);
                }
-               break;
-
-       case LFUN_MATH_PANEL:
-               result = UNDISPATCHED;
                break;
 
        case LFUN_ESCAPE:
Index: mathed/formulabase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.h,v
retrieving revision 1.46
diff -u -r1.46 formulabase.h
--- mathed/formulabase.h        4 Jul 2002 11:00:51 -0000       1.46
+++ mathed/formulabase.h        31 Jul 2002 17:05:03 -0000
@@ -20,6 +20,7 @@
 #endif
 
 #include "insets/inset.h"
+#include "math_actions.h"
 #include "frontends/mouse_state.h"
 #include "lyxfont.h"
 
@@ -53,6 +54,7 @@
        /// highest y coordinate
        virtual int yhigh() const;
 
+       virtual action::context context_code() const { return math_actions::context; }
 public:
        ///
        virtual void validate(LaTeXFeatures &) const;
Index: mathed/math_actions.C
===================================================================
RCS file: mathed/math_actions.C
diff -N mathed/math_actions.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ mathed/math_actions.C       31 Jul 2002 17:05:03 -0000
@@ -0,0 +1,84 @@
+/**
+ * \file math_actions.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * LyXView-wide actions.
+ * Special actions for tabular insets.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#include "math_actions.h"
+#include "math_cursor.h"
+#include "formulabase.h"
+#include "BufferView.h"
+#include "support/LAssert.h"
+
+namespace math_actions {
+
+action::context context;
+
+struct math_action : public action::handler_base {
+       void pre(BufferView & bv, InsetFormulaBase * inset) const {
+               inset->hideInsetCursor(&bv);
+               mathcursor->normalize();
+               mathcursor->touch();
+       }
+
+       void post(BufferView & bv, InsetFormulaBase * inset) const {
+               // FIXME
+               mathcursor->normalize();
+               mathcursor->touch();
+
+               lyx::Assert(mathcursor);
+
+               //if (mathcursor->selection() || was_selection)
+               if (mathcursor->selection())
+                       inset->toggleInsetSelection(&bv);
+
+               inset->fitInsetCursor(&bv);
+               inset->showInsetCursor(&bv);
+               inset->revealCodes(&bv);
+       }
+
+       virtual action::result handler(BufferView & bv, InsetFormulaBase * i, string 
+const &) const = 0;
+
+       virtual action::result operator()(BufferView & bv, Inset * i, string const & 
+arg) const {
+               InsetFormulaBase * inset(static_cast<InsetFormulaBase*>(i));
+               action::result result;
+               pre(bv, inset);
+               result = handler(bv, inset, arg);
+               post(bv, inset);
+               return result;
+       }
+};
+
+
+struct lfun_shift_tab : public math_action {
+       virtual action::result handler(BufferView & bv, InsetFormulaBase * i, string 
+const &) const {
+               mathcursor->idxPrev();
+               i->updateLocal(&bv, false);
+               return action::result();
+       }
+} lfun_shift_tab;
+
+
+struct lfun_tab : public math_action {
+       virtual action::result handler(BufferView & bv, InsetFormulaBase * i, string 
+const &) const {
+               mathcursor->idxNext();
+               i->updateLocal(&bv, false);
+               return action::result();
+       }
+} lfun_tab;
+
+
+void init()
+{
+       context = actions.get_context();
+
+       actions.add(context, LFUN_SHIFT_TAB, &lfun_shift_tab);
+       actions.add(context, LFUN_TAB, &lfun_tab);
+}
+
+};
Index: mathed/math_actions.h
===================================================================
RCS file: mathed/math_actions.h
diff -N mathed/math_actions.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ mathed/math_actions.h       31 Jul 2002 17:05:03 -0000
@@ -0,0 +1,23 @@
+/**
+ * \file math_actions.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Special actions for tabular insets.
+ *
+ * \author John Levon <[EMAIL PROTECTED]>
+ */
+
+#ifndef MATH_ACTIONS_H
+#define MATH_ACTIONS_H
+
+#include "action.h"
+ 
+namespace math_actions {
+
+       extern action::context context;
+ 
+       void init();
+};
+ 
+#endif // MATH_ACTIONS_H

Reply via email to