Martin's super/subscript patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3199 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-12-12 14:37:59 +00:00
parent 6c13215907
commit d857fc89c8
8 changed files with 65 additions and 27 deletions

View File

@ -1,3 +1,14 @@
2001-12-12 Martin Vermeer <martin.vermeer@hut.fi>
* commandtags.h:
* LyXAction.C:
* lyx_main.C:
* lyxfunc.C:
* mathed/formulabase.C:
* mathed/math_cursor.[Ch]:
make sub/superscript into functions LFUN_SUB/SUPERSCRIPT.
2001-12-12 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxlength.[Ch] (operator!=): new function

View File

@ -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 },

View File

@ -94,6 +94,8 @@ enum kb_action {
LFUN_BREAKPARAGRAPHKEEPLAYOUT,
LFUN_QUOTE,
LFUN_CIRCUMFLEX,
LFUN_SUBSCRIPT,
LFUN_SUPERSCRIPT,
LFUN_GRAVE,
LFUN_ACUTE,
LFUN_TILDE,

View File

@ -523,6 +523,10 @@ void LyX::defaultKeyBindings(kb_keymap * kbmap)
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->bindings to enable the use of the numeric keypad
// e.g. Num Lock set

View File

@ -573,6 +573,8 @@ func_status::value_type LyXFunc::getStatus(int ac,
case LFUN_MATH_LIMITS:
case LFUN_MATH_NONUMBER:
case LFUN_MATH_NUMBER:
case LFUN_SUBSCRIPT:
case LFUN_SUPERSCRIPT:
disable = !mathcursor;
break;
@ -1438,6 +1440,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!"));
}

View File

@ -556,7 +556,16 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
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";

View File

@ -1221,36 +1221,40 @@ bool MathCursor::interpret(string const & s)
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()) {

View File

@ -115,6 +115,8 @@ public:
/// size of current cell
size_type size() const;
///
bool script(bool);
///
bool interpret(string const &);
///
bool interpret(char);