]> git.lyx.org Git - features.git/commitdiff
Disable the Edit->Math menu when not in math.
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 16 Jan 2009 10:35:57 +0000 (10:35 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 16 Jan 2009 10:35:57 +0000 (10:35 +0000)
Introduce new LFUN_MATH_FONT_STYLE which takes one of the font styles as an argument. A dispatch is being redirected to math-insert.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28181 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ui/stdmenus.inc
src/FuncCode.h
src/LyXAction.cpp
src/mathed/InsetMathNest.cpp

index 2029e3bca12cf9c26b3b2586a5c834cc5f7c3997..b0c7002c2647da5a61e699144ab569511a15844a 100644 (file)
@@ -200,7 +200,7 @@ Menuset
                Separator
                Submenu "Change Formula Type|F" "edit_math_mutate"
                Separator
-               Submenu "Text Style|T" "edit_math_textstyles"
+               Submenu "Text Style|T" "edit_math_fontstyles"
                Separator
                Submenu "Use Computer Algebra System|S" "edit_math_extern"
                Separator
@@ -237,29 +237,29 @@ Menuset
                 Item "Inline|I"  "math-limits nolimits"
        End
 
-       Menu "edit_math_textstyles"
-               Item "Math Normal Font|N" "math-insert \mathnormal"
+       Menu "edit_math_fontstyles"
+               Item "Math Normal Font|N" "math-font-style mathnormal"
                Separator
-               Item "Math Calligraphic Family|C" "math-insert \mathcal"
-               Item "Math Fraktur Family|F" "math-insert \mathfrak"
-               Item "Math Roman Family|R" "math-insert \mathrm"
-               Item "Math Sans Serif Family|S" "math-insert \mathsf"
+               Item "Math Calligraphic Family|C" "math-font-style mathcal"
+               Item "Math Fraktur Family|F" "math-font-style mathfrak"
+               Item "Math Roman Family|R" "math-font-style mathrm"
+               Item "Math Sans Serif Family|S" "math-font-style mathsf"
                Separator
-               Item "Math Bold Series|B" "math-insert \mathbf"
+               Item "Math Bold Series|B" "math-font-style mathbf"
                Separator
-               Item "Text Normal Font|T" "math-insert \textnormal"
+               Item "Text Normal Font|T" "math-font-style textnormal"
                Separator
-               Item "Text Roman Family" "math-insert \textrm"
-               Item "Text Sans Serif Family" "math-insert \textsf"
-               Item "Text Typewriter Family" "math-insert \texttt"
+               Item "Text Roman Family" "math-font-style textrm"
+               Item "Text Sans Serif Family" "math-font-style textsf"
+               Item "Text Typewriter Family" "math-font-style texttt"
                Separator
-               Item "Text Bold Series" "math-insert \textbf"
-               Item "Text Medium Series" "math-insert \textmd"
+               Item "Text Bold Series" "math-font-style textbf"
+               Item "Text Medium Series" "math-font-style textmd"
                Separator
-               Item "Text Italic Shape" "math-insert \textit"
-               Item "Text Small Caps Shape" "math-insert \textsc"
-               Item "Text Slanted Shape" "math-insert \textsl"
-               Item "Text Upright Shape" "math-insert \textup"
+               Item "Text Italic Shape" "math-font-style textit"
+               Item "Text Small Caps Shape" "math-font-style textsc"
+               Item "Text Slanted Shape" "math-font-style textsl"
+               Item "Text Upright Shape" "math-font-style textup"
        End
 
        Menu "edit_math_extern"
index 48ec01d1fa5b72891a19e8bcb24f107371776b71..f39a2427cffb89d9beec3a59040fe9c5703581a6 100644 (file)
@@ -416,6 +416,7 @@ enum FuncCode
        // 320
        LFUN_COPY_LABEL_AS_REF,          // sts, 20081116
        LFUN_VC_COMMAND,
+       LFUN_MATH_FONT_STYLE,
 
        LFUN_LASTACTION                  // end of the table
 };
index 1927f5460c402de866411f333e62c14a66add03e..59286256334faf88853961b54708134476af48a2 100644 (file)
@@ -1581,6 +1581,17 @@ void LyXAction::init()
  * \endvar
  */
                { LFUN_MATH_SIZE, "math-size", Noop, Math },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_MATH_FONT_STYLE
+ * \li Action: Changes the text style used in math.
+ * \li Syntax: math-font-style <STYLE>
+ * \li Params: <STYLE>: mathnormal|mathcal|mathfrak|mathrm|mathsf|mathbf
+               |textnormal|textrm|textsf|texttt|textbf|textmd|textit
+               |textsc|textsl|textup
+ * \li Origin: vfr, 9 jan 2009
+ * \endvar
+ */
+               { LFUN_MATH_FONT_STYLE, "math-font-style", Noop, Math },
 /*!
  * \var lyx::FuncCode lyx::LFUN_MATH_MACRO_UNFOLD
  * \li Action: Unfold a Math Macro.
index 2aad5c93edfcfbd7ce9ef2820a758bac8dfd322e..b4b0c0d3439b4e15de23e4518eed08625bea687e 100644 (file)
@@ -980,6 +980,12 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
+       case LFUN_MATH_FONT_STYLE: {
+               FuncRequest fr = FuncRequest(LFUN_MATH_INSERT, '\\' + cmd.argument());
+               doDispatch(cur, fr);
+               break;
+       }
+
        case LFUN_MATH_SIZE: {
                FuncRequest fr = FuncRequest(LFUN_MATH_INSERT, cmd.argument());
                doDispatch(cur, fr);
@@ -1253,18 +1259,22 @@ bool InsetMathNest::getStatus(Cursor & cur, FuncRequest const & cmd,
                flag.setEnabled(currentMode() != TEXT_MODE);
                break;
 
-       case LFUN_MATH_INSERT: {
+       case LFUN_MATH_FONT_STYLE: {
                bool const textarg =
-                       arg == "\\textbf"   || arg == "\\textsf" ||
-                       arg == "\\textrm"   || arg == "\\textmd" ||
-                       arg == "\\textit"   || arg == "\\textsc" ||
-                       arg == "\\textsl"   || arg == "\\textup" ||
-                       arg == "\\texttt"   || arg == "\\textbb" ||
-                       arg == "\\textnormal";
+                       arg == "textbf"   || arg == "textsf" ||
+                       arg == "textrm"   || arg == "textmd" ||
+                       arg == "textit"   || arg == "textsc" ||
+                       arg == "textsl"   || arg == "textup" ||
+                       arg == "texttt"   || arg == "textbb" ||
+                       arg == "textnormal";
                flag.setEnabled(currentMode() != TEXT_MODE || textarg);
                break;
        }
 
+       case LFUN_MATH_INSERT:
+               flag.setEnabled(currentMode() != TEXT_MODE);
+               break;
+
        case LFUN_MATH_MATRIX:
                flag.setEnabled(currentMode() == MATH_MODE);
                break;