#include "InsetMathBrace.h"
#include "InsetMathColor.h"
#include "InsetMathComment.h"
-#include "MathArray.h"
#include "InsetMathDelim.h"
-#include "MathFactory.h"
#include "InsetMathHull.h"
-#include "MathStream.h"
-#include "MathMacroArgument.h"
//#include "InsetMathMBox.h"
-#include "MathParser.h"
+#include "InsetMathRef.h"
#include "InsetMathScript.h"
#include "InsetMathSpace.h"
#include "InsetMathSymbol.h"
-#include "MathSupport.h"
#include "InsetMathUnknown.h"
-#include "InsetMathRef.h"
+#include "MathData.h"
+#include "MathFactory.h"
+#include "MathMacroArgument.h"
+#include "MathParser.h"
+#include "MathStream.h"
+#include "MathSupport.h"
-#include "BufferView.h"
-#include "CutAndPaste.h"
-#include "FuncStatus.h"
-#include "LColor.h"
#include "bufferview_funcs.h"
+#include "BufferView.h"
+#include "Color.h"
#include "CoordCache.h"
-#include "LCursor.h"
+#include "Cursor.h"
+#include "CutAndPaste.h"
#include "debug.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
-#include "LyXText.h"
+#include "Text.h"
#include "OutputParams.h"
#include "Undo.h"
#include "frontends/Selection.h"
#include "FuncRequest.h"
-#include "LyXServer.h"
-#include "LyXServerSocket.h"
#include <sstream>
{
// FIXME: This is a hack. Ideally, the coord cache should not store
// absolute positions, but relative ones. This would mean to call
-// setXY() not in MathArray::draw(), but in the parent insets' draw()
+// setXY() not in MathData::draw(), but in the parent insets' draw()
// with the correctly adjusted x,y values. But this means that we'd have
// to touch all (math)inset's draw() methods. Right now, we'll store
// absolute value, and make them here relative, only to make them
// absolute again when actually drawing the cursor. What a mess.
BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
- MathArray const & ar = sl.cell();
+ MathData const & ar = sl.cell();
CoordCache const & coord_cache = bv.coordCache();
if (!coord_cache.getArrays().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
return;
}
Point const pt2 = coord_cache.getInsets().xy(this);
- //lyxerr << "retrieving position cache for MathArray "
+ //lyxerr << "retrieving position cache for MathData "
// << pt.x_ << ' ' << pt.y_ << std::endl;
x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos());
y = pt.y_ - pt2.y_;
}
-bool InsetMathNest::idxNext(LCursor & cur) const
+bool InsetMathNest::idxNext(Cursor & cur) const
{
BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
if (cur.idx() == cur.lastidx())
}
-bool InsetMathNest::idxRight(LCursor & cur) const
+bool InsetMathNest::idxRight(Cursor & cur) const
{
return idxNext(cur);
}
-bool InsetMathNest::idxPrev(LCursor & cur) const
+bool InsetMathNest::idxPrev(Cursor & cur) const
{
BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
if (cur.idx() == 0)
}
-bool InsetMathNest::idxLeft(LCursor & cur) const
+bool InsetMathNest::idxLeft(Cursor & cur) const
{
return idxPrev(cur);
}
-bool InsetMathNest::idxFirst(LCursor & cur) const
+bool InsetMathNest::idxFirst(Cursor & cur) const
{
BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
if (nargs() == 0)
}
-bool InsetMathNest::idxLast(LCursor & cur) const
+bool InsetMathNest::idxLast(Cursor & cur) const
{
BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
if (nargs() == 0)
#if 0
if (lock_)
pi.pain.fillRectangle(x, y - ascent(), width(), height(),
- LColor::mathlockbg);
+ Color::mathlockbg);
#endif
setPosCache(pi, x, y);
}
{
BufferView & bv = *pi.base.bv;
// this should use the x/y values given, not the cached values
- LCursor & cur = bv.cursor();
+ Cursor & cur = bv.cursor();
if (!cur.selection())
return;
if (!ptr_cmp(&cur.inset(), this))
//lyxerr << "InsetMathNest::drawing selection: "
// << " s1: " << s1 << " s2: " << s2 << endl;
if (s1.idx() == s2.idx()) {
- MathArray const & c = cell(s1.idx());
+ MathData const & c = cell(s1.idx());
int x1 = c.xo(bv) + c.pos2x(s1.pos());
int y1 = c.yo(bv) - c.ascent();
int x2 = c.xo(bv) + c.pos2x(s2.pos());
int y2 = c.yo(bv) + c.descent();
- pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
+ pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, Color::selection);
//lyxerr << "InsetMathNest::drawing selection 3: "
// << " x1: " << x1 << " x2: " << x2
// << " y1: " << y1 << " y2: " << y2 << endl;
} else {
for (idx_type i = 0; i < nargs(); ++i) {
if (idxBetween(i, s1.idx(), s2.idx())) {
- MathArray const & c = cell(i);
+ MathData const & c = cell(i);
int x1 = c.xo(bv);
int y1 = c.yo(bv) - c.ascent();
int x2 = c.xo(bv) + c.width();
int y2 = c.yo(bv) + c.descent();
- pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
+ pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, Color::selection);
}
}
}
}
-bool InsetMathNest::contains(MathArray const & ar) const
+bool InsetMathNest::contains(MathData const & ar) const
{
for (idx_type i = 0; i < nargs(); ++i)
if (cell(i).contains(ar))
}
-MathArray InsetMathNest::glue() const
+MathData InsetMathNest::glue() const
{
- MathArray ar;
+ MathData ar;
for (size_t i = 0; i < nargs(); ++i)
ar.append(cell(i));
return ar;
}
-bool InsetMathNest::notifyCursorLeaves(LCursor & /*cur*/)
+bool InsetMathNest::notifyCursorLeaves(Cursor & /*cur*/)
{
#ifdef WITH_WARNINGS
#warning look here
#endif
#if 0
- MathArray & ar = cur.cell();
+ MathData & ar = cur.cell();
// remove base-only "scripts"
for (pos_type i = 0; i + 1 < ar.size(); ++i) {
InsetMathScript * p = operator[](i).nucleus()->asScriptInset();
if (p && p->nargs() == 1) {
- MathArray ar = p->nuc();
+ MathData ar = p->nuc();
erase(i);
insert(i, ar);
cur.adjust(i, ar.size() - 1);
void InsetMathNest::handleFont
- (LCursor & cur, docstring const & arg, char const * const font)
+ (Cursor & cur, docstring const & arg, char const * const font)
{
handleFont(cur, arg, from_ascii(font));
}
void InsetMathNest::handleFont
- (LCursor & cur, docstring const & arg, docstring const & font)
+ (Cursor & cur, docstring const & arg, docstring const & font)
{
// this whole function is a hack and won't work for incremental font
// changes...
}
-void InsetMathNest::handleFont2(LCursor & cur, docstring const & arg)
+void InsetMathNest::handleFont2(Cursor & cur, docstring const & arg)
{
recordUndo(cur, Undo::ATOMIC);
- LyXFont font;
+ Font font;
bool b;
bv_funcs::string2font(to_utf8(arg), font, b);
- if (font.color() != LColor::inherit) {
+ if (font.color() != Color::inherit) {
MathAtom at = MathAtom(new InsetMathColor(true, font.color()));
cur.handleNest(at, 0);
}
}
-void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
{
//lyxerr << "InsetMathNest: request: " << cmd << std::endl;
//CursorSlice sl = cur.current();
cur.autocorrect() = false;
cur.clearTargetX();
cur.macroModeClose();
+ if (cur.isRTL() )
+ goto goto_char_backwards;
+
+goto_char_forwards:
if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
cur.pushLeft(*cur.nextAtom().nucleus());
cur.inset().idxFirst(cur);
cur.autocorrect() = false;
cur.clearTargetX();
cur.macroModeClose();
+ if (cur.isRTL())
+ goto goto_char_forwards;
+
+goto_char_backwards:
if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
cur.posLeft();
cur.push(*cur.nextAtom().nucleus());
// cmd.argument is the next character of the macro name.
// Otherwise we'll get an invalid cursor if we undo after
// the macro was finished and the macro is a known command,
- // e.g. sqrt. LCursor::macroModeClose replaces in this case
+ // e.g. sqrt. Cursor::macroModeClose replaces in this case
// the InsetMathUnknown with name "frac" by an empty
// InsetMathFrac -> a pos value > 0 is invalid.
// A side effect is that an undo before the macro is finished
case LFUN_MATH_MODE: {
#if 1
// ignore math-mode on when already in math mode
- if (currentMode() == InsetBase::MATH_MODE && cmd.argument() == "on")
+ if (currentMode() == Inset::MATH_MODE && cmd.argument() == "on")
break;
cur.macroModeClose();
docstring const save_selection = grabAndEraseSelection(cur);
cur.pushLeft(*cur.nextInset());
cur.niceInsert(save_selection);
#else
- if (currentMode() == InsetBase::TEXT_MODE) {
+ if (currentMode() == Inset::TEXT_MODE) {
cur.niceInsert(MathAtom(new InsetMathHull("simple")));
cur.message(_("create new math text environment ($...$)"));
} else {
rdelim)));
}
// Don't call cur.undispatched() if we did nothing, this would
- // lead to infinite recursion via LyXText::dispatch().
+ // lead to infinite recursion via Text::dispatch().
break;
}
docstring const & name = cmd.argument();
string data;
if (name == "ref") {
- RefInset tmp(name);
+ InsetMathRef tmp(name);
data = tmp.createDialogStr(to_utf8(name));
}
cur.bv().showInsetDialog(to_utf8(name), data, 0);
}
case LFUN_INSET_INSERT: {
- MathArray ar;
+ MathData ar;
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
recordUndo(cur);
cur.insert(ar);
}
default:
- InsetMathDim::doDispatch(cur, cmd);
+ InsetMath::doDispatch(cur, cmd);
break;
}
}
-bool InsetMathNest::getStatus(LCursor & cur, FuncRequest const & cmd,
+bool InsetMathNest::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
// the font related toggles
}
-void InsetMathNest::edit(LCursor & cur, bool left)
+void InsetMathNest::edit(Cursor & cur, bool left)
{
cur.push(*this);
cur.idx() = left ? 0 : cur.lastidx();
}
-InsetBase * InsetMathNest::editXY(LCursor & cur, int x, int y)
+Inset * InsetMathNest::editXY(Cursor & cur, int x, int y)
{
int idx_min = 0;
int dist_min = 1000000;
idx_min = i;
}
}
- MathArray & ar = cell(idx_min);
+ MathData & ar = cell(idx_min);
cur.push(*this);
cur.idx() = idx_min;
cur.pos() = ar.x2pos(x - ar.xo(cur.bv()));
}
-void InsetMathNest::lfunMousePress(LCursor & cur, FuncRequest & cmd)
+void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd)
{
//lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl;
BufferView & bv = cur.bv();
// cur.result().update(): don't overwrite previously set flags.
cur.updateFlags(Update::Decoration | Update::FitCursor | cur.result().update());
} else if (cmd.button() == mouse_button::button2) {
- MathArray ar;
+ MathData ar;
if (cap::selection()) {
- // See comment in LyXText::dispatch why we do this
+ // See comment in Text::dispatch why we do this
cap::copySelectionToStack();
cmd = FuncRequest(LFUN_PASTE, "0");
doDispatch(cur, cmd);
}
-void InsetMathNest::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
+void InsetMathNest::lfunMouseMotion(Cursor & cur, FuncRequest & cmd)
{
// only select with button 1
if (cmd.button() == mouse_button::button1) {
- LCursor & bvcur = cur.bv().cursor();
+ Cursor & bvcur = cur.bv().cursor();
if (bvcur.anchor_.hasPart(cur)) {
//lyxerr << "## lfunMouseMotion: cursor: " << cur << endl;
bvcur.setCursor(cur);
}
-void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
+void InsetMathNest::lfunMouseRelease(Cursor & cur, FuncRequest & cmd)
{
//lyxerr << "## lfunMouseRelease: buttons: " << cmd.button() << endl;
if (!cur.selection())
cur.noUpdate();
else {
- LCursor & bvcur = cur.bv().cursor();
+ Cursor & bvcur = cur.bv().cursor();
bvcur.selection() = true;
cap::saveSelection(bvcur);
}
}
-bool InsetMathNest::interpretChar(LCursor & cur, char_type c)
+bool InsetMathNest::interpretChar(Cursor & cur, char_type c)
{
//lyxerr << "interpret 2: '" << c << "'" << endl;
docstring save_selection;
}
-bool InsetMathNest::interpretString(LCursor & cur, docstring const & str)
+bool InsetMathNest::interpretString(Cursor & cur, docstring const & str)
{
// Create a InsetMathBig from cur.cell()[cur.pos() - 1] and t if
// possible
}
-bool InsetMathNest::script(LCursor & cur, bool up,
+bool InsetMathNest::script(Cursor & cur, bool up,
docstring const & save_selection)
{
// Hack to get \^ and \_ working