mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 23:07:43 +00:00
make undo more granular in mathed
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2951 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9665dd5ff0
commit
fcb060f97d
@ -60,6 +60,7 @@ int sel_x;
|
|||||||
int sel_y;
|
int sel_y;
|
||||||
bool sel_flag;
|
bool sel_flag;
|
||||||
|
|
||||||
|
|
||||||
void handleFont(BufferView * bv, MathTextCodes t)
|
void handleFont(BufferView * bv, MathTextCodes t)
|
||||||
{
|
{
|
||||||
if (mathcursor->selection())
|
if (mathcursor->selection())
|
||||||
@ -77,10 +78,6 @@ void handleAccent(BufferView * bv, string const & name)
|
|||||||
|
|
||||||
bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
|
bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
|
||||||
{
|
{
|
||||||
LyXText * lt = bv->getLyXText();
|
|
||||||
|
|
||||||
bv->beforeChange(lt);
|
|
||||||
finishUndo();
|
|
||||||
if (!bv->insertInset(new_inset)) {
|
if (!bv->insertInset(new_inset)) {
|
||||||
delete new_inset;
|
delete new_inset;
|
||||||
return false;
|
return false;
|
||||||
@ -90,14 +87,6 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns the nearest enclosing grid
|
|
||||||
MathArrayInset * matrixpar(MathInset::idx_type & idx)
|
|
||||||
{
|
|
||||||
idx = 0;
|
|
||||||
return mathcursor ? mathcursor->enclosingArray(idx) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
@ -444,7 +433,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
case LFUN_PASTE:
|
case LFUN_PASTE:
|
||||||
if (was_macro)
|
if (was_macro)
|
||||||
mathcursor->macroModeClose();
|
mathcursor->macroModeClose();
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
mathcursor->selPaste();
|
mathcursor->selPaste();
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
@ -498,7 +487,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MATH_LIMITS:
|
case LFUN_MATH_LIMITS:
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
if (mathcursor->toggleLimits())
|
if (mathcursor->toggleLimits())
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
@ -506,7 +495,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
case LFUN_MATH_SIZE:
|
case LFUN_MATH_SIZE:
|
||||||
#if 0
|
#if 0
|
||||||
if (!arg.empty()) {
|
if (!arg.empty()) {
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
mathcursor->setSize(arg);
|
mathcursor->setSize(arg);
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
}
|
}
|
||||||
@ -515,7 +504,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
|
|
||||||
case LFUN_INSERT_MATRIX:
|
case LFUN_INSERT_MATRIX:
|
||||||
if (!arg.empty()) {
|
if (!arg.empty()) {
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
mathcursor->interpret("matrix " + arg);
|
mathcursor->interpret("matrix " + arg);
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
}
|
}
|
||||||
@ -531,7 +520,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
|
|
||||||
case LFUN_MATH_DELIM:
|
case LFUN_MATH_DELIM:
|
||||||
{
|
{
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
|
||||||
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
|
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
|
||||||
string ls;
|
string ls;
|
||||||
string rs;
|
string rs;
|
||||||
@ -549,7 +537,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
|
|
||||||
case LFUN_PROTECTEDSPACE:
|
case LFUN_PROTECTEDSPACE:
|
||||||
//lyxerr << " called LFUN_PROTECTEDSPACE\n";
|
//lyxerr << " called LFUN_PROTECTEDSPACE\n";
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
mathcursor->insert(MathAtom(new MathSpaceInset(1)));
|
mathcursor->insert(MathAtom(new MathSpaceInset(1)));
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
@ -560,78 +548,28 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
|
|
||||||
|
|
||||||
case LFUN_MATH_HALIGN:
|
case LFUN_MATH_HALIGN:
|
||||||
{
|
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
|
||||||
lyxerr << "handling halign '" << arg << "'\n";
|
|
||||||
MathInset::idx_type idx;
|
|
||||||
MathArrayInset * p = matrixpar(idx);
|
|
||||||
if (!p)
|
|
||||||
break;
|
|
||||||
p->halign(arg.size() ? arg[0] : 'c', p->col(idx));
|
|
||||||
updateLocal(bv, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_MATH_VALIGN:
|
case LFUN_MATH_VALIGN:
|
||||||
{
|
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
|
||||||
lyxerr << "handling valign '" << arg << "'\n";
|
|
||||||
MathInset::idx_type idx;
|
|
||||||
MathArrayInset * p = matrixpar(idx);
|
|
||||||
if (!p)
|
|
||||||
break;
|
|
||||||
p->valign(arg.size() ? arg[0] : 'c');
|
|
||||||
updateLocal(bv, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_MATH_ROW_INSERT:
|
case LFUN_MATH_ROW_INSERT:
|
||||||
{
|
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
|
||||||
MathInset::idx_type idx;
|
|
||||||
MathArrayInset * p = matrixpar(idx);
|
|
||||||
lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
|
|
||||||
if (!p)
|
|
||||||
break;
|
|
||||||
p->addRow(p->row(idx));
|
|
||||||
updateLocal(bv, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_MATH_ROW_DELETE:
|
case LFUN_MATH_ROW_DELETE:
|
||||||
{
|
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
|
||||||
MathInset::idx_type idx;
|
|
||||||
MathArrayInset * p = matrixpar(idx);
|
|
||||||
lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
|
|
||||||
if (!p)
|
|
||||||
break;
|
|
||||||
p->delRow(p->row(idx));
|
|
||||||
updateLocal(bv, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_MATH_COLUMN_INSERT:
|
case LFUN_MATH_COLUMN_INSERT:
|
||||||
{
|
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
|
||||||
MathInset::idx_type idx;
|
|
||||||
MathArrayInset * p = matrixpar(idx);
|
|
||||||
if (!p)
|
|
||||||
break;
|
|
||||||
p->addCol(p->col(idx));
|
|
||||||
updateLocal(bv, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_MATH_COLUMN_DELETE:
|
case LFUN_MATH_COLUMN_DELETE:
|
||||||
{
|
{
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
MathInset::idx_type idx = 0;
|
||||||
MathInset::idx_type idx;
|
MathArrayInset * p = mathcursor ? mathcursor->enclosingArray(idx) : 0;
|
||||||
MathArrayInset * p = matrixpar(idx);
|
if (p) {
|
||||||
if (!p)
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
break;
|
char al = arg.size() ? arg[0] : 'c';
|
||||||
p->delCol(p->col(idx));
|
switch (action) {
|
||||||
|
case LFUN_MATH_HALIGN: p->halign(al, p->col(idx)); break;
|
||||||
|
case LFUN_MATH_VALIGN: p->valign(al); break;
|
||||||
|
case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break;
|
||||||
|
case LFUN_MATH_ROW_DELETE: p->delRow(p->row(idx)); break;
|
||||||
|
case LFUN_MATH_COLUMN_INSERT: p->addCol(p->col(idx)); break;
|
||||||
|
case LFUN_MATH_COLUMN_DELETE: p->delCol(p->col(idx)); break;
|
||||||
|
default: ;
|
||||||
|
}
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +586,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
|||||||
case LFUN_INSERT_MATH:
|
case LFUN_INSERT_MATH:
|
||||||
case LFUN_SELFINSERT:
|
case LFUN_SELFINSERT:
|
||||||
if (!arg.empty()) {
|
if (!arg.empty()) {
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
mathcursor->interpret(arg);
|
mathcursor->interpret(arg);
|
||||||
updateLocal(bv, true);
|
updateLocal(bv, true);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,6 @@ enum {
|
|||||||
FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
|
FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
|
||||||
FLAG_END = 1 << 3, // next \\end ends the parsing process
|
FLAG_END = 1 << 3, // next \\end ends the parsing process
|
||||||
FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing process
|
FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing process
|
||||||
FLAG_NEWLINE = 1 << 6, // next \\\\ ends the parsing process
|
|
||||||
FLAG_ITEM = 1 << 7, // read a (possibly braced token)
|
FLAG_ITEM = 1 << 7, // read a (possibly braced token)
|
||||||
FLAG_BLOCK = 1 << 8, // next block ends the parsing process
|
FLAG_BLOCK = 1 << 8, // next block ends the parsing process
|
||||||
FLAG_LEAVE = 1 << 9 // leave the loop at the end
|
FLAG_LEAVE = 1 << 9 // leave the loop at the end
|
||||||
@ -763,9 +762,10 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
add(array, t.character(), code);
|
add(array, t.character(), code);
|
||||||
|
|
||||||
//
|
//
|
||||||
// codesequences
|
// control sequences
|
||||||
//
|
//
|
||||||
else if (t.cs() == "protect")
|
else if (t.cs() == "protect")
|
||||||
|
// ignore \\protect, will be re-added during output
|
||||||
;
|
;
|
||||||
|
|
||||||
else if (t.cs() == "end")
|
else if (t.cs() == "end")
|
||||||
@ -779,10 +779,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
|
|
||||||
else if (t.cs() == "\\") {
|
else if (t.cs() == "\\") {
|
||||||
curr_skip_ = getArg('[', ']');
|
curr_skip_ = getArg('[', ']');
|
||||||
if (flags & FLAG_NEWLINE)
|
lyxerr << "found newline unexpectedly, array: '" << array << "'\n";
|
||||||
return;
|
|
||||||
lyxerr[Debug::MATHED]
|
|
||||||
<< "found newline unexpectedly, array: '" << array << "'\n";
|
|
||||||
array.push_back(createMathInset("\\"));
|
array.push_back(createMathInset("\\"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user