On Mon, Dec 10, 2001 at 03:30:10PM +0000, John Levon wrote:
... 
> (I think)
> 
> Someone better apply the kbsequence one before Andre goes mad ...
> 
> regards
> john

...

OK, I see this is in. Here is the redo of my LFUN_(SUB|SUPER)SCRIPT patch
for review. Works for me.

After this I could have a look at factoring the key bindings between
hardwired and bind files. And perhaps a separate keypad.bind file.

Cheers Martin

-- 
Martin Vermeer  [EMAIL PROTECTED]
Helsinki University of Technology 
Department of Surveying
P.O. Box 1200, FIN-02015 HUT, Finland
:wq
Index: src/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.450
diff -u -p -r1.450 ChangeLog
--- src/ChangeLog       2001/12/10 15:59:20     1.450
+++ src/ChangeLog       2001/12/10 19:55:00
@@ -1,3 +1,14 @@
+2001-12-10     Martin Vermeer <[EMAIL PROTECTED]>
+
+       * commandtags.h:
+       * LyXAction.C:
+       * lyx_main.C:
+       * lyxfunc.C:
+       * mathed/formulabase.C:
+       * mathed/math_cursor.h
+       * mathed/math_cursor.C: make sub/superscript
+       into functions LFUN_SUB/SUPERSCRIPT.
+
 2001-12-06  John Levon  <[EMAIL PROTECTED]>
 
        * lyx_cb.C: another bv->text misuse, from insert label
Index: src/LyXAction.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/LyXAction.C,v
retrieving revision 1.104
diff -u -p -r1.104 LyXAction.C
--- src/LyXAction.C     2001/12/05 23:09:26     1.104
+++ src/LyXAction.C     2001/12/10 19:55:01
@@ -281,6 +281,8 @@ void LyXAction::init()
                { LFUN_GREEK_TOGGLE, "math-greek-toggle", "", Noop },
                { LFUN_INSERT_MATH, "math-insert",
                  N_("Insert math symbol"), Noop },
+               { LFUN_SUBSCRIPT, "math-subscript", "", Noop },
+               { LFUN_SUPERSCRIPT, "math-superscript", "", Noop },
                { LFUN_MATH_LIMITS, "math-limits", "", Noop },
                { LFUN_MATH_MACRO, "math-macro", "", Noop },
                { LFUN_MATH_MUTATE, "math-mutate", "", Noop },
