-#ifdef __GNUG__
-#pragma implementation
-#endif
#include "math_scriptinset.h"
#include "math_support.h"
{
if (nuc().size())
nuc().draw(pi, x + dxx(), y);
- else if (editing())
- drawStr(pi, pi.base.font, x + dxx(), y, ".");
+ else {
+ nuc().setXY(x + dxx(), y);
+ if (editing())
+ drawStr(pi, pi.base.font, x + dxx(), y, ".");
+ }
MathScriptChanger dummy(pi.base);
if (hasUp())
up().draw(pi, x + dx1(), y - dy1());
}
-void MathScriptInset::removeEmptyScripts()
-{
- for (int i = 0; i <= 1; ++i)
- if (script_[i] && cell(i).size() == 0) {
- cell(i).clear();
- script_[i] = false;
- }
-}
-
-
void MathScriptInset::removeScript(bool up)
{
cell(up).clear();
return false;
// otherwise go to last base position
idx = 2;
- pos = cell(2).size();
+ pos = cell(2).size();
}
else if (idx == 0) {
if (!up)
return false;
idx = 2;
- pos = cell(2).size();
+ pos = cell(2).size();
}
-
+
else {
// in nucleus
- // don't go up/down unless in last position
- if (pos != cell(2).size())
- return false;
// don't go up/down if there is no cell.
if (!has(up))
return false;
- // otherwise move into the first position
- idx = up;
- pos = 0;
+ // go up/down only if in the last position
+ // or in the first position of something with displayed limits
+ if (pos == cell(2).size() || (pos == 0 && hasLimits())) {
+ idx = up;
+ pos = 0;
+ return true;
+ }
+ return false;
}
return true;
}
{
if (nuc().size()) {
os << nuc();
- if (nuc().back()->takesLimits()) {
+ //if (nuc().back()->takesLimits()) {
if (limits_ == -1)
os << "\\nolimits ";
if (limits_ == 1)
os << "\\limits ";
- }
+ //}
} else {
if (os.firstitem())
lyxerr[Debug::MATHED] << "suppressing {} when writing\n";
}
-void MathScriptInset::maplize(MapleStream & os) const
+void MathScriptInset::maple(MapleStream & os) const
{
if (nuc().size())
os << nuc();
}
-void MathScriptInset::mathematicize(MathematicaStream & os) const
+void MathScriptInset::mathematica(MathematicaStream & os) const
{
bool d = hasDown() && down().size();
bool u = hasUp() && up().size();
if (nuc().size()) {
- if (d)
+ if (d)
os << "Subscript[" << nuc();
else
os << nuc();
}
if (u)
- os << "^(" << up() << ")";
+ os << "^(" << up() << ')';
if (nuc().size())
if (d)
- os << "," << down() << "]";
+ os << ',' << down() << ']';
}
}
-void MathScriptInset::octavize(OctaveStream & os) const
+void MathScriptInset::octave(OctaveStream & os) const
{
if (nuc().size())
os << nuc();
void MathScriptInset::infoize(std::ostream & os) const
{
os << "Scripts";
+}
+
+
+void MathScriptInset::infoize2(std::ostream & os) const
+{
if (limits_)
os << (limits_ == 1 ? ", Displayed limits" : ", Inlined limits");
}
-MathInset::result_type MathScriptInset::dispatch
+void MathScriptInset::notifyCursorLeaves(idx_type idx)
+{
+ MathNestInset::notifyCursorLeaves(idx);
+
+ // remove empty scripts if possible
+ if (idx != 2 && script_[idx] && cell(idx).empty()) {
+ cell(idx).clear();
+ script_[idx] = false;
+ }
+}
+
+
+dispatch_result MathScriptInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
if (cmd.action == LFUN_MATH_LIMITS) {
- limits_ = limits_ < 0 ? 1 : -1;
+ if (!cmd.argument.empty()) {
+ if (cmd.argument == "limits")
+ limits_ = 1;
+ else if (cmd.argument == "nolimits")
+ limits_ = -1;
+ else
+ limits_ = 0;
+ } else if (limits_ == 0)
+ limits_ = (hasLimits()) ? -1 : 1;
+ else
+ limits_ = 0;
return DISPATCHED;
}