mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +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;
|
std::string selectionAsString(bool label) const;
|
||||||
///
|
///
|
||||||
void paste(std::string const & data);
|
|
||||||
///
|
|
||||||
std::string currentState();
|
std::string currentState();
|
||||||
|
|
||||||
/// auto-correct mode
|
/// auto-correct mode
|
||||||
|
@ -712,8 +712,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
// do superscript if LyX handles
|
// do superscript if LyX handles
|
||||||
// deadkeys
|
// deadkeys
|
||||||
recordUndo(cur, Undo::ATOMIC);
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
safe_ = grabAndEraseSelection(cur);
|
script(cur, true, grabAndEraseSelection(cur));
|
||||||
script(cur, true);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -792,19 +791,19 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
handleFont(cur, cmd.argument, "textnormal");
|
handleFont(cur, cmd.argument, "textnormal");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MATH_MODE:
|
case LFUN_MATH_MODE: {
|
||||||
#if 1
|
#if 1
|
||||||
// ignore math-mode on when already in math mode
|
// ignore math-mode on when already in math mode
|
||||||
if (currentMode() == InsetBase::MATH_MODE && cmd.argument == "on")
|
if (currentMode() == InsetBase::MATH_MODE && cmd.argument == "on")
|
||||||
break;
|
break;
|
||||||
cur.macroModeClose();
|
cur.macroModeClose();
|
||||||
safe_ = grabAndEraseSelection(cur);
|
string const save_selection = grabAndEraseSelection(cur);
|
||||||
selClearOrDel(cur);
|
selClearOrDel(cur);
|
||||||
//cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
|
//cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
|
||||||
cur.plainInsert(MathAtom(new MathBoxInset("mbox")));
|
cur.plainInsert(MathAtom(new MathBoxInset("mbox")));
|
||||||
cur.posLeft();
|
cur.posLeft();
|
||||||
cur.pushLeft(*cur.nextInset());
|
cur.pushLeft(*cur.nextInset());
|
||||||
cur.niceInsert(safe_);
|
cur.niceInsert(save_selection);
|
||||||
#else
|
#else
|
||||||
if (currentMode() == InsetBase::TEXT_MODE) {
|
if (currentMode() == InsetBase::TEXT_MODE) {
|
||||||
cur.niceInsert(MathAtom(new MathHullInset("simple")));
|
cur.niceInsert(MathAtom(new MathHullInset("simple")));
|
||||||
@ -815,6 +814,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_MATH_SIZE:
|
case LFUN_MATH_SIZE:
|
||||||
#if 0
|
#if 0
|
||||||
@ -1095,8 +1095,9 @@ void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
|
|||||||
bool MathNestInset::interpret(LCursor & cur, char c)
|
bool MathNestInset::interpret(LCursor & cur, char c)
|
||||||
{
|
{
|
||||||
//lyxerr << "interpret 2: '" << c << "'" << endl;
|
//lyxerr << "interpret 2: '" << c << "'" << endl;
|
||||||
|
string save_selection;
|
||||||
if (c == '^' || c == '_')
|
if (c == '^' || c == '_')
|
||||||
safe_ = grabAndEraseSelection(cur);
|
save_selection = grabAndEraseSelection(cur);
|
||||||
|
|
||||||
cur.clearTargetX();
|
cur.clearTargetX();
|
||||||
|
|
||||||
@ -1206,11 +1207,11 @@ bool MathNestInset::interpret(LCursor & cur, char c)
|
|||||||
// These shouldn't work in text mode:
|
// These shouldn't work in text mode:
|
||||||
if (currentMode() != MathInset::TEXT_MODE) {
|
if (currentMode() != MathInset::TEXT_MODE) {
|
||||||
if (c == '_') {
|
if (c == '_') {
|
||||||
script(cur, false);
|
script(cur, false, save_selection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (c == '^') {
|
if (c == '^') {
|
||||||
script(cur, true);
|
script(cur, true, save_selection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (c == '~') {
|
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
|
// Hack to get \^ and \_ working
|
||||||
lyxerr << "handling script: up: " << up << endl;
|
lyxerr << "handling script: up: " << up << endl;
|
||||||
@ -1280,9 +1282,9 @@ bool MathNestInset::script(LCursor & cur, bool up)
|
|||||||
cur.idx() = 1;
|
cur.idx() = 1;
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
}
|
}
|
||||||
//lyxerr << "inserting 1: safe:\n" << safe_ << endl;
|
//lyxerr << "inserting selection 1:\n" << save_selection << endl;
|
||||||
cur.niceInsert(safe_);
|
cur.niceInsert(save_selection);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
//lyxerr << "inserting 2: safe:\n" << safe_ << endl;
|
//lyxerr << "inserting selection 2:\n" << save_selection << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,8 @@ protected:
|
|||||||
///
|
///
|
||||||
bool interpret(LCursor & cur, char c);
|
bool interpret(LCursor & cur, char c);
|
||||||
///
|
///
|
||||||
bool script(LCursor & cur, bool);
|
bool script(LCursor & cur, bool,
|
||||||
|
std::string const & save_selection = std::string());
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -128,8 +129,6 @@ protected:
|
|||||||
cells_type cells_;
|
cells_type cells_;
|
||||||
/// if the inset is locked, it can't be entered with the cursor
|
/// if the inset is locked, it can't be entered with the cursor
|
||||||
bool lock_;
|
bool lock_;
|
||||||
///
|
|
||||||
std::string safe_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user