Index: src/commandtags.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/commandtags.h,v
retrieving revision 1.80
diff -u -p -r1.80 commandtags.h
--- src/commandtags.h   2001/12/05 23:09:26     1.80
+++ src/commandtags.h   2001/12/10 19:55:01
@@ -94,6 +94,8 @@ enum kb_action {
        LFUN_BREAKPARAGRAPHKEEPLAYOUT,
        LFUN_QUOTE,
        LFUN_CIRCUMFLEX,
+       LFUN_SUBSCRIPT,
+       LFUN_SUPERSCRIPT,
        LFUN_GRAVE,
        LFUN_ACUTE,
        LFUN_TILDE,
Index: src/lyx_main.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyx_main.C,v
retrieving revision 1.97
diff -u -p -r1.97 lyx_main.C
--- src/lyx_main.C      2001/11/26 10:19:49     1.97
+++ src/lyx_main.C      2001/12/10 19:55:02
@@ -523,6 +523,11 @@ void LyX::defaultKeyBindings(kb_keymap  
        
        kbmap->bind("Delete", LFUN_DELETE);
        kbmap->bind("BackSpace", LFUN_BACKSPACE);
+
+       // sub- and superscript -MV
+       kbmap->bind("S-underscore", LFUN_SUBSCRIPT);
+       kbmap->bind("S-asciicircum", LFUN_SUPERSCRIPT);
+       kbmap->bind("~S-dead_circumflex", LFUN_SUPERSCRIPT);
        
        // kbmap->bindings to enable the use of the numeric keypad
        // e.g. Num Lock set
@@ -580,7 +585,8 @@ void LyX::deadKeyBindings(kb_keymap * kb
        kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
        kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
        kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
-       kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
+       // Renamed, conflicted with superscript -MV
+       kbmap->bind("M-m h", LFUN_CIRCUMFLEX);
        kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
        kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
        kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
Index: src/lyxfunc.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.270
diff -u -p -r1.270 lyxfunc.C
--- src/lyxfunc.C       2001/12/05 23:09:26     1.270
+++ src/lyxfunc.C       2001/12/10 19:55:04
@@ -570,6 +570,8 @@ func_status::value_type LyXFunc::getStat
        case LFUN_MATH_LIMITS: 
        case LFUN_MATH_NONUMBER: 
        case LFUN_MATH_NUMBER:
+       case LFUN_SUBSCRIPT:
+       case LFUN_SUPERSCRIPT:
                disable = !mathcursor;
                break;
 
@@ -1435,6 +1437,8 @@ string const LyXFunc::dispatch(int ac,
        case LFUN_MATH_NUMBER:
        case LFUN_MATH_NONUMBER:
        case LFUN_MATH_LIMITS:
+       case LFUN_SUBSCRIPT:
+       case LFUN_SUPERSCRIPT:
        {
                setErrorMessage(N_("This is only allowed in math mode!"));
        }
Index: src/mathed/formulabase.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/mathed/formulabase.C,v
retrieving revision 1.109
diff -u -p -r1.109 formulabase.C
--- src/mathed/formulabase.C    2001/12/05 18:55:44     1.109
+++ src/mathed/formulabase.C    2001/12/10 19:55:05
@@ -556,7 +556,16 @@ InsetFormulaBase::localDispatch(BufferVi
                updateLocal(bv, true);
                break;
        }
-
+       
+       case LFUN_SUPERSCRIPT:
+       case LFUN_SUBSCRIPT:
+       {
+               bv->lockedInsetStoreUndo(Undo::EDIT);
+               mathcursor->script((action == LFUN_SUPERSCRIPT));
+               updateLocal(bv, true);
+               break;
+       }
+       
        case LFUN_MATH_DELIM:
        {
                lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
Index: src/mathed/math_cursor.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/mathed/math_cursor.C,v
retrieving revision 1.202
diff -u -p -r1.202 math_cursor.C
--- src/mathed/math_cursor.C    2001/12/10 10:09:00     1.202
+++ src/mathed/math_cursor.C    2001/12/10 19:55:06
@@ -1270,36 +1270,40 @@ bool MathCursor::interpret(string const 
        return true;
 }
 
+bool MathCursor::script(bool up)
+{
+       macroModeClose();
+       lyxerr << "script 2: '" << up << "'\n";
+       selCut();
+       if (hasPrevAtom() && prevAtom()->asScriptInset()) {
+               prevAtom()->asScriptInset()->ensure(up);
+               pushRight(prevAtom());
+               idx() = up;
+               pos() = size();
+       } else if (hasNextAtom() && nextAtom()->asScriptInset()) {
+               nextAtom()->asScriptInset()->ensure(up);
+               pushLeft(nextAtom());
+               idx() = up;
+               pos() = 0;
+       } else {
+               plainInsert(MathAtom(new MathScriptInset(up)));
+               prevAtom()->asScriptInset()->ensure(up);
+               pushRight(prevAtom());
+               idx() = up;
+               pos() = 0;
+       }
+       selPaste();
+       dump("1");
+       return true;
+}
+
 
 bool MathCursor::interpret(char c)
 {
-       //lyxerr << "interpret 2: '" << c << "'\n";
-       if (c == '^' || c == '_') {
-               macroModeClose();
-               const bool up = (c == '^');
-               selCut();
-               if (hasPrevAtom() && prevAtom()->asScriptInset()) {
-                       prevAtom()->asScriptInset()->ensure(up);
-                       pushRight(prevAtom());
-                       idx() = up;
-                       pos() = size();
-               } else if (hasNextAtom() && nextAtom()->asScriptInset()) {
-                       nextAtom()->asScriptInset()->ensure(up);
-                       pushLeft(nextAtom());
-                       idx() = up;
-                       pos() = 0;
-               } else {
-                       plainInsert(MathAtom(new MathScriptInset(up)));
-                       prevAtom()->asScriptInset()->ensure(up);
-                       pushRight(prevAtom());
-                       idx() = up;
-                       pos() = 0;
-               }
-               selPaste();
-               dump("1");
-               return true;
-       }
 
+       lyxerr << "interpret 2: '" << c << "'\n";
+
+       // Removed super/subscript handling from here  to ::script -MV
 
        // handle macroMode
        if (inMacroMode()) {
Index: src/mathed/math_cursor.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/mathed/math_cursor.h,v
retrieving revision 1.87
diff -u -p -r1.87 math_cursor.h
--- src/mathed/math_cursor.h    2001/12/10 10:09:00     1.87
+++ src/mathed/math_cursor.h    2001/12/10 19:55:06
@@ -115,6 +115,8 @@ public:
        /// size of current cell
        size_type size() const;
        ///
+       bool script(bool);
+       ///
        bool interpret(string const &);
        ///
        bool interpret(char);

Attachment: msg30243/pgp00000.pgp
Description: PGP signature

Reply via email to