mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
small stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8605 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
90e427465d
commit
ec744e7583
@ -14,11 +14,13 @@
|
||||
#include "math_data.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_streamstr.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "LColor.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "LColor.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
@ -1184,6 +1186,37 @@ void MathGridInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
|
||||
default:
|
||||
MathNestInset::priv_dispatch(cur, cmd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
bool ret = true;
|
||||
switch (cmd.action) {
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
#if 0
|
||||
// should be more precise
|
||||
if (v_align_ == '\0') {
|
||||
flag.enable(true);
|
||||
break;
|
||||
}
|
||||
if (cmd.argument.empty()) {
|
||||
flag.enable(false);
|
||||
break;
|
||||
}
|
||||
if (!contains("tcb", cmd.argument[0])) {
|
||||
flag.enable(false);
|
||||
break;
|
||||
}
|
||||
flag.setOnOff(cmd.argument[0] == v_align_);
|
||||
#endif
|
||||
flag.enabled(true);
|
||||
break;
|
||||
default:
|
||||
ret = MathNestInset::getStatus(cur, cmd, flag);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -213,6 +213,9 @@ public:
|
||||
protected:
|
||||
///
|
||||
void priv_dispatch(LCursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
bool getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const;
|
||||
/// returns x offset of cell compared to inset
|
||||
int cellXOffset(idx_type idx) const;
|
||||
/// returns y offset of cell compared to inset
|
||||
|
@ -297,9 +297,32 @@ void MathNestInset::normalize(NormalStream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathNestInset::notifyCursorLeaves(idx_type idx)
|
||||
void MathNestInset::notifyCursorLeaves(LCursor & cur)
|
||||
{
|
||||
cell(idx).notifyCursorLeaves();
|
||||
/*
|
||||
MathArray & ar = cur.cell();
|
||||
// remove base-only "scripts"
|
||||
for (pos_type i = 0; i + 1 < size(); ++i) {
|
||||
MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
|
||||
if (p && p->cell(0).empty() && p->cell(1).empty()) {
|
||||
MathArray ar = p->nuc();
|
||||
erase(i);
|
||||
insert(i, ar);
|
||||
mathcursor->adjust(i, ar.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// glue adjacent font insets of the same kind
|
||||
for (pos_type i = 0; i + 1 < size(); ++i) {
|
||||
MathFontInset * p = operator[](i).nucleus()->asFontInset();
|
||||
MathFontInset const * q = operator[](i + 1)->asFontInset();
|
||||
if (p && q && p->name() == q->name()) {
|
||||
p->cell(0).append(q->cell(0));
|
||||
erase(i + 1);
|
||||
mathcursor->adjust(i, -1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -583,7 +606,7 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
bool remove_inset = false;
|
||||
|
||||
DispatchResult result(true);
|
||||
bool was_macro = cur.inMacroMode();
|
||||
bool was_macro = cur.inMacroMode();
|
||||
|
||||
cur.normalize();
|
||||
cur.touch();
|
||||
@ -821,7 +844,7 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
// the font related toggles
|
||||
//string tc = mathcursor::getLastCode();
|
||||
//string tc = "mathnormal";
|
||||
bool ret = true;
|
||||
switch (cmd.action) {
|
||||
#if 0
|
||||
@ -994,9 +1017,10 @@ void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
|
||||
|
||||
bool MathNestInset::interpret(LCursor & cur, char c)
|
||||
{
|
||||
//lyxerr << "interpret 2: '" << c << "'" << endl;
|
||||
lyxerr << "interpret 2: '" << c << "'" << endl;
|
||||
cur.clearTargetX();
|
||||
if (cur.inMacroArgMode()) {
|
||||
/// are we currently typing '#1' or '#2' or...?
|
||||
if (cur.pos() > 0 && cur.prevAtom()->getChar() == '#') {
|
||||
cur.posLeft();
|
||||
cur.plainErase();
|
||||
#ifdef WITH_WARNINGS
|
||||
@ -1164,16 +1188,24 @@ bool MathNestInset::script(LCursor & cur, bool up)
|
||||
// convert the thing to our left to a scriptinset or create a new
|
||||
// one if in the very first position of the array
|
||||
if (cur.pos() == 0) {
|
||||
lyxerr << "new scriptinset" << endl;
|
||||
cur.insert(new MathScriptInset(up));
|
||||
} else {
|
||||
--cur.pos();
|
||||
cur.cell()[cur.pos()] = MathAtom(new MathScriptInset(cur.nextAtom(), up));
|
||||
lyxerr << "converting prev atom " << endl;
|
||||
cur.prevAtom() = MathAtom(new MathScriptInset(cur.prevAtom(), up));
|
||||
}
|
||||
lyxerr << "new scriptinset 2: cur:\n" << cur << endl;
|
||||
--cur.pos();
|
||||
lyxerr << "new scriptinset 3: cur:\n" << cur << endl;
|
||||
MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
|
||||
lyxerr << "new scriptinset 3: inset:\n" << inset << endl;
|
||||
cur.push(*inset);
|
||||
cur.idx() = 1;
|
||||
cur.pos() = 0;
|
||||
}
|
||||
lyxerr << "pasting 1: safe:\n" << safe << endl;
|
||||
cur.paste(safe);
|
||||
cur.resetAnchor();
|
||||
lyxerr << "pasting 2: safe:\n" << safe << endl;
|
||||
return true;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
/// access to the lock
|
||||
void lock(bool);
|
||||
/// get notification when the cursor leaves this inset
|
||||
void notifyCursorLeaves(idx_type);
|
||||
void notifyCursorLeaves(LCursor & cur);
|
||||
|
||||
/// direct access to the cell
|
||||
MathArray & cell(idx_type);
|
||||
|
@ -84,27 +84,19 @@ bool MathScriptInset::idxLast(LCursor & cur) const
|
||||
|
||||
MathArray const & MathScriptInset::down() const
|
||||
{
|
||||
#if 1
|
||||
if (nargs() == 3)
|
||||
return cell(2);
|
||||
BOOST_ASSERT(nargs() > 1);
|
||||
return cell(1);
|
||||
#else
|
||||
return nargs() == 3 ? cell(2) : cell(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
MathArray & MathScriptInset::down()
|
||||
{
|
||||
#if 1
|
||||
if (nargs() == 3)
|
||||
return cell(2);
|
||||
BOOST_ASSERT(nargs() > 1);
|
||||
return cell(1);
|
||||
#else
|
||||
return nargs() == 3 ? cell(2) : cell(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -313,9 +305,12 @@ bool MathScriptInset::hasLimits() const
|
||||
|
||||
void MathScriptInset::removeScript(bool up)
|
||||
{
|
||||
lyxerr << "MathNestInset::removeScript: 1 up: " << up << endl;
|
||||
if (nargs() == 2) {
|
||||
lyxerr << "MathNestInset::removeScript: a up: " << up << endl;
|
||||
if (up == cell_1_is_up_)
|
||||
cells_.pop_back();
|
||||
lyxerr << "MathNestInset::removeScript: b up: " << up << endl;
|
||||
} else if (nargs() == 3) {
|
||||
if (up == true) {
|
||||
swap(cells_[1], cells_[2]);
|
||||
@ -323,7 +318,9 @@ void MathScriptInset::removeScript(bool up)
|
||||
} else {
|
||||
cell_1_is_up_ = true;
|
||||
}
|
||||
cells_.pop_back();
|
||||
}
|
||||
lyxerr << "MathNestInset::removeScript: 2 up: " << up << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -335,16 +332,16 @@ bool MathScriptInset::has(bool up) const
|
||||
|
||||
bool MathScriptInset::hasUp() const
|
||||
{
|
||||
//lyxerr << "hasUp: " << bool(idxOfScript(true)) << endl;
|
||||
//lyxerr << "1up: " << bool(cell_1_is_up_) << endl;
|
||||
//lyxerr << "hasUp: " << bool(idxOfScript(true)) << endl;
|
||||
return idxOfScript(true);
|
||||
}
|
||||
|
||||
|
||||
bool MathScriptInset::hasDown() const
|
||||
{
|
||||
//lyxerr << "hasDown: " << bool(idxOfScript(false)) << endl;
|
||||
//lyxerr << "1up: " << bool(cell_1_is_up_) << endl;
|
||||
//lyxerr << "hasDown: " << bool(idxOfScript(false)) << endl;
|
||||
return idxOfScript(false);
|
||||
}
|
||||
|
||||
@ -354,7 +351,7 @@ InsetBase::idx_type MathScriptInset::idxOfScript(bool up) const
|
||||
if (nargs() == 1)
|
||||
return 0;
|
||||
if (nargs() == 2)
|
||||
return cell_1_is_up_ == up ? 1 : 0;
|
||||
return (cell_1_is_up_ == up) ? 1 : 0;
|
||||
if (nargs() == 3)
|
||||
return up ? 1 : 2;
|
||||
BOOST_ASSERT(false);
|
||||
@ -393,7 +390,7 @@ bool MathScriptInset::idxUpDown(LCursor & cur, bool up) const
|
||||
}
|
||||
|
||||
// Are we 'up'?
|
||||
if (cur.idx() == idxOfScript(true)) {
|
||||
if (has(up) && cur.idx() == idxOfScript(true)) {
|
||||
// can't go further up
|
||||
if (up)
|
||||
return false;
|
||||
@ -404,7 +401,7 @@ bool MathScriptInset::idxUpDown(LCursor & cur, bool up) const
|
||||
}
|
||||
|
||||
// Are we 'down'?
|
||||
if (cur.idx() == idxOfScript(false)) {
|
||||
if (has(up) && cur.idx() == idxOfScript(false)) {
|
||||
// can't go further down
|
||||
if (!up)
|
||||
return false;
|
||||
@ -556,11 +553,26 @@ void MathScriptInset::infoize2(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathScriptInset::notifyCursorLeaves(idx_type idx)
|
||||
void MathScriptInset::notifyCursorLeaves(LCursor & cur)
|
||||
{
|
||||
MathNestInset::notifyCursorLeaves(idx);
|
||||
MathNestInset::notifyCursorLeaves(cur);
|
||||
|
||||
#if 1
|
||||
// remove empty scripts if possible
|
||||
<<<<<<< math_scriptinset.C
|
||||
if (cur.idx() == 2 && cell(2).empty()) {
|
||||
// must be a subscript...
|
||||
removeScript(false);
|
||||
// sanitize cursor, even if this slice will be removed immediately
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
} else if (cur.idx() == 1 && cell(1).empty()) {
|
||||
// could be either subscript or super script
|
||||
removeScript(cell_1_is_up_);
|
||||
// sanitize cursor, even if this slice will be removed immediately
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
=======
|
||||
if (idx == 2 && nargs() > 2 && cell(2).empty()) {
|
||||
removeScript(false); // must be a subscript...
|
||||
} else if (idx == 1 && nargs() > 1 && cell(1).empty()) {
|
||||
@ -571,7 +583,9 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
|
||||
} else if (nargs() == 1) {
|
||||
cells_.pop_back();
|
||||
}
|
||||
>>>>>>> 1.114
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,13 +71,13 @@ public:
|
||||
void limits(int lim) { limits_ = lim; }
|
||||
/// get limits
|
||||
int limits() const { return limits_; }
|
||||
/// returns subscript
|
||||
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
|
||||
MathArray const & down() const;
|
||||
/// returns subscript
|
||||
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
|
||||
MathArray & down();
|
||||
/// returns superscript
|
||||
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
|
||||
MathArray const & up() const;
|
||||
/// returns superscript
|
||||
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
|
||||
MathArray & up();
|
||||
/// returns nucleus
|
||||
MathArray const & nuc() const;
|
||||
@ -122,7 +122,7 @@ private:
|
||||
/// where do we have to draw the scripts?
|
||||
bool hasLimits() const;
|
||||
/// clean up empty cells
|
||||
void notifyCursorLeaves(idx_type idx);
|
||||
void notifyCursorLeaves(LCursor & cur);
|
||||
|
||||
/// possible subscript (index 0) and superscript (index 1)
|
||||
bool cell_1_is_up_;
|
||||
|
Loading…
Reference in New Issue
Block a user