mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Further revision of the raise/lower selection to super/subscript
patch, avoiding class data member for nestinset * cursor.h: remove paste() (was forgotten) * mathed/math_nestinset.C (MathNestInset::doDispatch): (MathNestInset::lfunMouseRelease): (MathNestInset::interpret): incorporate saved selection into script() call parameters (MathNestInset::script): saved selection is extra parameter * mathed/math_nestinset.h: extra parameter; remove safe_ git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13431 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
812b5ebfa9
commit
206e3745a2
@ -88,8 +88,6 @@ public:
|
||||
//
|
||||
std::string selectionAsString(bool label) const;
|
||||
///
|
||||
void paste(std::string const & data);
|
||||
///
|
||||
std::string currentState();
|
||||
|
||||
/// auto-correct mode
|
||||
|
@ -712,8 +712,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
// do superscript if LyX handles
|
||||
// deadkeys
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
safe_ = grabAndEraseSelection(cur);
|
||||
script(cur, true);
|
||||
script(cur, true, grabAndEraseSelection(cur));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -792,19 +791,19 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
handleFont(cur, cmd.argument, "textnormal");
|
||||
break;
|
||||
|
||||
case LFUN_MATH_MODE:
|
||||
case LFUN_MATH_MODE: {
|
||||
#if 1
|
||||
// ignore math-mode on when already in math mode
|
||||
if (currentMode() == InsetBase::MATH_MODE && cmd.argument == "on")
|
||||
break;
|
||||
cur.macroModeClose();
|
||||
safe_ = grabAndEraseSelection(cur);
|
||||
string const save_selection = grabAndEraseSelection(cur);
|
||||
selClearOrDel(cur);
|
||||
//cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
|
||||
cur.plainInsert(MathAtom(new MathBoxInset("mbox")));
|
||||
cur.posLeft();
|
||||
cur.pushLeft(*cur.nextInset());
|
||||
cur.niceInsert(safe_);
|
||||
cur.niceInsert(save_selection);
|
||||
#else
|
||||
if (currentMode() == InsetBase::TEXT_MODE) {
|
||||
cur.niceInsert(MathAtom(new MathHullInset("simple")));
|
||||
@ -815,6 +814,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MATH_SIZE:
|
||||
#if 0
|
||||
@ -1095,8 +1095,9 @@ void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
|
||||
bool MathNestInset::interpret(LCursor & cur, char c)
|
||||
{
|
||||
//lyxerr << "interpret 2: '" << c << "'" << endl;
|
||||
string save_selection;
|
||||
if (c == '^' || c == '_')
|
||||
safe_ = grabAndEraseSelection(cur);
|
||||
save_selection = grabAndEraseSelection(cur);
|
||||
|
||||
cur.clearTargetX();
|
||||
|
||||
@ -1206,11 +1207,11 @@ bool MathNestInset::interpret(LCursor & cur, char c)
|
||||
// These shouldn't work in text mode:
|
||||
if (currentMode() != MathInset::TEXT_MODE) {
|
||||
if (c == '_') {
|
||||
script(cur, false);
|
||||
script(cur, false, save_selection);
|
||||
return true;
|
||||
}
|
||||
if (c == '^') {
|
||||
script(cur, true);
|
||||
script(cur, true, save_selection);
|
||||
return true;
|
||||
}
|
||||
if (c == '~') {
|
||||
@ -1237,7 +1238,8 @@ bool MathNestInset::interpret(LCursor & cur, char c)
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::script(LCursor & cur, bool up)
|
||||
bool MathNestInset::script(LCursor & cur, bool up, string const &
|
||||
save_selection)
|
||||
{
|
||||
// Hack to get \^ and \_ working
|
||||
lyxerr << "handling script: up: " << up << endl;
|
||||
@ -1280,9 +1282,9 @@ bool MathNestInset::script(LCursor & cur, bool up)
|
||||
cur.idx() = 1;
|
||||
cur.pos() = 0;
|
||||
}
|
||||
//lyxerr << "inserting 1: safe:\n" << safe_ << endl;
|
||||
cur.niceInsert(safe_);
|
||||
//lyxerr << "inserting selection 1:\n" << save_selection << endl;
|
||||
cur.niceInsert(save_selection);
|
||||
cur.resetAnchor();
|
||||
//lyxerr << "inserting 2: safe:\n" << safe_ << endl;
|
||||
//lyxerr << "inserting selection 2:\n" << save_selection << endl;
|
||||
return true;
|
||||
}
|
||||
|
@ -110,7 +110,8 @@ protected:
|
||||
///
|
||||
bool interpret(LCursor & cur, char c);
|
||||
///
|
||||
bool script(LCursor & cur, bool);
|
||||
bool script(LCursor & cur, bool,
|
||||
std::string const & save_selection = std::string());
|
||||
|
||||
|
||||
private:
|
||||
@ -128,8 +129,6 @@ protected:
|
||||
cells_type cells_;
|
||||
/// if the inset is locked, it can't be entered with the cursor
|
||||
bool lock_;
|
||||
///
|
||||
std::string safe_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user