Disable the Edit->Math menu when not in math.

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
This commit is contained in:
Vincent van Ravesteijn 2009-01-16 10:35:57 +00:00
parent 26e3d3ff66
commit 650a0261a6
4 changed files with 47 additions and 25 deletions

View 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"

View 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
};

View 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.

View 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;