git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8371 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-01-26 10:13:15 +00:00
parent be2ce42c65
commit 1eaa3eb913
74 changed files with 3278 additions and 863 deletions

View File

@ -299,7 +299,7 @@ void BufferView::setCursorFromRow(int row)
}
bool BufferView::insertInset(InsetOld * inset, string const & lout)
bool BufferView::insertInset(InsetBase * inset, string const & lout)
{
return pimpl_->insertInset(inset, lout);
}
@ -410,10 +410,10 @@ Encoding const * BufferView::getEncoding() const
LyXText * t = getLyXText();
if (!t)
return 0;
return t->cursorPar()->getFont(
buffer()->params(),
t->cursor().pos(),
outerFont(t->cursorPar(), t->paragraphs())
CursorSlice const & cur = cursor().innerTextSlice();
return t->getPar(cur.par())->getFont(
buffer()->params(), cur.pos(),
outerFont(t->getPar(cur.par()), t->paragraphs())
).language()->encoding();
}
@ -448,7 +448,7 @@ LyXText * BufferView::text() const
if the fitCursor call refers to some point in never-explored-land, then we
don't have y information in insets there, then we cannot even do an update
to get it (because we need the y infomation for setting top_y first). So
this is solved in put_selection_at with:
this is solved in putSelectionAt with:
- setting top_y to the y of the outerPar (that has good info)
- calling update

View File

@ -24,6 +24,7 @@ class Change;
class Encoding;
class ErrorList;
class FuncRequest;
class InsetBase;
class InsetOld;
class Language;
class LCursor;
@ -140,7 +141,7 @@ public:
* Insert an inset into the buffer.
* Place it in a layout of lout,
*/
bool insertInset(InsetOld * inset, std::string const & lout = std::string());
bool insertInset(InsetBase * inset, std::string const & lout = std::string());
/// Inserts a lyx file at cursor position. return false if it fails
bool insertLyXFile(std::string const & file);

View File

@ -59,7 +59,7 @@
#include "graphics/Previews.h"
#include "mathed/formulabase.h"
#include "mathed/math_hullinset.h"
#include "support/filetools.h"
#include "support/globbing.h"
@ -302,6 +302,9 @@ void BufferView::Pimpl::buffer(Buffer * b)
//bv_->setText(0);
}
// reset old cursor
cursor_.reset();
// set current buffer
buffer_ = b;
@ -403,8 +406,8 @@ void BufferView::Pimpl::resizeCurrentBuffer()
LCursor & cur = bv_->cursor();
par = cur.par();
pos = cur.pos();
selstartpar = cur.selStart().par();
selstartpos = cur.selStart().pos();
selstartpar = cur.selBegin().par();
selstartpos = cur.selBegin().pos();
selendpar = cur.selEnd().par();
selendpos = cur.selEnd().pos();
sel = cur.selection();
@ -646,8 +649,8 @@ Change const BufferView::Pimpl::getCurrentChange()
if (!cur.selection())
return Change(Change::UNCHANGED);
return text->getPar(cur.selStart())
->lookupChangeFull(cur.selStart().pos());
return text->getPar(cur.selBegin())
->lookupChangeFull(cur.selBegin().pos());
}
@ -745,7 +748,7 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
}
InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code)
InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
{
#if 0
CursorSlice cursor = bv_->getLyXText()->cursor;
@ -885,14 +888,16 @@ CursorBase theTempCursor;
namespace {
InsetOld * insetFromCoords(BufferView * bv, int x, int y)
InsetBase * insetFromCoords(BufferView * bv, int x, int y)
{
lyxerr << "insetFromCoords" << endl;
LyXText * text = bv->text();
InsetOld * inset = 0;
InsetBase * inset = 0;
theTempCursor.clear();
LyXText * text = bv->text();
#warning FIXME
#if 0
while (true) {
InsetOld * const inset_hit = text->checkInsetHit(x, y);
InsetBase * const inset_hit = text->checkInsetHit(x, y);
if (!inset_hit) {
lyxerr << "no further inset hit" << endl;
break;
@ -910,6 +915,7 @@ namespace {
<< " text: " << text << " y: " << y << endl;
theTempCursor.push_back(CursorSlice(inset));
}
#endif
//lyxerr << "theTempCursor: " << theTempCursor << endl;
return inset;
}
@ -964,7 +970,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
// handle this event.
// built temporary path to inset
InsetOld * inset = insetFromCoords(bv_, cmd.x, cmd.y);
InsetBase * inset = insetFromCoords(bv_, cmd.x, cmd.y);
DispatchResult res;
// try to dispatch to that inset
@ -1097,7 +1103,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
string label = ev.argument;
if (label.empty()) {
InsetRef * inset =
static_cast<InsetRef*>(getInsetByCode(InsetOld::REF_CODE));
static_cast<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
if (inset) {
label = inset->getContents();
savePosition(0);
@ -1152,7 +1158,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
case LFUN_INSET_INSERT: {
// Same as above.
BOOST_ASSERT(false);
InsetOld * inset = createInset(bv_, ev);
InsetBase * inset = createInset(bv_, ev);
if (!inset || !insertInset(inset))
delete inset;
break;
@ -1160,7 +1166,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
case LFUN_FLOAT_LIST:
if (tclass.floats().typeExist(ev.argument)) {
InsetOld * inset = new InsetFloatList(ev.argument);
InsetBase * inset = new InsetFloatList(ev.argument);
if (!insertInset(inset, tclass.defaultLayoutName()))
delete inset;
} else {
@ -1290,7 +1296,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
}
bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
bool BufferView::Pimpl::insertInset(InsetBase * inset, string const & lout)
{
// not quite sure if we want this...
bv_->text()->recUndo(bv_->text()->cursor().par());
@ -1318,7 +1324,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
}
bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
bool BufferView::Pimpl::ChangeInsets(InsetBase::Code code,
string const & from, string const & to)
{
bool need_update = false;
@ -1360,12 +1366,14 @@ void BufferView::Pimpl::updateParagraphDialog()
{
if (!bv_->owner()->getDialogs().visible("paragraph"))
return;
Paragraph const & par = *bv_->getLyXText()->cursorPar();
CursorSlice const & cur = bv_->cursor().innerTextSlice();
LyXText * text = bv_->cursor().innerText();
Paragraph const & par = *text->getPar(cur.par());
string data;
params2string(par, data);
// Will the paragraph accept changes from the dialog?
InsetOld * const inset = par.inInset();
InsetBase * const inset = cur.inset();
bool const accept =
!(inset && inset->forceDefaultParagraphs(inset));

View File

@ -102,7 +102,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
///
void center();
///
bool insertInset(InsetOld * inset, std::string const & lout = std::string());
bool insertInset(InsetBase * inset, std::string const & lout = std::string());
/// a function should be executed from the workarea
bool workAreaDispatch(FuncRequest const & ev);
/// a function should be executed
@ -148,7 +148,7 @@ private:
* string. May only be used with InsetCommand-derived insets
* Returns true if a screen update is needed.
*/
bool ChangeInsets(InsetOld::Code code, std::string const & from,
bool ChangeInsets(InsetBase::Code code, std::string const & from,
std::string const & to);
///
@ -187,7 +187,7 @@ private:
///
std::vector<Position> saved_positions;
/// Get next inset of this class from current cursor position
InsetOld * getInsetByCode(InsetOld::Code code);
InsetBase * getInsetByCode(InsetBase::Code code);
///
void MenuInsertLyXFile(std::string const & filen);
/// our workarea

View File

@ -1,3 +1,35 @@
2004-01-26 André Pönitz <poenitz@gmx.net>
* BufferView.[Ch]:
* BufferView_pimpl.[Ch]:
* InsetList.[Ch]:
* PosIterator.[Ch]:
* buffer.h:
* bufferview_funcs.C:
* cursor.[Ch]:
* cursor_slice.h:
* factory.[Ch]:
* iterators.[Ch]:
* lyxfind.C:
* lyxfunc.C:
* lyxtext.h:
* output_docbook.C:
* output_latex.C:
* output_linuxdoc.C:
* output_plaintext.C:
* paragraph.[Ch]:
* paragraph_funcs.[Ch]:
* paragraph_pimpl.[Ch]:
* rowpainter.C:
* tabular.C:
* tabular.h:
* text.C:
* text2.C:
* text3.C: more IU: dumps most of the rest of the mathcursor
implementation into cursor.[Ch]; "globalize" a bit of it.
2004-01-25 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): Dialogs::showSearch is no more.

View File

@ -26,12 +26,13 @@ using lyx::pos_type;
using std::endl;
using std::lower_bound;
namespace {
class InsetTablePosLess : public std::binary_function<InsetList::InsetTable, InsetList::InsetTable, bool> {
public:
bool operator()(InsetList::InsetTable const & t1,
InsetList::InsetTable const & t2) const
typedef InsetList::InsetTable Table;
struct InsetTablePosLess : public std::binary_function<Table, Table, bool> {
bool operator()(Table const & t1, Table const & t2) const
{
return t1.pos < t2.pos;
}
@ -39,6 +40,8 @@ public:
} // namespace anon
InsetList::~InsetList()
{
// If we begin storing a shared_ptr in the List
@ -67,7 +70,7 @@ InsetList::const_iterator InsetList::insetIterator(pos_type pos) const
}
void InsetList::insert(InsetOld * inset, lyx::pos_type pos)
void InsetList::insert(InsetBase * inset, lyx::pos_type pos)
{
List::iterator end = list.end();
List::iterator it = insetIterator(pos);
@ -91,12 +94,12 @@ void InsetList::erase(pos_type pos)
}
InsetOld * InsetList::release(pos_type pos)
InsetBase * InsetList::release(pos_type pos)
{
List::iterator end = list.end();
List::iterator it = insetIterator(pos);
if (it != end && it->pos == pos) {
InsetOld * tmp = it->inset;
InsetBase * tmp = it->inset;
it->inset = 0;
return tmp;
}
@ -104,7 +107,7 @@ InsetOld * InsetList::release(pos_type pos)
}
InsetOld * InsetList::get(pos_type pos) const
InsetBase * InsetList::get(pos_type pos) const
{
List::const_iterator end = list.end();
List::const_iterator it = insetIterator(pos);
@ -139,8 +142,9 @@ void InsetList::insetsOpenCloseBranch(Buffer const & buf)
List::iterator it = list.begin();
List::iterator end = list.end();
for (; it != end; ++it) {
if (!it->inset ||
it->inset->lyxCode() != InsetOld::BRANCH_CODE)
if (!it->inset)
continue;
if (it->inset->lyxCode() != InsetBase::BRANCH_CODE)
continue;
InsetBranch * inset = static_cast<InsetBranch *>(it->inset);

View File

@ -16,7 +16,7 @@
#include <vector>
class InsetOld;
class InsetBase;
class Buffer;
@ -28,9 +28,9 @@ public:
///
lyx::pos_type pos;
///
InsetOld * inset;
InsetBase * inset;
///
InsetTable(lyx::pos_type p, InsetOld * i) : pos(p), inset(i) {}
InsetTable(lyx::pos_type p, InsetBase * i) : pos(p), inset(i) {}
};
///
typedef std::vector<InsetTable> List;
@ -56,13 +56,13 @@ public:
///
const_iterator insetIterator(lyx::pos_type pos) const;
///
void insert(InsetOld * inset, lyx::pos_type pos);
void insert(InsetBase * inset, lyx::pos_type pos);
///
void erase(lyx::pos_type pos);
///
InsetOld * release(lyx::pos_type);
InsetBase * release(lyx::pos_type);
///
InsetOld * get(lyx::pos_type pos) const;
InsetBase * get(lyx::pos_type pos) const;
///
void increasePosAfterPos(lyx::pos_type pos);
///

View File

@ -35,7 +35,7 @@ PosIterator & PosIterator::operator++()
PosIteratorItem & p = stack_.back();
if (p.pos < p.pit->size()) {
if (InsetOld * inset = p.pit->getInset(p.pos)) {
if (InsetBase * inset = p.pit->getInset(p.pos)) {
if (LyXText * text = inset->getText(p.index)) {
ParagraphList & pl = text->paragraphs();
p.index++;
@ -68,7 +68,7 @@ PosIterator & PosIterator::operator--()
PosIteratorItem & p = stack_.back();
if (p.pos > 0) {
--p.pos;
InsetOld * inset = p.pit->getInset(p.pos);
InsetBase * inset = p.pit->getInset(p.pos);
if (inset)
p.index = inset->numParagraphs();
} else {
@ -85,7 +85,7 @@ PosIterator & PosIterator::operator--()
// try to push an item if there is some left unexplored
PosIteratorItem & q = stack_.back();
if (q.pos < q.pit->size()) {
InsetOld * inset = q.pit->getInset(q.pos);
InsetBase * inset = q.pit->getInset(q.pos);
if (inset && q.index > 0) {
LyXText * text = inset->getText(q.index - 1);
BOOST_ASSERT(text);
@ -144,7 +144,7 @@ PosIterator::PosIterator(BufferView & bv)
}
InsetOld * PosIterator::inset() const
InsetBase * PosIterator::inset() const
{
if (stack_.size() == 1)
return 0;
@ -155,9 +155,8 @@ InsetOld * PosIterator::inset() const
int distance(PosIterator const & cur, PosIterator const & end)
{
PosIterator p = cur;
int count = 0;
for (; p != end; ++p, ++count)
for (PosIterator p = cur; p != end; ++p, ++count)
;
return count;
}

View File

@ -22,8 +22,7 @@
class BufferView;
struct PosIteratorItem
{
struct PosIteratorItem {
PosIteratorItem(ParagraphList * pl,
ParagraphList::iterator pit,
lyx::pos_type pos,
@ -36,8 +35,7 @@ struct PosIteratorItem
};
class PosIterator
{
class PosIterator {
public:
PosIterator(BufferView & bv);
PosIterator(ParIterator & par, lyx::pos_type pos);
@ -51,7 +49,7 @@ public:
ParagraphList::iterator pit() const { return stack_.back().pit; }
lyx::pos_type pos() const { return stack_.back().pos; }
bool at_end() const;
InsetOld * inset() const;
InsetBase * inset() const;
friend PosIterator ParIterator::asPosIterator(lyx::pos_type) const;
friend ParIterator::ParIterator(PosIterator const &);
@ -61,6 +59,7 @@ private:
std::vector<PosIteratorItem> stack_;
};
bool operator!=(PosIterator const &, PosIterator const &);
bool operator==(PosIterator const &, PosIterator const &);

View File

@ -31,15 +31,16 @@
class BufferParams;
class ErrorItem;
class FuncRequest;
class InsetBase;
class LyXFont;
class LyXLex;
class LyXRC;
class LyXText;
class LyXVC;
class LaTeXFeatures;
class OutputParams;
class Language;
class Messages;
class OutputParams;
class ParIterator;
class PosIterator;
class ParConstIterator;
@ -282,10 +283,10 @@ public:
class inset_iterator {
public:
typedef std::input_iterator_tag iterator_category;
typedef InsetOld value_type;
typedef InsetBase value_type;
typedef ptrdiff_t difference_type;
typedef InsetOld * pointer;
typedef InsetOld & reference;
typedef InsetBase * pointer;
typedef InsetBase & reference;
typedef ParagraphList::iterator base_type;
///

View File

@ -34,10 +34,7 @@
#include "insets/insettext.h"
#include "mathed/math_cursor.h"
#include "support/tostr.h"
#include "support/std_sstream.h"
using lyx::support::bformat;
@ -169,7 +166,7 @@ string const currentState(BufferView * bv)
if (!bv->available())
return string();
if (inMathed()) {
if (bv->cursor().inMathed()) {
bv->cursor().info(state);
return state.str();
}

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,11 @@ class LyXText;
class Paragraph;
// these should go
class MathHullInset;
class PainterInfo;
class MathUnknownInset;
class MathGridInset;
// this is used for traversing math insets
typedef std::vector<CursorSlice> CursorBase;
@ -59,12 +64,18 @@ public:
explicit LCursor(BufferView & bv);
/// dispatch from innermost inset upwards
DispatchResult dispatch(FuncRequest const & cmd);
///
/// add a new cursor slice
void push(InsetBase * inset);
/// restrict cursor nesting to given size
void pop(int depth);
/// add a new cursor slice, place cursor on left end
void pushLeft(InsetBase * inset);
/// pop one level off the cursor
void pop();
/// pop one slice off the cursor stack and go left
bool popLeft();
/// pop one slice off the cursor stack and go right
bool popRight();
/// restrict cursor nesting to given size
void pop(int depth);
/// access to current cursor slice
CursorSlice & current();
/// access to current cursor slice
@ -85,26 +96,55 @@ public:
bool & mark() { return mark_; }
///
void setSelection();
/// set selection at given position
void setSelection(CursorBase const & where, size_t n);
///
void clearSelection();
///
CursorSlice & selStart();
///
CursorSlice const & selStart() const;
///
/// access start of selection
CursorSlice & selBegin();
/// access start of selection
CursorSlice const & selBegin() const;
/// access end of selection
CursorSlice & selEnd();
///
/// access end of selection
CursorSlice const & selEnd() const;
///
std::string grabSelection();
///
void eraseSelection();
///
std::string grabAndEraseSelection();
// other selection methods
///
void selCopy();
///
void selCut();
///
void selDel();
/// pastes n-th element of cut buffer
void selPaste(size_t n);
///
void selHandle(bool selecting);
/// start selection
void selStart();
/// clear selection
void selClear();
/// clears or deletes selection depending on lyxrc setting
void selClearOrDel();
///
void paste(std::string const & data);
//
// access to the 'current' cursor slice
//
/// the current inset
InsetBase * inset() const { return current().inset(); }
/// return the text-ed cell this cursor is in
/// return the cell of the inset this cursor is in
idx_type idx() const { return current().idx(); }
/// return the text-ed cell this cursor is in
/// return the cell of the inset this cursor is in
idx_type & idx() { return current().idx(); }
/// return the last possible cell in this inset
idx_type lastidx() const { return current().lastidx(); }
/// return the paragraph this cursor is in
par_type par() const { return current().par(); }
/// return the paragraph this cursor is in
@ -164,6 +204,8 @@ public:
InsetTabular * innerInsetTabular() const;
///
LyXText * innerText() const;
///
CursorSlice const & innerTextSlice() const;
/// returns x,y position
void getPos(int & x, int & y) const;
/// returns cursor dimension
@ -194,6 +236,10 @@ public:
BufferView & bv() const;
/// get some interesting description of current position
void info(std::ostream & os);
/// are we in math mode (2), text mode (1) or unsure (0)?
int currentMode();
/// reset cursor
void reset();
/// output
friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
@ -241,6 +287,137 @@ private:
bool autocorrect_;
/// are we entering a macro name?
bool macromode_;
///////////////////////////////////////////////////////////////////
//
// The part below is the non-integrated rest of the original math
// cursor. This should be either generalized for texted or moved
// back to the math insets.
//
///////////////////////////////////////////////////////////////////
public:
///
void insert(MathAtom const &);
///
void insert(MathArray const &);
///
void insert2(std::string const &);
/// return false for empty math insets
bool erase();
/// return false for empty math insets
bool backspace();
/// called for LFUN_HOME etc
bool home();
/// called for LFUN_END etc
bool end();
/// called for LFUN_RIGHT and LFUN_RIGHTSEL
bool right();
/// called for LFUN_LEFT etc
bool left();
/// called for LFUN_UP etc
bool up();
/// called for LFUN_DOWN etc
bool down();
///
void plainErase();
///
void plainInsert(MathAtom const & at);
///
void niceInsert(MathAtom const & at);
///
void niceInsert(std::string const & str);
/// in pixels from top of screen
void setScreenPos(int x, int y);
/// in pixels from top of screen
void getScreenPos(int & x, int & y) const;
/// in pixels from left of screen
int targetX() const;
/// return the next enclosing grid inset and the cursor's index in it
MathGridInset * enclosingGrid(idx_type & idx) const;
/// adjust anchor position after deletions/insertions
void adjust(pos_type from, int diff);
///
MathHullInset * formula() const;
/// current offset in the current cell
///
bool script(bool);
///
bool interpret(char);
/// interpret name a name of a macro
void macroModeClose();
/// are we currently typing the name of a macro?
bool inMacroMode() const;
/// get access to the macro we are currently typing
MathUnknownInset * activeMacro();
/// are we currently typing '#1' or '#2' or...?
bool inMacroArgMode() const;
/// draws light-blue selection background
void drawSelection(PainterInfo & pi);
/// replace selected stuff with at, placing the former
// selection in given cell of atom
void handleNest(MathAtom const & at, int cell = 0);
/// remove this as soon as LyXFunc::getStatus is "localized"
//inline std::string getLastCode() { return "mathnormal"; }
///
bool isInside(InsetBase const *);
///
char valign();
///
char halign();
/// make sure cursor position is valid
void normalize();
/// mark current cursor trace for redraw
void touch();
/// returns the normalized anchor of the selection
CursorSlice normalAnchor();
///
void insert(char c);
///
void insert(std::string const & str);
/// lock/unlock inset
void lockToggle();
/// hack for reveal codes
void markInsert();
void markErase();
/// injects content of a cell into parent
void pullArg();
/// split font inset etc
void handleFont(std::string const & font);
void releaseMathCursor();
bool inMathed() const;
private:
/// moves cursor index one cell to the left
bool idxLeft();
/// moves cursor index one cell to the right
bool idxRight();
/// moves cursor to end of last cell of current line
bool idxLineLast();
/// moves position somehow up or down
bool goUpDown(bool up);
/// moves position closest to (x, y) in given box
bool bruteFind(int x, int y, int xlow, int xhigh, int ylow, int yhigh);
/// moves position closest to (x, y) in current cell
void bruteFind2(int x, int y);
/// are we in a nucleus of a script inset?
bool inNucleus();
/// the name of the macro we are currently inputting
std::string macroName();
/// where in the curent cell does the macro name start?
int macroNamePos();
/// can we enter the inset?
bool openable(MathAtom const &);
};
#endif // LYXCURSOR_H

View File

@ -60,10 +60,12 @@ public:
InsetBase * inset() const { return inset_; }
/// set the paragraph that contains this cursor
void idx(idx_type idx);
/// return the paragraph this cursor is in
/// return the cell this cursor is in
idx_type idx() const;
/// return the paragraph this cursor is in
/// return the cell this cursor is in
idx_type & idx();
/// return the last cell in this inset
idx_type lastidx() const { return nargs() - 1; }
/// set the paragraph that contains this cursor
void par(par_type par);
/// return the paragraph this cursor is in

View File

@ -52,11 +52,13 @@
#include "insets/inseturl.h"
#include "insets/insetvspace.h"
#include "insets/insetwrap.h"
#include "mathed/formulamacro.h"
#include "mathed/formula.h"
#include "mathed/math_hullinset.h"
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
#include "support/lstrings.h"
#include "support/std_sstream.h"
@ -69,7 +71,7 @@ using std::endl;
using std::string;
InsetOld * createInset(BufferView * bv, FuncRequest const & cmd)
InsetBase * createInset(BufferView * bv, FuncRequest const & cmd)
{
BufferParams const & params = bv->buffer()->params();
@ -330,7 +332,7 @@ InsetOld * createInset(BufferView * bv, FuncRequest const & cmd)
}
InsetOld * readInset(LyXLex & lex, Buffer const & buf)
InsetBase * readInset(LyXLex & lex, Buffer const & buf)
{
// consistency check
if (lex.getString() != "\\begin_inset") {
@ -338,7 +340,7 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
<< endl;
}
auto_ptr<InsetOld> inset;
auto_ptr<InsetBase> inset;
LyXTextClass tclass = buf.params().getLyXTextClass();
@ -405,7 +407,7 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
} else if (tmptok == "FormulaMacro") {
inset.reset(new InsetFormulaMacro);
} else if (tmptok == "Formula") {
inset.reset(new InsetFormula);
inset.reset(new MathHullInset);
} else if (tmptok == "Graphics") {
inset.reset(new InsetGraphics);
} else if (tmptok == "Note") {

View File

@ -15,14 +15,14 @@
class Buffer;
class BufferView;
class FuncRequest;
class InsetOld;
class InsetBase;
class LyXLex;
/// creates inset according to 'cmd'
InsetOld * createInset(BufferView * bv, FuncRequest const & cmd);
InsetBase * createInset(BufferView * bv, FuncRequest const & cmd);
/// read inset from a file
InsetOld * readInset(LyXLex & lex, Buffer const & buf);
InsetBase * readInset(LyXLex & lex, Buffer const & buf);
#endif // FACTORY_H

View File

@ -21,6 +21,7 @@
#include "bufferparams.h"
#include "BufferView.h"
#include "bufferview_funcs.h"
#include "cursor.h"
#include "debug.h"
#include "funcrequest.h"
#include "gettext.h"
@ -34,8 +35,6 @@
#include "controllers/ControlCommandBuffer.h"
#include "mathed/math_cursor.h"
#include "support/filetools.h" // OnlyFilename()
#include <boost/bind.hpp>
@ -105,7 +104,7 @@ void LyXView::setLayout(string const & layout)
void LyXView::updateToolbar()
{
bool const math = inMathed();
bool const math = bufferview_->cursor().inMathed();
bool const table =
!getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).disabled();
toolbar_->update(math, table);

View File

@ -41,30 +41,6 @@ InsetOld::InsetOld(InsetOld const & in)
{}
bool InsetOld::directWrite() const
{
return false;
}
InsetOld::EDITABLE InsetOld::editable() const
{
return NOT_EDITABLE;
}
bool InsetOld::autoDelete() const
{
return false;
}
string const InsetOld::editMessage() const
{
return _("Opened inset");
}
void InsetOld::setBackgroundColor(LColor_color color)
{
background_color_ = color;
@ -77,7 +53,7 @@ LColor_color InsetOld::backgroundColor() const
}
bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
bool InsetOld::forceDefaultParagraphs(InsetBase const * inset) const
{
if (owner())
return owner()->forceDefaultParagraphs(inset);
@ -103,52 +79,9 @@ int InsetOld::width() const
}
bool InsetOld::insetAllowed(InsetOld * in) const
{
return insetAllowed(in->lyxCode());
}
int InsetOld::scroll(bool recursive) const
{
if (!recursive || !owner_)
return scx;
return 0;
}
int InsetOld::getCell(int x, int y) const
{
for (int i = 0, n = numParagraphs(); i < n; ++i) {
LyXText * text = getText(i);
//lyxerr << "### text: " << text << " i: " << i
// << " xo: " << text->xo_ << "..." << text->xo_ + text->width
// << " yo: " << text->yo_
// << " yo: " << text->yo_ - text->ascent() << "..."
// << text->yo_ + text->descent()
// << std::endl;
if (x >= text->xo_
&& x <= text->xo_ + text->width
&& y >= text->yo_
&& y <= text->yo_ + text->height)
{
lyxerr << "### found text # " << i << std::endl;
return i;
}
}
return -1;
}
bool isEditableInset(InsetOld const * i)
{
return i && i->editable();
}
bool isHighlyEditableInset(InsetOld const * i)
{
return i && i->editable() == InsetOld::HIGHLY_EDITABLE;
}

View File

@ -18,23 +18,9 @@
#include "insetbase.h"
#include "dimension.h"
class Buffer;
class LColor_color;
class FuncRequest;
class OutputParams;
class CursorSlice;
class LyXLex;
class LyXText;
class Painter;
class Paragraph;
class UpdatableInset;
namespace lyx {
namespace graphics {
class PreviewLoader;
}
}
/// Insets
class InsetOld : public InsetBase {
@ -45,16 +31,6 @@ public:
TEXT_TO_INSET_OFFSET = 2
};
///
enum EDITABLE {
///
NOT_EDITABLE = 0,
///
IS_EDITABLE,
///
HIGHLY_EDITABLE
};
///
InsetOld();
///
@ -65,39 +41,6 @@ public:
int descent() const;
///
int width() const;
/// what appears in the minibuffer when opening
virtual std::string const editMessage() const;
///
virtual EDITABLE editable() const;
/// can we go further down on mouse click?
virtual bool descendable() const { return false; }
///
virtual bool isTextInset() const { return false; }
/// return true if the inset should be removed automatically
virtual bool autoDelete() const;
/// returns true the inset can hold an inset of given type
virtual bool insetAllowed(InsetOld::Code) const { return false; }
/// wrapper around the above
bool insetAllowed(InsetOld * in) const;
///
virtual void write(Buffer const &, std::ostream &) const = 0;
///
virtual void read(Buffer const &, LyXLex & lex) = 0;
/// returns the number of rows (\n's) of generated tex code.
virtual int latex(Buffer const &, std::ostream &,
OutputParams const &) const = 0;
///
virtual int plaintext(Buffer const &, std::ostream &,
OutputParams const &) const = 0;
///
virtual int linuxdoc(Buffer const &, std::ostream &,
OutputParams const &) const = 0;
///
virtual int docbook(Buffer const &, std::ostream &,
OutputParams const &) const = 0;
/// returns true to override begin and end inset in file
virtual bool directWrite() const;
///
void setInsetName(std::string const & s) { name_ = s; }
@ -118,52 +61,8 @@ public:
/// returns the actual scroll-value
virtual int scroll(bool recursive = true) const;
/// if this insets owns text cells (e.g. InsetText) return cell num
virtual LyXText * getText(int /*num*/) const { return 0; }
///
virtual int numParagraphs() const { return 0; }
/// returns cell covering position (x,y), -1 if none exists
virtual int getCell(int x, int y) const;
/// used to toggle insets
// is the inset open?
virtual bool isOpen() const { return false; }
/// open the inset
virtual void open() {}
/// close the inset
virtual void close() {}
// should this inset be handled like a normal charater
virtual bool isChar() const { return false; }
// is this equivalent to a letter?
virtual bool isLetter() const { return false; }
// is this equivalent to a space (which is BTW different from
// a line separator)?
virtual bool isSpace() const { return false; }
// should we have a non-filled line before this inset?
virtual bool display() const { return false; }
// should we break lines after this inset?
virtual bool isLineSeparator() const { return false; }
// if this inset has paragraphs should they be output all as default
// paragraphs with "Standard" layout?
virtual bool forceDefaultParagraphs(InsetOld const *) const;
/** returns true if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for
insets that may contain several paragraphs */
virtual bool noFontChange() const { return false; }
/// mark the inset contents as erased (for change tracking)
virtual void markErased() {}
/// does this inset allows spellchecking?
virtual bool allowSpellCheck() const { return true; }
/** Adds a LaTeX snippet to the Preview Loader for transformation
* into a bitmap image. Does not start the laoding process.
*
* Most insets have no interest in this capability, so the method
* defaults to empty.
*/
virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
bool forceDefaultParagraphs(InsetBase const * inset) const;
protected:
///
mutable int xo_;
@ -197,18 +96,4 @@ public:
operator InsetOld::Code() const { return val_; }
};
/**
* returns true if pointer argument is valid
* and points to an editable inset
*/
bool isEditableInset(InsetOld const * inset);
/**
* returns true if pointer argument is valid
* and points to a highly editable inset
*/
bool isHighlyEditableInset(InsetOld const * inset);
#endif

View File

@ -13,6 +13,8 @@
#include "insetbase.h"
#include "debug.h"
#include "dispatchresult.h"
#include "gettext.h"
#include "lyxtext.h"
DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
@ -21,7 +23,7 @@ DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
}
DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const & cmd)
DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &)
{
return DispatchResult(false);
}
@ -38,3 +40,138 @@ void InsetBase::edit(LCursor & cur, int, int)
lyxerr << "InsetBase: edit xy" << std::endl;
edit(cur, true);
}
InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
{
if (row != 0)
lyxerr << "illegal row: " << row << std::endl;
if (col != 0)
lyxerr << "illegal col: " << col << std::endl;
return 0;
}
bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
{
return from <= idx && idx <= to;
}
bool InsetBase::idxUpDown(LCursor &, bool) const
{
return false;
}
bool InsetBase::idxUpDown2(LCursor &, bool) const
{
return false;
}
void InsetBase::getScreenPos(idx_type, pos_type, int & x, int & y) const
{
lyxerr << "InsetBase::getScreenPos() called directly!" << std::endl;
x = y = 0;
}
int InsetBase::plaintext(Buffer const &,
std::ostream &, OutputParams const &) const
{
return 0;
}
int InsetBase::linuxdoc(Buffer const &,
std::ostream &, OutputParams const &) const
{
return 0;
}
int InsetBase::docbook(Buffer const &,
std::ostream &, OutputParams const &) const
{
return 0;
}
bool InsetBase::directWrite() const
{
return false;
}
InsetBase::EDITABLE InsetBase::editable() const
{
return NOT_EDITABLE;
}
bool InsetBase::autoDelete() const
{
return false;
}
std::string const InsetBase::editMessage() const
{
return _("Opened inset");
}
bool InsetBase::insetAllowed(InsetBase * inset) const
{
return insetAllowed(inset->lyxCode());
}
std::string const & InsetBase::getInsetName() const
{
static std::string const name = "unknown";
return name;
}
int InsetBase::getCell(int x, int y) const
{
for (int i = 0, n = numParagraphs(); i < n; ++i) {
LyXText * text = getText(i);
//lyxerr << "### text: " << text << " i: " << i
// << " xo: " << text->xo_ << "..." << text->xo_ + text->width
// << " yo: " << text->yo_
// << " yo: " << text->yo_ - text->ascent() << "..."
// << text->yo_ + text->descent()
// << std::endl;
if (x >= text->xo_
&& x <= text->xo_ + text->width
&& y >= text->yo_
&& y <= text->yo_ + text->height)
{
lyxerr << "### found text # " << i << std::endl;
return i;
}
}
return -1;
}
void InsetBase::markErased()
{}
/////////////////////////////////////////
bool isEditableInset(InsetBase const * i)
{
return i && i->editable();
}
bool isHighlyEditableInset(InsetBase const * i)
{
return i && i->editable() == InsetBase::HIGHLY_EDITABLE;
}

View File

@ -22,13 +22,24 @@ class DispatchResult;
class FuncRequest;
class LaTeXFeatures;
class LCursor;
class LyXLex;
class LyXText;
class MathInset;
class MetricsInfo;
class Dimension;
class PainterInfo;
class OutputParams;
class UpdatableInset;
namespace lyx { namespace graphics { class PreviewLoader; } }
/// Common base class to all insets
// Do not add _any_ (non-static) data members as this would inflate
// everything storing large quantities of insets. Mathed e.g. would
// suffer.
class InsetBase {
public:
///
@ -71,27 +82,104 @@ public:
/// last drawn position for 'important' insets
virtual int y() const { return 0; }
/// is this an inset that can be moved into?
virtual bool isActive() const { return nargs() > 0; }
/// Where should we go when we press the up or down cursor key?
virtual bool idxUpDown(LCursor & cur, bool up) const;
/// Where should we go when we press the up or down cursor key?
virtual bool idxUpDown2(LCursor & cur, bool up) const;
/// Move one cell to the left
virtual bool idxLeft(LCursor &) const { return false; }
/// Move one cell to the right
virtual bool idxRight(LCursor &) const { return false; }
/// Move one physical cell up
virtual bool idxNext(LCursor &) const { return false; }
/// Move one physical cell down
virtual bool idxPrev(LCursor &) const { return false; }
/// Target pos when we enter the inset from the left by pressing "Right"
virtual bool idxFirst(LCursor &) const { return false; }
/// Target pos when we enter the inset from the right by pressing "Left"
virtual bool idxLast(LCursor &) const { return false; }
/// Where should we go if we press home?
virtual bool idxHome(LCursor &) const { return false; }
/// Where should we go if we press end?
virtual bool idxEnd(LCursor &) const { return false; }
/// Delete a cell and move cursor
virtual bool idxDelete(idx_type &) { return false; }
/// pulls cell after pressing erase
virtual void idxGlue(idx_type) {}
// returns list of cell indices that are "between" from and to for
// selection purposes
virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
/// to which column belongs a cell with a given index?
virtual col_type col(idx_type) const { return 0; }
/// to which row belongs a cell with a given index?
virtual row_type row(idx_type) const { return 0; }
/// cell idex corresponding to row and column;
virtual idx_type index(row_type row, col_type col) const;
/// any additional x-offset when drawing a cell?
virtual int cellXOffset(idx_type) const { return 0; }
/// any additional y-offset when drawing a cell?
virtual int cellYOffset(idx_type) const { return 0; }
/// can we enter this cell?
virtual bool validCell(idx_type) const { return true; }
/// get coordinates
virtual void getScreenPos(idx_type idx, pos_type pos, int & x, int & y) const;
/// number of embedded cells
virtual size_t nargs() const { return 0; }
/// number of rows in gridlike structures
virtual size_t nrows() const { return 0; }
/// number of columns in gridlike structures
virtual size_t ncols() const { return 0; }
/// is called when the cursor leaves this inset
virtual void notifyCursorLeaves(idx_type) {}
/// request "external features"
virtual void validate(LaTeXFeatures &) const {}
/// Appends \c list with all labels found within this inset.
virtual void getLabelList(Buffer const &,
std::vector<std::string> & /* list */) const {}
/// describe content if cursor inside
virtual void infoize(std::ostream &) const {}
/// describe content if cursor behind
virtual void infoize2(std::ostream &) const {}
protected:
// the real dispatcher
virtual
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
public:
/// plain ascii output
virtual int plaintext(Buffer const &, std::ostream & os,
OutputParams const &) const;
/// linuxdoc output
virtual int linuxdoc(Buffer const &, std::ostream & os,
OutputParams const &) const;
/// docbook output
virtual int docbook(Buffer const &, std::ostream & os,
OutputParams const &) const;
///
enum EDITABLE {
///
NOT_EDITABLE = 0,
///
IS_EDITABLE,
///
HIGHLY_EDITABLE
};
/// what appears in the minibuffer when opening
virtual std::string const editMessage() const;
///
virtual EDITABLE editable() const;
/// can we go further down on mouse click?
virtual bool descendable() const { return false; }
///
virtual bool isTextInset() const { return false; }
/// return true if the inset should be removed automatically
virtual bool autoDelete() const;
/** This is not quite the correct place for this enum. I think
the correct would be to let each subclass of Inset declare
its own enum code. Actually the notion of an InsetOld::Code
@ -193,9 +281,102 @@ public:
///
MATHHULL_CODE
};
/// returns LyX code associated with the inset. Used for TOC, ...)
virtual InsetBase::Code lyxCode() const { return NO_CODE; }
/// returns true the inset can hold an inset of given type
virtual bool insetAllowed(Code) const { return false; }
/// wrapper around the above
bool insetAllowed(InsetBase * inset) const;
// if this inset has paragraphs should they be output all as default
// paragraphs with "Standard" layout?
virtual bool forceDefaultParagraphs(InsetBase const *) const { return false; }
///
virtual std::string const & getInsetName() const;
/// used to toggle insets
// is the inset open?
virtual bool isOpen() const { return false; }
/// open the inset
virtual void open() {}
/// close the inset
virtual void close() {}
// should this inset be handled like a normal charater
virtual bool isChar() const { return false; }
// is this equivalent to a letter?
virtual bool isLetter() const { return false; }
// is this equivalent to a space (which is BTW different from
// a line separator)?
virtual bool isSpace() const { return false; }
// should we have a non-filled line before this inset?
virtual bool display() const { return false; }
// should we break lines after this inset?
virtual bool isLineSeparator() const { return false; }
///
virtual void write(Buffer const &, std::ostream &) const {}
///
virtual void read(Buffer const &, LyXLex &) {}
/// returns the number of rows (\n's) of generated tex code.
virtual int latex(Buffer const &, std::ostream &,
OutputParams const &) const { return 0; }
/// returns true to override begin and end inset in file
virtual bool directWrite() const;
///
virtual bool allowSpellCheck() const { return false; }
/// if this insets owns text cells (e.g. InsetText) return cell num
virtual LyXText * getText(int /*num*/) const { return 0; }
///
virtual int numParagraphs() const { return 0; }
/// returns cell covering position (x,y), -1 if none exists
virtual int getCell(int x, int y) const;
/** Adds a LaTeX snippet to the Preview Loader for transformation
* into a bitmap image. Does not start the laoding process.
*
* Most insets have no interest in this capability, so the method
* defaults to empty.
*/
virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
protected:
// the real dispatcher
virtual
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
public:
/// returns LyX code associated with the inset. Used for TOC, ...)
virtual Code lyxCode() const { return NO_CODE; }
/// -1: text mode, 1: math mode, 0 undecided
enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE};
/// return text or mathmode if that is possible to determine
virtual mode_type currentMode() const { return UNDECIDED_MODE; }
/// FIXME: This ought to die.
virtual void setOwner(UpdatableInset *) {}
///
virtual UpdatableInset * owner() const { return 0; }
/// is this inset allowed within a font change?
virtual bool noFontChange() const { return false; }
///
virtual void markErased();
/// pretty arbitrary
virtual int width() const { return 10; }
/// pretty arbitrary
virtual int ascent() const { return 10; }
/// pretty arbitrary
virtual int descent() const { return 10; }
};
/**
* returns true if pointer argument is valid
* and points to an editable inset
*/
bool isEditableInset(InsetBase const * inset);
/**
* returns true if pointer argument is valid
* and points to a highly editable inset
*/
bool isHighlyEditableInset(InsetBase const * inset);
#endif

View File

@ -116,6 +116,8 @@ public:
void setBackgroundColor(LColor_color);
///
void setStatus(CollapseStatus st);
///
bool allowSpellCheck() const { return true; }
protected:
///

View File

@ -71,7 +71,7 @@ public:
///
void getDrawFont(LyXFont &) const;
///
bool forceDefaultParagraphs(InsetOld const *) const { return true; }
bool forceDefaultParagraphs(InsetBase const *) const { return true; }
protected:
///
virtual

View File

@ -12,6 +12,7 @@
#include "insetref.h"
#include "buffer.h"
#include "cursor.h"
#include "BufferView.h"
#include "dispatchresult.h"
#include "funcrequest.h"

View File

@ -1985,7 +1985,7 @@ void InsetTabular::markErased()
}
bool InsetTabular::forceDefaultParagraphs(InsetOld const * in) const
bool InsetTabular::forceDefaultParagraphs(InsetBase const * in) const
{
const int cell = tabular.getCellFromInset(in);

View File

@ -134,7 +134,7 @@ public:
// this should return true if we have a "normal" cell, otherwise true.
// "normal" means without width set!
bool forceDefaultParagraphs(InsetOld const * in) const;
bool forceDefaultParagraphs(InsetBase const * in) const;
///
void addPreview(lyx::graphics::PreviewLoader &) const;

View File

@ -166,7 +166,7 @@ LyXText * ParIterator::text(Buffer & buf) const
}
InsetOld * ParIterator::inset() const
InsetBase * ParIterator::inset() const
{
//lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl;
if (pimpl_->positions.size() <= 1)
@ -385,7 +385,7 @@ ParIterator::ParIterator(PosIterator const & pos)
PosIteratorItem const & it = pos.stack_[i];
ParPosition pp(it.pit, *it.pl);
if (i < size - 1) {
InsetOld * inset = it.pit->getInset(it.pos);
InsetBase * inset = it.pit->getInset(it.pos);
BOOST_ASSERT(inset);
InsetList::iterator beg = it.pit->insetlist.begin();
InsetList::iterator end = it.pit->insetlist.end();

View File

@ -18,7 +18,7 @@
#include <boost/scoped_ptr.hpp>
class LyXText;
class InsetOld;
class InsetBase;
class Cursor;
class Buffer;
class BufferView;
@ -52,7 +52,7 @@ public:
/// returns 'innermost' LyXText
LyXText * text(Buffer &) const;
/// returns innermost inset
InsetOld * inset() const;
InsetBase * inset() const;
/// returns index of cell in innermost inset
int index() const;
///

View File

@ -391,7 +391,7 @@ int replace(BufferView * bv,
text->replaceSelectionWithString(replacestr);
text->setSelectionRange(replacestr.length());
bv->cursor().current() = fw ? bv->cursor().selEnd() : bv->cursor().selStart();
bv->cursor().current() = fw ? bv->cursor().selEnd() : bv->cursor().selBegin();
bv->buffer()->markDirty();
find(bv, searchstr, cs, mw, fw);
bv->update();

View File

@ -63,8 +63,6 @@
#include "insets/insetvspace.h"
#include "insets/insetwrap.h"
#include "mathed/math_cursor.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
#include "frontends/FileDialog.h"
@ -162,8 +160,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
}
void LyXFunc::processKeySym(LyXKeySymPtr keysym,
key_modifier::state state)
void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
{
string argument;
@ -343,7 +340,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
if (tab && tab->hasSelection())
disable = false;
else
disable = !inMathed() && !view()->cursor().selection();
disable = !view()->cursor().inMathed() && !view()->cursor().selection();
break;
case LFUN_RUNCHKTEX:
@ -379,7 +376,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_TABULAR_FEATURE:
#if 0
if (inMathed()) {
if (view()->cursor().inMathed()) {
// FIXME: check temporarily disabled
// valign code
char align = mathcursor::valign();
@ -511,7 +508,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
}
case LFUN_MATH_MUTATE:
if (inMathed())
if (view()->cursor().inMathed())
//flag.setOnOff(mathcursor::formula()->hullType() == ev.argument);
flag.setOnOff(false);
else
@ -525,7 +522,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_MATH_NONUMBER:
case LFUN_MATH_NUMBER:
case LFUN_MATH_EXTERN:
disable = !inMathed();
disable = !view()->cursor().inMathed();
break;
case LFUN_DIALOG_SHOW: {
@ -684,13 +681,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
break;
case LFUN_SPACE_INSERT:
// slight hack: we know this is allowed in math mode
if (!inMathed())
if (!view()->cursor().inMathed())
code = InsetOld::SPACE_CODE;
break;
case LFUN_INSET_DIALOG_SHOW: {
InsetOld * inset = view()->getLyXText()->getInset();
InsetBase * inset = view()->getLyXText()->getInset();
disable = !inset;
if (!disable) {
if (inset) {
code = inset->lyxCode();
if (!(code == InsetOld::INCLUDE_CODE
|| code == InsetOld::BIBTEX_CODE
@ -736,7 +733,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
#ifdef LOCK
// the font related toggles
if (!inMathed()) {
if (!view()->cursor().inMathed()) {
LyXFont const & font = view()->getLyXText()->real_current_font;
switch (ev.action) {
case LFUN_EMPH:
@ -1289,7 +1286,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
break;
case LFUN_INSET_DIALOG_SHOW: {
InsetOld * inset = view()->getLyXText()->getInset();
InsetBase * inset = view()->getLyXText()->getInset();
if (inset)
inset->dispatch(view()->cursor(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
break;

View File

@ -16,23 +16,28 @@
#include "bufferview_funcs.h"
#include "Bidi.h"
#include "layout.h"
#include "dispatchresult.h"
#include "lyxfont.h"
#include "lyxtextclass.h"
#include "layout.h"
#include "lyxlayout_ptr_fwd.h"
#include "ParagraphList_fwd.h"
#include "RowList_fwd.h"
#include "insets/inset.h"
#include <iosfwd>
class Buffer;
class BufferParams;
class BufferView;
class Dimension;
class LColor_color;
class CursorSlice;
class Dimension;
class InsetBase;
class InsetOld_code;
class FuncRequest;
class LColor_color;
class LCursor;
class LyXTextClass;
class MetricsInfo;
class PainterInfo;
class Paragraph;
class Row;
class Spacing;
@ -112,7 +117,7 @@ public:
*/
void insertChar(char c);
///
void insertInset(InsetOld * inset);
void insertInset(InsetBase * inset);
/// a full rebreak of the whole text
void fullRebreak();
@ -163,7 +168,7 @@ public:
/// just selects the word the cursor is in
void selectWord(lyx::word_location loc);
/// returns the inset at cursor (if it exists), 0 otherwise
InsetOld * getInset() const;
InsetBase * getInset() const;
/// accept selected change
void acceptChange();
@ -278,13 +283,13 @@ public:
void insertStringAsParagraphs(std::string const & str);
/// Find next inset of some specified type.
bool gotoNextInset(std::vector<InsetOld::Code> const & codes,
bool gotoNextInset(std::vector<InsetOld_code> const & codes,
std::string const & contents = std::string());
///
void gotoInset(std::vector<InsetOld::Code> const & codes,
void gotoInset(std::vector<InsetOld_code> const & codes,
bool same_content);
///
void gotoInset(InsetOld::Code code, bool same_content);
void gotoInset(InsetOld_code code, bool same_content);
/// current max text width
int textWidth() const;
@ -292,7 +297,7 @@ public:
/// updates all counters
void updateCounters();
/// Returns an inset if inset was hit, or 0 if not.
InsetOld * checkInsetHit(int x, int y);
InsetBase * checkInsetHit(int x, int y);
///
int singleWidth(ParagraphList::iterator pit, lyx::pos_type pos) const;

View File

@ -7,10 +7,6 @@ INCLUDES = -I$(srcdir)/../ $(BOOST_INCLUDES)
libmathed_la_SOURCES = \
textpainter.C \
textpainter.h \
formulabase.C \
formulabase.h \
formula.C \
formula.h \
formulamacro.C \
formulamacro.h \
math_amsarrayinset.C \
@ -39,8 +35,6 @@ libmathed_la_SOURCES = \
math_colorinset.h \
math_commentinset.C \
math_commentinset.h \
math_cursor.C \
math_cursor.h \
math_data.C \
math_data.h \
math_decorationinset.C \

View File

@ -9,16 +9,18 @@
* Full author contact details are available in file CREDITS.
*/
#if 0
#include <config.h>
#include "formula.h"
#include "math_cursor.h"
#include "math_data.h"
#include "math_parser.h"
#include "math_hullinset.h"
#include "math_mathmlstream.h"
#include "textpainter.h"
#include "BufferView.h"
#include "cursor.h"
#include "debug.h"
#include "LColor.h"
#include "lyx_main.h"
@ -164,25 +166,13 @@ void InsetFormula::read(Buffer const &, LyXLex & lex)
}
namespace {
bool editing_inset(InsetFormula const * inset)
{
return inMathed() &&
(const_cast<InsetFormulaBase const *>(mathcursor::formula()) ==
inset);
}
} // namespace anon
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
{
xo_ = x;
yo_ = y;
// The previews are drawn only when we're not editing the inset.
bool const use_preview = !editing_inset(this)
bool const use_preview = !pi.base.bv->cursor().isInside(this)
&& RenderPreview::activated()
&& preview_->previewReady();
@ -203,8 +193,8 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
!= lcolor.getX11Name(LColor::background))
p.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
if (editing_inset(this)) {
mathcursor::drawSelection(pi);
if (!pi.base.bv->cursor().isInside(this)) {
pi.base.bv->cursor().drawSelection(pi);
//p.pain.rectangle(x, y - a, w, h, LColor::mathframe);
}
@ -243,7 +233,7 @@ bool InsetFormula::insetAllowed(InsetOld::Code code) const
void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
{
bool const use_preview = !editing_inset(this)
bool const use_preview = !m.base.bv->cursor().isInside(this)
&& RenderPreview::activated()
&& preview_->previewReady();
@ -308,3 +298,4 @@ void InsetFormula::generatePreview(Buffer const & buffer) const
preview_->addPreview(snippet, buffer);
preview_->startLoading(buffer);
}
#endif

View File

@ -10,6 +10,7 @@
* Full author contact details are available in file CREDITS.
*/
#if 0
#ifndef INSET_FORMULA_H
#define INSET_FORMULA_H
@ -89,3 +90,4 @@ private:
boost::scoped_ptr<RenderPreview> const preview_;
};
#endif
#endif

View File

@ -12,11 +12,12 @@
#include <config.h>
#include "formulamacro.h"
#include "math_cursor.h"
#include "math_macrotable.h"
#include "math_macrotemplate.h"
#include "math_mathmlstream.h"
#include "BufferView.h"
#include "cursor.h"
#include "gettext.h"
#include "LColor.h"
#include "lyxlex.h"
@ -35,22 +36,22 @@ using std::auto_ptr;
using std::ostream;
InsetFormulaMacro::InsetFormulaMacro()
{
// inset name is inherited from Inset
setInsetName("unknown");
}
: MathNestInset(2), name_("unknown")
{}
InsetFormulaMacro::InsetFormulaMacro
(string const & name, int nargs, string const & type)
(string const & name, int nargs, string const & type)
: MathNestInset(2), name_(name)
{
setInsetName(name);
MathMacroTable::create(MathAtom(new MathMacroTemplate(name, nargs, type)));
}
InsetFormulaMacro::InsetFormulaMacro(string const & s)
: MathNestInset(2), name_("unknown")
{
std::istringstream is(s);
read(is);
@ -67,7 +68,7 @@ void InsetFormulaMacro::write(Buffer const &, ostream & os) const
{
os << "FormulaMacro ";
WriteStream wi(os, false, false);
par()->write(wi);
MathNestInset::write(wi);
}
@ -75,7 +76,7 @@ int InsetFormulaMacro::latex(Buffer const &, ostream & os,
OutputParams const & runparams) const
{
WriteStream wi(os, runparams.moving_arg, true);
par()->write(wi);
MathNestInset::write(wi);
return 2;
}
@ -84,7 +85,7 @@ int InsetFormulaMacro::plaintext(Buffer const &, ostream & os,
OutputParams const &) const
{
WriteStream wi(os, false, true);
par()->write(wi);
MathNestInset::write(wi);
return 0;
}
@ -112,7 +113,7 @@ void InsetFormulaMacro::read(Buffer const &, LyXLex & lex)
void InsetFormulaMacro::read(std::istream & is)
{
auto_ptr<MathMacroTemplate> p(new MathMacroTemplate(is));
setInsetName(p->name());
name_ = p->name();
MathMacroTable::create(MathAtom(p.release()));
//metrics();
}
@ -120,20 +121,24 @@ void InsetFormulaMacro::read(std::istream & is)
string InsetFormulaMacro::prefix() const
{
return bformat(_(" Macro: %1$s: "), getInsetName());
return bformat(_(" Macro: %1$s: "), name_);
}
void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
par()->metrics(mi, dim_);
dim_.asc += 5;
dim_.des += 5;
dim_.wid += 10 + font_metrics::width(prefix(), mi.base.font);
MathNestInset::metrics(mi);
dim = cell(0).dim();
dim += cell(1).dim();
dim.asc += 5;
dim.des += 5;
dim.wid += 10 + font_metrics::width(prefix(), mi.base.font);
dim = dim_;
}
#warning FIXME
#if 0
MathAtom const & InsetFormulaMacro::par() const
{
return MathMacroTable::provide(getInsetName());
@ -144,12 +149,7 @@ MathAtom & InsetFormulaMacro::par()
{
return MathMacroTable::provide(getInsetName());
}
InsetOld::Code InsetFormulaMacro::lyxCode() const
{
return InsetOld::MATHMACRO_CODE;
}
#endif
void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
@ -170,14 +170,17 @@ void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
pi.pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);
pi.pain.rectangle(x, a, w, h, LColor::mathframe);
if (inMathed() &&
const_cast<InsetFormulaBase const *>(mathcursor::formula()) == this)
mathcursor::drawSelection(pi);
LCursor & cur = p.base.bv->cursor();
if (cur.isInside(this))
cur.drawSelection(pi);
pi.pain.text(x + 2, y, prefix(), font);
// formula
#warning FIXME
#if 0
par()->draw(pi, x + font_metrics::width(prefix(), p.base.font) + 5, y);
xo_ = x;
yo_ = y;
#endif
}

View File

@ -13,21 +13,22 @@
#ifndef INSET_FORMULA_MACRO_H
#define INSET_FORMULA_MACRO_H
#include "formulabase.h"
#include "math_nestinset.h"
class MathMacroTemplate;
class LyXLex;
// An InsetFormulaMacro only knows its name and asks the global
// MathMacroTable if it needs to know more.
/// Main LyX Inset for defining math macros
class InsetFormulaMacro : public InsetFormulaBase {
class InsetFormulaMacro : public MathNestInset {
public:
///
InsetFormulaMacro();
/// construct a macro hull from its name and the number of arguments
explicit InsetFormulaMacro(std::string const & name, int nargs, std::string const & t);
InsetFormulaMacro(std::string const & name, int nargs, std::string const & t);
/// constructs a mocro from its LaTeX definition
explicit InsetFormulaMacro(std::string const & s);
///
@ -53,18 +54,16 @@ public:
OutputParams const &) const;
///
virtual std::auto_ptr<InsetBase> clone() const;
std::auto_ptr<InsetBase> clone() const;
///
InsetOld::Code lyxCode() const;
///
MathAtom const & par() const;
///
MathAtom & par();
InsetBase::Code lyxCode() const { return MATHMACRO_CODE; }
private:
///
void read(std::istream & is);
/// prefix in inset
std::string prefix() const;
///
std::string name_;
};
#endif

View File

@ -37,7 +37,7 @@ auto_ptr<InsetBase> MathColorInset::clone() const
void MathColorInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(1).metrics(mi, dim);
if (editing()) {
if (editing(mi.base.bv)) {
FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi);
dim += cell(0).dim();
@ -53,7 +53,7 @@ void MathColorInset::metrics(MetricsInfo & mi, Dimension & dim) const
void MathColorInset::draw(PainterInfo & pi, int x, int y) const
{
if (editing()) {
if (editing(pi.base.bv)) {
FontSetChanger dummy(pi.base, "textnormal");
drawMarkers(pi, x, y);
drawStrBlack(pi, x, y, "[");

View File

@ -11,7 +11,6 @@
#include <config.h>
#include "math_data.h"
#include "math_cursor.h"
#include "math_fontinset.h"
#include "math_scriptinset.h"
#include "math_mathmlstream.h"

View File

@ -32,12 +32,12 @@ bool MathFracbaseInset::idxLeft(LCursor &) const
}
bool MathFracbaseInset::idxUpDown(LCursor & cur, bool up, int targetx) const
bool MathFracbaseInset::idxUpDown(LCursor & cur, bool up) const
{
MathInset::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
if (cur.idx() == target)
return false;
cur.idx() = target;
cur.pos() = cell(target).x2pos(targetx);
cur.pos() = cell(target).x2pos(cur.x_target());
return true;
}

View File

@ -20,7 +20,7 @@ public:
///
MathFracbaseInset();
///
bool idxUpDown(LCursor &, bool up, int targetx) const;
bool idxUpDown(LCursor &, bool up) const;
///
bool idxLeft(LCursor &) const;
///

View File

@ -755,7 +755,7 @@ int MathGridInset::cellYOffset(idx_type idx) const
}
bool MathGridInset::idxUpDown(LCursor & cur, bool up, int targetx) const
bool MathGridInset::idxUpDown(LCursor & cur, bool up) const
{
if (up) {
if (cur.idx() < ncols())
@ -766,7 +766,7 @@ bool MathGridInset::idxUpDown(LCursor & cur, bool up, int targetx) const
return false;
cur.idx() += ncols();
}
cur.pos() = cur.cell().x2pos(targetx - cur.cell().xo());
cur.pos() = cur.cell().x2pos(cur.x_target() - cur.cell().xo());
return true;
}

View File

@ -145,7 +145,7 @@ public:
row_type row(idx_type idx) const;
///
bool idxUpDown(LCursor &, bool up, int targetx) const;
bool idxUpDown(LCursor &, bool up) const;
///
bool idxLeft(LCursor &) const;
///

View File

@ -10,15 +10,16 @@
#include <config.h>
#include "math_charinset.h"
#include "math_data.h"
#include "math_extern.h"
#include "math_hullinset.h"
#include "math_mathmlstream.h"
#include "math_streamstr.h"
#include "math_cursor.h"
#include "math_support.h"
#include "math_extern.h"
#include "math_charinset.h"
#include "textpainter.h"
#include "BufferView.h"
#include "cursor.h"
#include "dispatchresult.h"
#include "debug.h"
#include "funcrequest.h"
@ -26,6 +27,7 @@
#include "LaTeXFeatures.h"
#include "LColor.h"
#include "lyxrc.h"
#include "textpainter.h"
#include "frontends/Alert.h"
@ -66,7 +68,7 @@ namespace {
// returns position of first relation operator in the array
// used for "intelligent splitting"
MathArray::size_type firstRelOp(MathArray const & ar)
size_t firstRelOp(MathArray const & ar)
{
for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
if ((*it)->isRelOp())
@ -110,6 +112,12 @@ namespace {
MathHullInset::MathHullInset()
: MathGridInset(1, 1), type_("none"), nonum_(1), label_(1)
{
// This is needed as long the math parser is not re-entrant
initMath();
//lyxerr << "sizeof MathInset: " << sizeof(MathInset) << endl;
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
//lyxerr << "sizeof MathCharInset: " << sizeof(MathCharInset) << endl;
//lyxerr << "sizeof LyXFont: " << sizeof(LyXFont) << endl;
setDefaults();
}
@ -725,8 +733,8 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
if (getType() == "simple") {
size_type pos = cur.cell().find_last(eq);
MathArray ar;
if (inMathed() && cur.selection()) {
asArray(mathcursor::grabAndEraseSelection(cur), ar);
if (cur.inMathed() && cur.selection()) {
asArray(cur.grabAndEraseSelection(), ar);
} else if (pos == cur.cell().size()) {
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
@ -871,3 +879,509 @@ string MathHullInset::fileInsetLabel() const
{
return "Formula";
}
/////////////////////////////////////////////////////////////////////
#include "formulamacro.h"
#include "math_arrayinset.h"
#include "math_data.h"
#include "math_deliminset.h"
#include "math_factory.h"
#include "math_hullinset.h"
#include "math_parser.h"
#include "math_spaceinset.h"
#include "math_support.h"
#include "ref_inset.h"
#include "BufferView.h"
#include "bufferview_funcs.h"
#include "cursor.h"
#include "dispatchresult.h"
#include "debug.h"
#include "funcrequest.h"
#include "gettext.h"
#include "LColor.h"
#include "lyxtext.h"
#include "undo.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
#include "support/std_sstream.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
using lyx::support::atoi;
using lyx::support::split;
using lyx::support::token;
using std::abs;
using std::endl;
using std::max;
using std::istringstream;
using std::ostringstream;
namespace {
// local global
int first_x;
int first_y;
bool openNewInset(LCursor & cur, InsetBase * inset)
{
if (!cur.bv().insertInset(inset)) {
delete inset;
return false;
}
inset->edit(cur, true);
return true;
}
} // namespace anon
int MathHullInset::ylow() const
{
return yo_ - dim_.asc;
}
int MathHullInset::yhigh() const
{
return yo_ + dim_.des;
}
int MathHullInset::xlow() const
{
return xo_;
}
int MathHullInset::xhigh() const
{
return xo_ + dim_.wid;
}
// simply scrap this function if you want
void MathHullInset::mutateToText()
{
#if 0
// translate to latex
ostringstream os;
latex(NULL, os, false, false);
string str = os.str();
// insert this text
LyXText * lt = view_->getLyXText();
string::const_iterator cit = str.begin();
string::const_iterator end = str.end();
for (; cit != end; ++cit)
view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
// remove ourselves
//view_->owner()->dispatch(LFUN_ESCAPE);
#endif
}
void MathHullInset::handleFont
(LCursor & cur, string const & arg, string const & font)
{
// this whole function is a hack and won't work for incremental font
// changes...
recordUndo(cur, Undo::ATOMIC);
if (cur.inset()->asMathInset()->name() == font)
cur.handleFont(font);
else {
cur.handleNest(createMathInset(font));
cur.insert(arg);
}
}
void MathHullInset::handleFont2(LCursor & cur, string const & arg)
{
recordUndo(cur, Undo::ATOMIC);
LyXFont font;
bool b;
bv_funcs::string2font(arg, font, b);
if (font.color() != LColor::inherit) {
MathAtom at = createMathInset("color");
asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
cur.handleNest(at, 1);
}
}
string const MathHullInset::editMessage() const
{
return _("Math editor mode");
}
void MathHullInset::insetUnlock(BufferView & bv)
{
if (bv.cursor().inMathed()) {
if (bv.cursor().inMacroMode())
bv.cursor().macroModeClose();
bv.cursor().releaseMathCursor();
}
if (bv.buffer())
generatePreview(*bv.buffer());
bv.update();
}
void MathHullInset::getCursorPos(BufferView & bv, int & x, int & y) const
{
if (bv.cursor().inMathed()) {
bv.cursor().getScreenPos(x, y);
x = bv.cursor().targetX();
x -= xo_;
y -= yo_;
lyxerr << "MathHullInset::getCursorPos: " << x << ' ' << y << endl;
} else {
x = 0;
y = 0;
lyxerr << "getCursorPos - should not happen";
}
}
void MathHullInset::getCursorDim(int & asc, int & desc) const
{
asc = 10;
desc = 2;
//math_font_max_dim(font_, asc, des);
}
DispatchResult
MathHullInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
{
if (!cur.inMathed())
return DispatchResult(false);
cur.bv().update();
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
if (cmd.button() == mouse_button::button3) {
// try to dispatch to enclosed insets first
if (!cur.dispatch(cmd).dispatched()) {
// launch math panel for right mouse button
lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
cur.bv().owner()->getDialogs().show("mathpanel");
}
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button2) {
MathArray ar;
asArray(cur.bv().getClipboard(), ar);
cur.selClear();
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
cur.insert(ar);
cur.bv().update();
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button1) {
// try to dispatch to enclosed insets first
cur.dispatch(cmd);
cur.bv().stuffClipboard(cur.grabSelection());
// try to set the cursor
//delete mathcursor;
//mathcursor = new MathCursor(bv, this, x == 0);
//metrics(bv);
//cur.setScreenPos(x + xo_, y + yo_);
return DispatchResult(true, true);
}
return DispatchResult(false);
}
DispatchResult
MathHullInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
{
//lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
if (!cur.inMathed() || cur.formula() != this) {
lyxerr[Debug::MATHED] << "re-create cursor" << endl;
cur.releaseMathCursor();
cur.idx() = 0;
//metrics(bv);
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
}
if (cmd.button() == mouse_button::button3) {
cur.dispatch(cmd);
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button1) {
first_x = cmd.x;
first_y = cmd.y;
cur.selClear();
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
cur.dispatch(cmd);
return DispatchResult(true, true);
}
cur.bv().update();
return DispatchResult(true, true);
}
DispatchResult
MathHullInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
{
if (!cur.inMathed())
return DispatchResult(true, true);
if (cur.dispatch(FuncRequest(cmd)).dispatched())
return DispatchResult(true, true);
// only select with button 1
if (cmd.button() != mouse_button::button1)
return DispatchResult(true, true);
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
return DispatchResult(true, true);
first_x = cmd.x;
first_y = cmd.y;
if (!cur.selection())
cur.selBegin();
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
cur.bv().update();
return DispatchResult(true, true);
}
void MathHullInset::edit(LCursor & cur, bool left)
{
lyxerr << "Called FormulaBase::edit" << endl;
cur.push(this);
cur.idx() = left ? 0 : cur.lastidx();
cur.pos() = left ? 0 : cur.lastpos();
cur.resetAnchor();
}
void MathHullInset::edit(LCursor & cur, int x, int y)
{
lyxerr << "Called FormulaBase::EDIT with '" << x << ' ' << y << "'" << endl;
//metrics(bv);
cur.push(this);
//cur.idx() = left ? 0 : cur.lastidx();
cur.idx() = 0;
cur.idx() = 0;
cur.setScreenPos(x + xo_, y + yo_);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
cur.bv().update();
}
void MathHullInset::revealCodes(LCursor & cur) const
{
if (!cur.inMathed())
return;
ostringstream os;
cur.info(os);
cur.bv().owner()->message(os.str());
/*
// write something to the minibuffer
// translate to latex
cur.markInsert(bv);
ostringstream os;
write(NULL, os);
string str = os.str();
cur.markErase(bv);
string::size_type pos = 0;
string res;
for (string::iterator it = str.begin(); it != str.end(); ++it) {
if (*it == '\n')
res += ' ';
else if (*it == '\0') {
res += " -X- ";
pos = it - str.begin();
}
else
res += *it;
}
if (pos > 30)
res = res.substr(pos - 30);
if (res.size() > 60)
res = res.substr(0, 60);
bv.owner()->message(res);
*/
}
InsetBase::Code MathHullInset::lyxCode() const
{
return MATH_CODE;
}
/////////////////////////////////////////////////////////////////////
#if 1
bool MathHullInset::searchForward(BufferView *, string const &, bool, bool)
{
return false;
}
#else
bool MathHullInset::searchForward(BufferView * bv, string const & str,
bool, bool)
{
return false;
#ifdef WITH_WARNINGS
#warning pretty ugly
#endif
static MathHullInset * lastformula = 0;
static CursorBase current = CursorBase(ibegin(par().nucleus()));
static MathArray ar;
static string laststr;
if (lastformula != this || laststr != str) {
//lyxerr << "reset lastformula to " << this << endl;
lastformula = this;
laststr = str;
current = ibegin(par().nucleus());
ar.clear();
mathed_parse_cell(ar, str);
} else {
increment(current);
}
//lyxerr << "searching '" << str << "' in " << this << ar << endl;
for (CursorBase it = current; it != iend(par().nucleus()); increment(it)) {
CursorSlice & top = it.back();
MathArray const & a = top.asMathInset()->cell(top.idx_);
if (a.matchpart(ar, top.pos_)) {
bv->cursor().setSelection(it, ar.size());
current = it;
top.pos_ += ar.size();
bv->update();
return true;
}
}
//lyxerr << "not found!" << endl;
lastformula = 0;
return false;
}
#endif
bool MathHullInset::searchBackward(BufferView * bv, string const & what,
bool a, bool b)
{
lyxerr[Debug::MATHED] << "searching backward not implemented in mathed" << endl;
return searchForward(bv, what, a, b);
}
void mathDispatchCreation(LCursor & cur, FuncRequest const & cmd,
bool display)
{
// use selection if available..
//string sel;
//if (action == LFUN_MATH_IMPORT_SELECTION)
// sel = "";
//else
string sel =
cur.bv().getLyXText()->selectionAsString(*cur.bv().buffer(), false);
if (sel.empty()) {
InsetBase * f = new MathHullInset;
if (openNewInset(cur, f)) {
cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
// don't do that also for LFUN_MATH_MODE unless you want end up with
// always changing to mathrm when opening an inlined inset
// -- I really hate "LyXfunc overloading"...
if (display)
f->dispatch(cur, FuncRequest(LFUN_MATH_DISPLAY));
f->dispatch(cur, FuncRequest(LFUN_INSERT_MATH, cmd.argument));
}
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
// formula otherwise
InsetBase * f;
if (sel.find("\\newcommand") == string::npos &&
sel.find("\\def") == string::npos)
f = new MathHullInset(sel);
else
f = new InsetFormulaMacro(sel);
cur.bv().getLyXText()->cutSelection(true, false);
openNewInset(cur, f);
}
cmd.message(N_("Math editor mode"));
}
void mathDispatch(LCursor & cur, FuncRequest const & cmd)
{
if (!cur.bv().available())
return;
switch (cmd.action) {
case LFUN_MATH_DISPLAY:
mathDispatchCreation(cur, cmd, true);
break;
case LFUN_MATH_MODE:
mathDispatchCreation(cur, cmd, false);
break;
case LFUN_MATH_IMPORT_SELECTION:
mathDispatchCreation(cur, cmd, false);
break;
/*
case LFUN_MATH_MACRO:
if (cmd.argument.empty())
cmd.errorMessage(N_("Missing argument"));
else {
string s = cmd.argument;
string const s1 = token(s, ' ', 1);
int const nargs = s1.empty() ? 0 : atoi(s1);
string const s2 = token(s, ' ', 2);
string const type = s2.empty() ? "newcommand" : s2;
openNewInset(cur, new InsetFormulaMacro(token(s, ' ', 0), nargs, s2));
}
break;
case LFUN_INSERT_MATH:
case LFUN_INSERT_MATRIX:
case LFUN_MATH_DELIM: {
MathHullInset * f = new MathHullInset;
if (openNewInset(cur, f)) {
cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
cur.inset()->dispatch(cur, cmd);
}
break;
}
*/
default:
break;
}
}

View File

@ -47,8 +47,6 @@ public:
///
bool numberedType() const;
///
bool display() const;
///
bool ams() const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &,
@ -98,9 +96,7 @@ public:
protected:
///
virtual
DispatchResult
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
///
std::string eolString(row_type row, bool fragile) const;
@ -132,6 +128,93 @@ private:
std::vector<int> nonum_;
///
std::vector<std::string> label_;
//
// Incorporate me
//
public:
/// lowest x coordinate
int xlow() const;
/// highest x coordinate
int xhigh() const;
/// lowest y coordinate
int ylow() const;
/// highest y coordinate
int yhigh() const;
/// what appears in the minibuffer when opening
virtual std::string const editMessage() const;
/// get the absolute document x,y of the cursor
virtual void getCursorPos(BufferView & bv, int & x, int & y) const;
///
virtual void getCursorDim(int &, int &) const;
///
virtual void insetUnlock(BufferView & bv);
/// To allow transparent use of math editing functions
//virtual void status(FuncRequest const &);
///
virtual bool searchForward(BufferView *, std::string const &,
bool = true, bool = false);
///
virtual bool searchBackward(BufferView *, std::string const &,
bool = true, bool = false);
///
virtual bool isTextInset() const { return true; }
///
virtual void mutateToText();
///
virtual void revealCodes(LCursor & cur) const;
///
virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
bool display() const;
///
void edit(LCursor & cur, bool);
///
void edit(LCursor & cur, int, int);
///
Code MathHullInset::lyxCode() const;
private:
/// common base for handling accents
void handleAccent(BufferView & bv, std::string const & arg,
std::string const & name);
/// lfun handler
DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
///
DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
///
DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
///
int x() const { return xo_; }
///
int y() const { return yo_; }
///
int yo_;
///
int xo_;
protected:
/** Find the PreviewLoader, add a LaTeX snippet to it and
* start the loading process.
*
* Most insets have no interest in this capability, so the method
* defaults to empty.
*/
virtual void generatePreview(Buffer const &) const {}
///
void handleFont(LCursor &, std::string const & arg, std::string const & font);
///
void handleFont2(LCursor &, std::string const & arg);
};
// We don't really mess want around with mathed stuff outside mathed.
// So do it here.
void mathDispatch(LCursor & cur, FuncRequest const & cmd);
#endif

View File

@ -21,12 +21,6 @@ using std::ostream;
using std::endl;
MathInset::size_type MathInset::nargs() const
{
return 0;
}
MathArray dummyCell;
MathArray & MathInset::cell(idx_type)
@ -43,85 +37,10 @@ MathArray const & MathInset::cell(idx_type) const
}
MathInset::idx_type MathInset::index(row_type row, col_type col) const
{
if (row != 0)
lyxerr << "illegal row: " << row << endl;
if (col != 0)
lyxerr << "illegal col: " << col << endl;
return 0;
}
void MathInset::substitute(MathMacro const &)
{}
bool MathInset::idxNext(LCursor &) const
{
return false;
}
bool MathInset::idxRight(LCursor &) const
{
return false;
}
bool MathInset::idxPrev(LCursor &) const
{
return false;
}
bool MathInset::idxLeft(LCursor &) const
{
return false;
}
bool MathInset::idxUpDown(LCursor &, bool, int) const
{
return false;
}
bool MathInset::idxUpDown2(LCursor &, bool, int) const
{
return false;
}
bool MathInset::idxFirst(LCursor &) const
{
return false;
}
bool MathInset::idxLast(LCursor &) const
{
return false;
}
bool MathInset::idxHome(LCursor &) const
{
return false;
}
bool MathInset::idxEnd(LCursor &) const
{
return false;
}
void MathInset::getScreenPos(idx_type, pos_type, int & x, int & y) const
{
lyxerr << "MathInset::getScreenPos() called directly!" << endl;
x = y = 0;
}
void MathInset::dump() const
{
@ -132,12 +51,6 @@ void MathInset::dump() const
}
bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
{
return from <= idx && idx <= to;
}
void MathInset::drawSelection(PainterInfo &,
idx_type, pos_type, idx_type, pos_type) const
{
@ -210,24 +123,6 @@ void MathInset::mathmlize(MathMLStream & os) const
}
int MathInset::plaintext(std::ostream &, OutputParams const &) const
{
return 0;
}
int MathInset::linuxdoc(std::ostream &, OutputParams const &) const
{
return 0;
}
int MathInset::docbook(std::ostream &, OutputParams const &) const
{
return 0;
}
string const & MathInset::getType() const
{
static string const t("none");

View File

@ -75,8 +75,6 @@ class ReplaceData;
class MathInset : public InsetBase {
public:
/// our members behave nicely...
MathInset() {}
/// identification as math inset
MathInset * asMathInset() { return this; }
@ -91,65 +89,11 @@ public:
/// draw the object as text
virtual void drawT(TextPainter &, int x, int y) const;
/// Where should we go when we press the up or down cursor key?
virtual bool idxUpDown(LCursor & cur, bool up, int targetx) const;
/// Where should we go when we press the up or down cursor key?
virtual bool idxUpDown2(LCursor & cur, bool up, int targetx) const;
/// The left key
virtual bool idxLeft(LCursor & cur) const;
/// The right key
virtual bool idxRight(LCursor & cur) const;
/// Move one physical cell up
virtual bool idxNext(LCursor & cur) const;
/// Move one physical cell down
virtual bool idxPrev(LCursor & cur) const;
/// Target pos when we enter the inset from the left by pressing "Right"
virtual bool idxFirst(LCursor & cur) const;
/// Target pos when we enter the inset from the right by pressing "Left"
virtual bool idxLast(LCursor & cur) const;
/// Where should we go if we press home?
virtual bool idxHome(LCursor & cur) const;
/// Where should we go if we press end?
virtual bool idxEnd(LCursor & cur) const;
/// Delete a cell and move cursor
virtual bool idxDelete(idx_type &) { return false; }
/// pulls cell after pressing erase
virtual void idxGlue(idx_type) {}
// returns list of cell indices that are "between" from and to for
// selection purposes
virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
/// the number of nested cells this inset owns
virtual idx_type nargs() const;
/// return cell given its number
virtual MathArray & cell(idx_type);
/// return cell given its number
virtual MathArray const & cell(idx_type) const;
/// the number of columns of this inset if it is grid-like
virtual col_type ncols() const { return 1; }
/// the number of rows of this inset if it is grid-like
virtual row_type nrows() const { return 1; }
/// to which column belongs a cell with a given index?
virtual col_type col(idx_type) const { return 0; }
/// to which row belongs a cell with a given index?
virtual row_type row(idx_type) const { return 0; }
/// cell idex corresponding to row and column;
virtual idx_type index(row_type row, col_type col) const;
/// any additional x-offset when drawing a cell?
virtual int cellXOffset(idx_type) const { return 0; }
/// any additional y-offset when drawing a cell?
virtual int cellYOffset(idx_type) const { return 0; }
/// can we enter this cell?
virtual bool validCell(idx_type) const { return true; }
/// get coordinates
virtual void getScreenPos(idx_type idx, pos_type pos, int & x, int & y) const;
/// identifies certain types of insets
virtual MathAMSArrayInset * asAMSArrayInset() { return 0; }
virtual MathAMSArrayInset const * asAMSArrayInset() const { return 0; }
@ -185,14 +129,8 @@ public:
/// identifies things that can get scripts
virtual bool isScriptable() const { return false; }
/// thing that can be moved into
virtual bool isActive() const { return nargs() > 0; }
/// is the a relational operator (used for splitting equations)
virtual bool isRelOp() const { return false; }
/// -1: text mode, 1: math mode, 0 undecided
enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE};
virtual mode_type currentMode() const { return UNDECIDED_MODE; }
/// will this get written as a single block in {..}
virtual bool extraBraces() const { return false; }
@ -211,8 +149,6 @@ public:
virtual bool lock() const { return false; }
/// access to the lock (only nest array have one)
virtual void lock(bool) {}
/// get notification when the cursor leaves this inset
virtual void notifyCursorLeaves(idx_type) {}
/// write LaTeX and Lyx code
virtual void write(WriteStream & os) const;
@ -228,12 +164,6 @@ public:
virtual void mathmlize(MathMLStream &) const;
/// write content as something readable by Octave
virtual void octave(OctaveStream &) const;
/// plain ascii output
virtual int plaintext(std::ostream & os, OutputParams const &) const;
/// linuxdoc output
virtual int linuxdoc(std::ostream & os, OutputParams const &) const;
/// docbook output
virtual int docbook(std::ostream & os, OutputParams const &) const;
/// dump content to stderr for debugging
virtual void dump() const;

View File

@ -75,13 +75,13 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
mathed_string_dim(font_, name(), dim_);
} else if (editing()) {
} else if (editing(mi.base.bv)) {
expand();
expanded_.metrics(mi_, dim_);
metricsMarkers();
dim_.wid += mathed_string_width(font_, name()) + 10;
dim_.wid += mathed_string_width(font_, name()) + 10;
int ww = mathed_string_width(font_, "#1: ");
@ -117,7 +117,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
return;
}
if (editing()) {
if (editing(pi.base.bv)) {
int h = y - dim_.ascent() + 2 + expanded_.ascent();
drawStr(pi, font_, x + 3, h, name());
@ -156,7 +156,7 @@ void MathMacro::dump() const
}
bool MathMacro::idxUpDown(LCursor & cur, bool up, int x) const
bool MathMacro::idxUpDown(LCursor & cur, bool up) const
{
if (up) {
if (!MathNestInset::idxLeft(cur))
@ -165,7 +165,7 @@ bool MathMacro::idxUpDown(LCursor & cur, bool up, int x) const
if (!MathNestInset::idxRight(cur))
return false;
}
cur.pos() = cur.cell().x2pos(x);
cur.pos() = cur.cell().x2pos(cur.x_target());
return true;
}

View File

@ -38,11 +38,11 @@ public:
void dump() const;
///
bool idxUpDown(LCursor &, bool up, int targetx) const;
bool idxUpDown(LCursor & cur, bool up) const;
///
bool idxLeft(LCursor &) const;
bool idxLeft(LCursor & cur) const;
///
bool idxRight(LCursor &) const;
bool idxRight(LCursor & cur) const;
///
void validate(LaTeXFeatures &) const;

View File

@ -11,14 +11,16 @@
#include <config.h>
#include "math_nestinset.h"
#include "math_cursor.h"
#include "BufferView.h"
#include "LColor.h"
#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "funcrequest.h"
#include "math_data.h"
#include "math_mathmlstream.h"
#include "math_parser.h"
#include "BufferView.h"
#include "dispatchresult.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
#include "undo.h"
#include "frontends/Painter.h"
@ -214,9 +216,9 @@ bool MathNestInset::contains(MathArray const & ar) const
}
bool MathNestInset::editing() const
bool MathNestInset::editing(BufferView * bv) const
{
return inMathed() && mathcursor::isInside(this);
return bv->cursor().isInside(this);
}
@ -306,44 +308,416 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
case LFUN_RIGHTSEL:
cur.selection() = true; // fall through...
case LFUN_RIGHT:
return mathcursor::right(cur, cur.selection()) ?
return cur.right() ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
//lyxerr << "calling scroll 20" << endl;
//scroll(&cur.bv(), 20);
// write something to the minibuffer
//cur.bv().owner()->message(mathcursor::info());
//cur.bv().owner()->message(cur.info());
case LFUN_LEFTSEL:
cur.selection() = true; // fall through
case LFUN_LEFT:
return mathcursor::left(cur, cur.selection()) ?
return cur.left() ?
DispatchResult(true, true) : DispatchResult(false, FINISHED);
case LFUN_UPSEL:
cur.selection() = true; // fall through
case LFUN_UP:
return mathcursor::up(cur, cur.selection()) ?
return cur.up() ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
case LFUN_DOWNSEL:
cur.selection() = true; // fall through
case LFUN_DOWN:
return mathcursor::down(cur, cur.selection()) ?
return cur.down() ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
case LFUN_WORDSEL:
cur.home();
cur.selection() = true;
cur.end();
return DispatchResult(true, true);
case LFUN_UP_PARAGRAPHSEL:
case LFUN_UP_PARAGRAPH:
case LFUN_DOWN_PARAGRAPHSEL:
case LFUN_DOWN_PARAGRAPH:
return DispatchResult(true, FINISHED);
case LFUN_HOMESEL:
case LFUN_WORDLEFTSEL:
cur.selection() = true; // fall through
case LFUN_HOME:
case LFUN_WORDLEFT:
return cur.home()
? DispatchResult(true, true) : DispatchResult(true, FINISHED);
case LFUN_ENDSEL:
case LFUN_WORDRIGHTSEL:
cur.selection() = true; // fall through
case LFUN_END:
case LFUN_WORDRIGHT:
return cur.end()
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
case LFUN_PRIORSEL:
case LFUN_PRIOR:
case LFUN_BEGINNINGBUFSEL:
case LFUN_BEGINNINGBUF:
return DispatchResult(true, FINISHED);
case LFUN_NEXTSEL:
case LFUN_NEXT:
case LFUN_ENDBUFSEL:
case LFUN_ENDBUF:
return DispatchResult(false, FINISHED_RIGHT);
case LFUN_CELL_FORWARD:
cur.inset()->idxNext(cur);
return DispatchResult(true, true);
case LFUN_CELL_BACKWARD:
cur.inset()->idxPrev(cur);
return DispatchResult(true, true);
case LFUN_DELETE_WORD_BACKWARD:
case LFUN_BACKSPACE:
recordUndo(cur, Undo::ATOMIC);
cur.backspace();
return DispatchResult(true, true);
case LFUN_DELETE_WORD_FORWARD:
case LFUN_DELETE:
recordUndo(cur, Undo::ATOMIC);
cur.erase();
return DispatchResult(true, FINISHED);
case LFUN_ESCAPE:
if (!cur.selection())
return DispatchResult(true, true);
cur.selClear();
return DispatchResult(false);
case LFUN_INSET_TOGGLE:
cur.lockToggle();
return DispatchResult(true, true);
case LFUN_SELFINSERT:
if (!cmd.argument.empty()) {
recordUndo(cur, Undo::ATOMIC);
if (cmd.argument.size() == 1) {
if (mathcursor::interpret(cur, cmd.argument[0]))
if (cur.interpret(cmd.argument[0]))
return DispatchResult(true, true);
else
return DispatchResult(false, FINISHED_RIGHT);
}
mathcursor::insert(cur, cmd.argument);
cur.insert(cmd.argument);
}
return DispatchResult(false, FINISHED_RIGHT);
#if 0
//
// this needs to bee incorporated
//
//lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
// << " arg: '" << cmd.argument
// << "' x: '" << cmd.x
// << " y: '" << cmd.y
// << "' button: " << cmd.button() << endl;
// delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
bool remove_inset = false;
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
//lyxerr << "Mouse single press" << endl;
return lfunMousePress(cur, cmd);
case LFUN_MOUSE_MOTION:
//lyxerr << "Mouse motion" << endl;
return lfunMouseMotion(cur, cmd);
case LFUN_MOUSE_RELEASE:
//lyxerr << "Mouse single release" << endl;
return lfunMouseRelease(cur, cmd);
case LFUN_MOUSE_DOUBLE:
//lyxerr << "Mouse double" << endl;
return dispatch(cur, FuncRequest(LFUN_WORDSEL));
default:
break;
}
DispatchResult result(true);
string argument = cmd.argument;
bool was_macro = cur.inMacroMode();
cur.normalize();
cur.touch();
switch (cmd.action) {
case LFUN_MATH_MUTATE:
case LFUN_MATH_DISPLAY:
case LFUN_MATH_NUMBER:
case LFUN_MATH_NONUMBER:
case LFUN_CELL_SPLIT:
case LFUN_BREAKLINE:
case LFUN_DELETE_LINE_FORWARD:
case LFUN_INSERT_LABEL:
case LFUN_MATH_EXTERN:
case LFUN_TABULAR_FEATURE:
case LFUN_PASTESELECTION:
case LFUN_MATH_LIMITS:
recordUndo(cur, Undo::ATOMIC);
cur.dispatch(cmd);
break;
// case LFUN_GETXY:
// sprintf(dispatch_buffer, "%d %d",);
// DispatchResult= dispatch_buffer;
// break;
case LFUN_SETXY: {
lyxerr << "LFUN_SETXY broken!" << endl;
int x = 0;
int y = 0;
istringstream is(cmd.argument.c_str());
is >> x >> y;
cur.setScreenPos(x, y);
break;
}
case LFUN_PASTE: {
size_t n = 0;
istringstream is(cmd.argument.c_str());
is >> n;
if (was_macro)
cur.macroModeClose();
recordUndo(cur, Undo::ATOMIC);
cur.selPaste(n);
break;
}
case LFUN_CUT:
recordUndo(cur, Undo::DELETE);
cur.selCut();
break;
case LFUN_COPY:
cur.selCopy();
break;
// Special casing for superscript in case of LyX handling
// dead-keys:
case LFUN_CIRCUMFLEX:
if (cmd.argument.empty()) {
// do superscript if LyX handles
// deadkeys
recordUndo(cur, Undo::ATOMIC);
cur.script(true);
}
break;
case LFUN_UMLAUT:
case LFUN_ACUTE:
case LFUN_GRAVE:
case LFUN_BREVE:
case LFUN_DOT:
case LFUN_MACRON:
case LFUN_CARON:
case LFUN_TILDE:
case LFUN_CEDILLA:
case LFUN_CIRCLE:
case LFUN_UNDERDOT:
case LFUN_TIE:
case LFUN_OGONEK:
case LFUN_HUNG_UMLAUT:
break;
// Math fonts
case LFUN_FREEFONT_APPLY:
case LFUN_FREEFONT_UPDATE:
handleFont2(cur, cmd.argument);
break;
case LFUN_BOLD: handleFont(cur, cmd.argument, "mathbf"); break;
case LFUN_SANS: handleFont(cur, cmd.argument, "mathsf"); break;
case LFUN_EMPH: handleFont(cur, cmd.argument, "mathcal"); break;
case LFUN_ROMAN: handleFont(cur, cmd.argument, "mathrm"); break;
case LFUN_CODE: handleFont(cur, cmd.argument, "texttt"); break;
case LFUN_FRAK: handleFont(cur, cmd.argument, "mathfrak"); break;
case LFUN_ITAL: handleFont(cur, cmd.argument, "mathit"); break;
case LFUN_NOUN: handleFont(cur, cmd.argument, "mathbb"); break;
//case LFUN_FREEFONT_APPLY: handleFont(cur, cmd.argument, "textrm"); break;
case LFUN_DEFAULT: handleFont(cur, cmd.argument, "textnormal"); break;
case LFUN_MATH_MODE:
if (cur.currentMode() == InsetBase::TEXT_MODE)
cur.niceInsert(MathAtom(new MathHullInset("simple")));
else
handleFont(cur, cmd.argument, "textrm");
//cur.owner()->message(_("math text mode toggled"));
break;
case LFUN_MATH_SIZE:
#if 0
if (!arg.empty()) {
recordUndo(cur, Undo::ATOMIC);
cur.setSize(arg);
}
#endif
break;
case LFUN_INSERT_MATRIX: {
recordUndo(cur, Undo::ATOMIC);
unsigned int m = 1;
unsigned int n = 1;
string v_align;
string h_align;
istringstream is(argument);
is >> m >> n >> v_align >> h_align;
m = max(1u, m);
n = max(1u, n);
v_align += 'c';
cur.niceInsert(
MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
break;
}
case LFUN_MATH_DELIM: {
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'" << endl;
string ls;
string rs = split(cmd.argument, ls, ' ');
// Reasonable default values
if (ls.empty())
ls = '(';
if (rs.empty())
rs = ')';
recordUndo(cur, Undo::ATOMIC);
cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
break;
}
case LFUN_SPACE_INSERT:
case LFUN_MATH_SPACE:
recordUndo(cur, Undo::ATOMIC);
cur.insert(MathAtom(new MathSpaceInset(",")));
break;
case LFUN_UNDO:
cur.bv().owner()->message(_("Invalid action in math mode!"));
break;
case LFUN_EXEC_COMMAND:
result = DispatchResult(false);
break;
case LFUN_INSET_ERT:
// interpret this as if a backslash was typed
recordUndo(cur, Undo::ATOMIC);
cur.interpret('\\');
break;
case LFUN_BREAKPARAGRAPH:
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
case LFUN_BREAKPARAGRAPH_SKIP:
argument = "\n";
// fall through
// FIXME: We probably should swap parts of "math-insert" and "self-insert"
// handling such that "self-insert" works on "arbitrary stuff" too, and
// math-insert only handles special math things like "matrix".
case LFUN_INSERT_MATH:
recordUndo(cur, Undo::ATOMIC);
cur.niceInsert(argument);
break;
case LFUN_INSET_TOGGLE:
cur.lockToggle();
break;
case LFUN_DIALOG_SHOW:
result = DispatchResult(false);
break;
case LFUN_DIALOG_SHOW_NEW_INSET: {
string const & name = argument;
string data;
if (name == "ref") {
RefInset tmp(name);
data = tmp.createDialogStr(name);
}
if (data.empty())
result = DispatchResult(false);
else
cur.bv().owner()->getDialogs().show(name, data, 0);
break;
}
case LFUN_INSET_APPLY: {
string const name = cmd.getArg(0);
InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
if (base) {
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
result = base->dispatch(cur, fr);
} else {
MathArray ar;
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
cur.insert(ar);
result = DispatchResult(true, true);
} else {
result = DispatchResult(false);
}
}
break;
}
case LFUN_WORD_REPLACE:
case LFUN_WORD_FIND: {
result =
searchForward(&cur.bv(), cmd.getArg(0), false, false)
? DispatchResult(true, true) : DispatchResult(false);
break;
}
case LFUN_INSERT_MATH:
case LFUN_INSERT_MATRIX:
case LFUN_MATH_DELIM: {
MathHullInset * f = new MathHullInset;
if (openNewInset(cur, f)) {
cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
cur.inset()->dispatch(cur, cmd);
}
break;
}
default:
result = DispatchResult(false);
}
if (result == DispatchResult(true, true))
cur.bv().update();
cur.normalize();
cur.touch();
BOOST_ASSERT(cur.inMathed());
if (result.dispatched()) {
revealCodes(cur);
cur.bv().stuffClipboard(cur.grabSelection());
} else {
cur.releaseMathCursor();
if (remove_inset)
cur.bv().owner()->dispatch(FuncRequest(LFUN_DELETE));
}
return result; // original version
#endif
default:
return MathInset::priv_dispatch(cur, cmd);
}
@ -364,9 +738,10 @@ void MathNestInset::metricsMarkers2(int) const
dim_.des += 1;
}
void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const
{
if (!editing())
if (!editing(pi.base.bv))
return;
int t = x + dim_.width() - 1;
int d = y + dim_.descent();
@ -379,7 +754,7 @@ void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const
void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const
{
if (!editing())
if (!editing(pi.base.bv))
return;
drawMarkers(pi, x, y);
int t = x + dim_.width() - 1;

View File

@ -25,7 +25,7 @@ public:
/// nestinsets have a fixed size to start with
explicit MathNestInset(idx_type ncells);
/// the size is usuall some sort of convex hull of the cells
/// the size is usually some sort of convex hull of the cells
/// hides inset::metrics() intentionally!
void metrics(MetricsInfo const & mi) const;
/// draw background if locked
@ -90,8 +90,6 @@ public:
/// debug helper
void dump() const;
/// is the cursor currently somewhere within this inset?
virtual bool editing() const;
/// writes \\, name(), and args in braces and '\\lyxlock' if necessary
void write(WriteStream & os) const;
@ -110,6 +108,8 @@ protected:
/// if the inset is locked, it can't be entered with the cursor
bool lock_;
///
bool editing(BufferView * bv) const;
/// draw four angular markers
void drawMarkers(PainterInfo & pi, int x, int y) const;
/// draw two angular markers

View File

@ -80,7 +80,7 @@ void MathRootInset::normalize(NormalStream & os) const
}
bool MathRootInset::idxUpDown(LCursor & cur, bool up, int) const
bool MathRootInset::idxUpDown(LCursor & cur, bool up) const
{
bool target = !up; // up ? 0 : 1;
if (cur.idx() == target)

View File

@ -24,7 +24,7 @@ public:
///
virtual std::auto_ptr<InsetBase> clone() const;
///
bool idxUpDown(LCursor &, bool up, int targetx) const;
bool idxUpDown(LCursor & cur, bool up) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///

View File

@ -231,7 +231,7 @@ void MathScriptInset::draw(PainterInfo & pi, int x, int y) const
nuc().draw(pi, x + dxx(), y);
else {
nuc().setXY(x + dxx(), y);
if (editing())
if (editing(pi.base.bv))
drawStr(pi, pi.base.font, x + dxx(), y, ".");
}
ScriptChanger dummy(pi.base);
@ -326,7 +326,7 @@ bool MathScriptInset::idxLeft(LCursor &) const
}
bool MathScriptInset::idxUpDown(LCursor & cur, bool up, int) const
bool MathScriptInset::idxUpDown(LCursor & cur, bool up) const
{
if (cur.idx() == 1) {
// if we are 'up' we can't go further up

View File

@ -35,6 +35,19 @@ public:
///
void drawT(TextPainter & pi, int x, int y) const;
/// move cursor left
bool idxLeft(LCursor & cur) const;
/// move cursor right
bool idxRight(LCursor & cur) const;
/// move cursor up or down
bool idxUpDown(LCursor & cur, bool up) const;
/// Target pos when we enter the inset from the left by pressing "Right"
bool idxFirst(LCursor & cur) const;
/// Target pos when we enter the inset from the right by pressing "Left"
bool idxLast(LCursor & cur) const;
/// can we enter this cell?
bool validCell(idx_type i) const { return i == 2 || script_[i]; }
/// write LaTeX and Lyx code
void write(WriteStream & os) const;
/// write normalized content
@ -47,18 +60,6 @@ public:
void mathmlize(MathMLStream &) const;
/// write content as something readable by Octave
void octave(OctaveStream &) const;
/// move cursor left
bool idxLeft(LCursor &) const;
/// move cursor right
bool idxRight(LCursor &) const;
/// move cursor up or down
bool idxUpDown(LCursor &, bool up, int targetx) const;
/// Target pos when we enter the inset from the left by pressing "Right"
bool idxFirst(LCursor &) const;
/// Target pos when we enter the inset from the right by pressing "Left"
bool idxLast(LCursor &) const;
/// can we enter this cell?
bool validCell(idx_type i) const { return i == 2 || script_[i]; }
/// identifies scriptinsets
MathScriptInset const * asScriptInset() const;

View File

@ -50,8 +50,7 @@ void MathTextInset::getScreenPos(idx_type /*idx*/, pos_type pos, int & x, int &
#if 0
bool MathTextInset::idxUpDown2(LCursor & pos, bool up,
int /*targetx*/) const
bool MathTextInset::idxUpDown2(LCursor & pos, bool up) const
{
// try to move only one screen row up or down if possible
idx_type i = pos2row(pos);

View File

@ -33,7 +33,7 @@ public:
void drawSelection(PainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
/// moves cursor up or down
//bool idxUpDown2(LCursor & pos, bool up, int targetx) const;
//bool idxUpDown2(LCursor & pos, bool up) const;
protected:
/// row corresponding to given position
idx_type pos2row(pos_type pos) const;

View File

@ -64,13 +64,13 @@ bool MathUndersetInset::idxLast(LCursor & cur) const
}
bool MathUndersetInset::idxUpDown(LCursor & cur, bool up, int targetx) const
bool MathUndersetInset::idxUpDown(LCursor & cur, bool up) const
{
idx_type target = up; // up ? 1 : 0, since upper cell has idx 1
if (cur.idx() == target)
return false;
cur.idx() = target;
cur.pos() = cur.cell().x2pos(targetx);
cur.pos() = cur.cell().x2pos(cur.x_target());
return true;
}

View File

@ -25,15 +25,15 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
bool idxFirst(LCursor &) const;
bool idxFirst(LCursor & cur) const;
///
bool idxLast(LCursor &) const;
bool idxLast(LCursor & cur) const;
///
bool idxUpDown(LCursor &, bool up, int targetx) const;
bool idxUpDown(LCursor & cur, bool up) const;
///
void write(WriteStream & os) const;
void write(WriteStream & ws) const;
///
void normalize(NormalStream &) const;
void normalize(NormalStream & ns) const;
};
#endif

View File

@ -149,9 +149,8 @@ void docbookParagraphs(Buffer const & buf,
// This is a hack while paragraphs can't have
// attributes, like id in this case.
if (par->size() && par->isInset(0)) {
InsetOld * inset = par->getInset(0);
InsetOld::Code lyx_code = inset->lyxCode();
if (lyx_code == InsetOld::LABEL_CODE) {
InsetBase * inset = par->getInset(0);
if (inset->lyxCode() == InsetOld::LABEL_CODE) {
command_name += " id=\"";
command_name += (static_cast<InsetCommand *>(inset))->getContents();
command_name += '"';

View File

@ -194,8 +194,8 @@ InsetOptArg * optArgInset(Paragraph const & par)
InsetList::const_iterator it = par.insetlist.begin();
InsetList::const_iterator end = par.insetlist.end();
for (; it != end; ++it) {
InsetOld * ins = it->inset;
if (ins->lyxCode() == InsetOld::OPTARG_CODE) {
InsetBase * ins = it->inset;
if (ins->lyxCode() == InsetBase::OPTARG_CODE) {
return static_cast<InsetOptArg *>(ins);
}
}

View File

@ -46,9 +46,8 @@ void linuxdocParagraphs(Buffer const & buf,
LyXLayout_ptr const & style = pit->layout();
// treat <toc> as a special case for compatibility with old code
if (pit->isInset(0)) {
InsetOld * inset = pit->getInset(0);
InsetOld::Code lyx_code = inset->lyxCode();
if (lyx_code == InsetOld::TOC_CODE) {
InsetBase * inset = pit->getInset(0);
if (inset->lyxCode() == InsetOld::TOC_CODE) {
string const temp = "toc";
sgml::openTag(os, depth, false, temp);
continue;
@ -92,8 +91,7 @@ void linuxdocParagraphs(Buffer const & buf,
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT:
case LATEX_BIB_ENVIRONMENT:
{
case LATEX_BIB_ENVIRONMENT: {
string const & latexname = style->latexname();
if (depth == pit->params().depth()

View File

@ -204,7 +204,7 @@ void asciiParagraph(Buffer const & buf,
char c = par.getUChar(buf.params(), i);
switch (c) {
case Paragraph::META_INSET: {
InsetOld const * inset = par.getInset(i);
InsetBase const * inset = par.getInset(i);
if (runparams.linelen > 0) {
os << word;
currlinelen += word.length();
@ -225,13 +225,11 @@ void asciiParagraph(Buffer const & buf,
os << p.second;
currlinelen = p.first;
}
os << word << ' ';
currlinelen += word.length() + 1;
word.erase();
break;
case '\0':
lyxerr[Debug::INFO] <<
"writeAsciiFile: NULL char in structure." << endl;

View File

@ -85,10 +85,8 @@ Paragraph::Paragraph(Paragraph const & par)
insetlist = par.insetlist;
InsetList::iterator it = insetlist.begin();
InsetList::iterator end = insetlist.end();
for (; it != end; ++it) {
// currently we hold Inset*, not InsetBase*
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
}
for (; it != end; ++it)
it->inset = it->inset->clone().release();
}
@ -114,9 +112,8 @@ void Paragraph::operator=(Paragraph const & par)
insetlist = par.insetlist;
InsetList::iterator it = insetlist.begin();
InsetList::iterator end = insetlist.end();
for (; it != end; ++it) {
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
}
for (; it != end; ++it)
it->inset = it->inset->clone().release();
}
@ -181,7 +178,7 @@ void Paragraph::write(Buffer const & buf, ostream & os,
switch (c) {
case META_INSET:
{
InsetOld const * inset = getInset(i);
InsetBase const * inset = getInset(i);
if (inset)
if (inset->directWrite()) {
// international char, let it write
@ -290,13 +287,13 @@ void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
}
void Paragraph::insertInset(pos_type pos, InsetOld * inset)
void Paragraph::insertInset(pos_type pos, InsetBase * inset)
{
insertInset(pos, inset, LyXFont(LyXFont::ALL_INHERIT));
}
void Paragraph::insertInset(pos_type pos, InsetOld * inset,
void Paragraph::insertInset(pos_type pos, InsetBase * inset,
LyXFont const & font, Change change)
{
pimpl_->insertInset(pos, inset, font, change);
@ -312,14 +309,14 @@ bool Paragraph::insetAllowed(InsetOld_code code)
}
InsetOld * Paragraph::getInset(pos_type pos)
InsetBase * Paragraph::getInset(pos_type pos)
{
BOOST_ASSERT(pos < size());
return insetlist.get(pos);
}
InsetOld const * Paragraph::getInset(pos_type pos) const
InsetBase const * Paragraph::getInset(pos_type pos) const
{
BOOST_ASSERT(pos < size());
return insetlist.get(pos);
@ -689,7 +686,7 @@ void Paragraph::setBeginOfBody()
// returns -1 if inset not found
int Paragraph::getPositionOfInset(InsetOld const * inset) const
int Paragraph::getPositionOfInset(InsetBase const * inset) const
{
// Find the entry.
InsetList::const_iterator it = insetlist.begin();
@ -704,8 +701,8 @@ int Paragraph::getPositionOfInset(InsetOld const * inset) const
InsetBibitem * Paragraph::bibitem() const
{
if (!insetlist.empty()) {
InsetOld * inset = insetlist.begin()->inset;
if (inset->lyxCode() == InsetOld::BIBTEX_CODE)
InsetBase * inset = insetlist.begin()->inset;
if (inset->lyxCode() == InsetBase::BIBTEX_CODE)
return static_cast<InsetBibitem *>(inset);
}
return 0;
@ -720,9 +717,9 @@ namespace {
bool noTrivlistCentering(UpdatableInset const * inset)
{
if (inset && inset->owner()) {
InsetOld::Code const code = inset->owner()->lyxCode();
return code == InsetOld::FLOAT_CODE ||
code == InsetOld::WRAP_CODE;
InsetBase::Code const code = inset->owner()->lyxCode();
return code == InsetBase::FLOAT_CODE ||
code == InsetBase::WRAP_CODE;
}
return false;
}
@ -1087,7 +1084,7 @@ void sgmlLineBreak(ostream & os, string::size_type & colcount,
}
enum PAR_TAG {
NONE=0,
PAR_NONE=0,
TT = 1,
SF = 2,
BF = 4,
@ -1099,7 +1096,7 @@ enum PAR_TAG {
string tag_name(PAR_TAG const & pt) {
switch (pt) {
case NONE: return "!-- --";
case PAR_NONE: return "!-- --";
case TT: return "tt";
case SF: return "sf";
case BF: return "bf";
@ -1158,7 +1155,7 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf,
// parsing main loop
for (pos_type i = 0; i < size(); ++i) {
PAR_TAG tag_close = NONE;
PAR_TAG tag_close = PAR_NONE;
list < PAR_TAG > tag_open;
LyXFont const font = getFont(buf.params(), i, outerfont);
@ -1389,7 +1386,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
if (isInset(i)) {
InsetOld const * inset = getInset(i);
InsetBase const * inset = getInset(i);
// don't print the inset in position 0 if desc_on == 3 (label)
//if (i || desc_on != 3) {
if (!labelid) {
@ -1463,7 +1460,7 @@ bool IsInsetChar(char c)
bool Paragraph::isHfill(pos_type pos) const
{
return IsInsetChar(getChar(pos))
&& getInset(pos)->lyxCode() == InsetOld::HFILL_CODE;
&& getInset(pos)->lyxCode() == InsetBase::HFILL_CODE;
}
@ -1476,7 +1473,7 @@ bool Paragraph::isInset(pos_type pos) const
bool Paragraph::isNewline(pos_type pos) const
{
return IsInsetChar(getChar(pos))
&& getInset(pos)->lyxCode() == InsetOld::NEWLINE_CODE;
&& getInset(pos)->lyxCode() == InsetBase::NEWLINE_CODE;
}
@ -1539,7 +1536,7 @@ bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
return lyxrc.rtl_support
&& getParLanguage(bparams)->RightToLeft()
&& !(inInset() && inInset()->owner() &&
inInset()->owner()->lyxCode() == InsetOld::ERT_CODE);
inInset()->owner()->lyxCode() == InsetBase::ERT_CODE);
}
@ -1595,7 +1592,7 @@ string const Paragraph::asString(Buffer const & buffer,
if (IsPrintable(c))
s += c;
else if (c == META_INSET &&
getInset(i)->lyxCode() == InsetOld::MATH_CODE) {
getInset(i)->lyxCode() == InsetBase::MATH_CODE) {
ostringstream os;
getInset(i)->plaintext(buffer, os, runparams);
s += subst(STRCONV(os.str()),'\n',' ');
@ -1756,8 +1753,8 @@ int Paragraph::id() const
LyXLayout_ptr const & Paragraph::layout() const
{
/*
InsetOld * inset = inInset();
if (inset && inset->lyxCode() == InsetOld::ENVIRONMENT_CODE)
InsetBase * inset = inInset();
if (inset && inset->lyxCode() == InsetBase::ENVIRONMENT_CODE)
return static_cast<InsetEnvironment*>(inset)->layout();
*/
return layout_;
@ -1806,9 +1803,9 @@ bool Paragraph::isFreeSpacing() const
return true;
// for now we just need this, later should we need this in some
// other way we can always add a function to InsetOld too.
// other way we can always add a function to InsetBase too.
if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
return pimpl_->inset_owner->owner()->lyxCode() == InsetBase::ERT_CODE;
return false;
}
@ -1818,7 +1815,7 @@ bool Paragraph::allowEmpty() const
if (layout()->keepempty)
return true;
if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
return pimpl_->inset_owner->owner()->lyxCode() == InsetBase::ERT_CODE;
return false;
}

View File

@ -29,6 +29,7 @@ class Buffer;
class BufferParams;
class BufferView;
class Counters;
class InsetBase;
class InsetBibitem;
class InsetOld_code;
class Language;
@ -44,7 +45,7 @@ class UpdatableInset;
class Paragraph {
public:
///
enum META_KIND {
enum {
/// Note that this is 1 right now to avoid
/// crashes where getChar() is called wrongly
/// (returning 0) - if this was 0, then we'd
@ -61,12 +62,11 @@ public:
///
Paragraph();
///
Paragraph(Paragraph const &);
///
void operator=(Paragraph const &);
/// the destructor removes the new paragraph from the list
///
~Paragraph();
///
@ -276,19 +276,21 @@ public:
///
void insertChar(lyx::pos_type pos, value_type c);
///
void insertChar(lyx::pos_type pos, value_type c, LyXFont const &, Change change = Change(Change::INSERTED));
void insertChar(lyx::pos_type pos, value_type c,
LyXFont const &, Change change = Change(Change::INSERTED));
///
bool checkInsertChar(LyXFont &);
///
void insertInset(lyx::pos_type pos, InsetOld * inset);
void insertInset(lyx::pos_type pos, InsetBase * inset);
///
void insertInset(lyx::pos_type pos, InsetOld * inset, LyXFont const &, Change change = Change(Change::INSERTED));
void insertInset(lyx::pos_type pos, InsetBase * inset,
LyXFont const &, Change change = Change(Change::INSERTED));
///
bool insetAllowed(InsetOld_code code);
///
InsetOld * getInset(lyx::pos_type pos);
InsetBase * getInset(lyx::pos_type pos);
///
InsetOld const * getInset(lyx::pos_type pos) const;
InsetBase const * getInset(lyx::pos_type pos) const;
///
bool isHfill(lyx::pos_type pos) const;
@ -308,7 +310,7 @@ public:
bool isWord(lyx::pos_type pos) const;
/// returns -1 if inset not found
int getPositionOfInset(InsetOld const * inset) const;
int getPositionOfInset(InsetBase const * inset) const;
///
int stripLeadingSpaces();

View File

@ -77,7 +77,7 @@ bool moveItem(Paragraph & from, Paragraph & to,
LyXFont tmpfont = from.getFontSettings(params, i);
if (tmpchar == Paragraph::META_INSET) {
InsetOld * tmpinset = 0;
InsetBase * tmpinset = 0;
if (from.getInset(i)) {
// the inset is not in a paragraph anymore
tmpinset = from.insetlist.release(i);
@ -356,7 +356,7 @@ int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n"
<< "Missing \\begin_inset?.\n";
} else if (token == "\\begin_inset") {
InsetOld * inset = readInset(lex, buf);
InsetBase * inset = readInset(lex, buf);
if (inset)
par.insertInset(par.size(), inset, font, change);
else {
@ -431,7 +431,7 @@ int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
}
}
} else {
auto_ptr<InsetOld> inset;
auto_ptr<InsetBase> inset;
if (token == "\\SpecialChar" )
inset.reset(new InsetSpecialChar);
else
@ -441,17 +441,17 @@ int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
font, change);
}
} else if (token == "\\i") {
auto_ptr<InsetOld> inset(new InsetLatexAccent);
auto_ptr<InsetBase> inset(new InsetLatexAccent);
inset->read(buf, lex);
par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\backslash") {
par.insertChar(par.size(), '\\', font, change);
} else if (token == "\\newline") {
auto_ptr<InsetOld> inset(new InsetNewline);
auto_ptr<InsetBase> inset(new InsetNewline);
inset->read(buf, lex);
par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\LyXTable") {
auto_ptr<InsetOld> inset(new InsetTabular(buf));
auto_ptr<InsetBase> inset(new InsetTabular(buf));
inset->read(buf, lex);
par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\bibitem") {
@ -559,7 +559,7 @@ LyXFont const outerFont(ParagraphList::iterator pit,
}
ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset)
ParagraphList::iterator outerPar(Buffer const & buf, InsetBase const * inset)
{
ParIterator pit = const_cast<Buffer &>(buf).par_iterator_begin();
ParIterator end = const_cast<Buffer &>(buf).par_iterator_end();
@ -582,7 +582,7 @@ ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset)
}
Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
Paragraph const & ownerPar(Buffer const & buf, InsetBase const * inset)
{
ParConstIterator pit = buf.par_iterator_begin();
ParConstIterator end = buf.par_iterator_end();

View File

@ -22,7 +22,7 @@ class Buffer;
class BufferParams;
class LyXFont;
class LyXLex;
class InsetOld;
class InsetBase;
///
void breakParagraph(BufferParams const & bparams,
@ -70,10 +70,10 @@ LyXFont const outerFont(ParagraphList::iterator pit,
ParagraphList const & plist);
/// find outermost paragraph containing an inset
ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset);
ParagraphList::iterator outerPar(Buffer const & buf, InsetBase const * inset);
/// find owning paragraph containing an inset
Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset);
Paragraph const & ownerPar(Buffer const & buf, InsetBase const * inset);
/// return the range of pars [beg, end[ owning the range of y [ystart, yend]
void getParsInRange(ParagraphList & pl,

View File

@ -291,7 +291,7 @@ void Paragraph::Pimpl::insertChar(pos_type pos, value_type c,
void Paragraph::Pimpl::insertInset(pos_type pos,
InsetOld * inset, LyXFont const & font, Change change)
InsetBase * inset, LyXFont const & font, Change change)
{
BOOST_ASSERT(inset);
BOOST_ASSERT(pos <= size());
@ -467,8 +467,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
if (c != '\0')
os << c;
} else {
InsetOld const * inset = owner_->getInset(i);
inset->plaintext(buf, os, runparams);
owner_->getInset(i)->plaintext(buf, os, runparams);
}
return;
}
@ -478,14 +477,14 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
// and then split to handle the two modes separately.
switch (c) {
case Paragraph::META_INSET: {
InsetOld * inset = owner_->getInset(i);
InsetBase * inset = owner_->getInset(i);
// FIXME: remove this check
if (!inset)
break;
// FIXME: move this to InsetNewline::latex
if (inset->lyxCode() == InsetOld::NEWLINE_CODE) {
if (inset->lyxCode() == InsetBase::NEWLINE_CODE) {
// newlines are handled differently here than
// the default in simpleTeXSpecialChars().
if (!style.newline_allowed) {
@ -521,9 +520,9 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
bool close = false;
ostream::pos_type const len = os.tellp();
if ((inset->lyxCode() == InsetOld::GRAPHICS_CODE
|| inset->lyxCode() == InsetOld::MATH_CODE
|| inset->lyxCode() == InsetOld::URL_CODE)
if ((inset->lyxCode() == InsetBase::GRAPHICS_CODE
|| inset->lyxCode() == InsetBase::MATH_CODE
|| inset->lyxCode() == InsetBase::URL_CODE)
&& running_font.isRightToLeft()) {
os << "\\L{";
close = true;
@ -790,7 +789,7 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features,
if (icit->inset) {
icit->inset->validate(features);
if (layout.needprotect &&
icit->inset->lyxCode() == InsetOld::FOOT_CODE)
icit->inset->lyxCode() == InsetBase::FOOT_CODE)
features.require("NeedLyXFootnoteCode");
}
}

View File

@ -28,10 +28,14 @@ class LyXLayout;
struct Paragraph::Pimpl {
///
Pimpl(Paragraph * owner);
/// Copy constructor
/// "Copy constructor"
Pimpl(Pimpl const &, Paragraph * owner);
///
void setContentsFromPar(Paragraph const & par);
//
// Change tracking
//
/// set tracking mode
void trackChanges(Change::Type type = Change::UNCHANGED);
/// stop tracking
@ -46,32 +50,27 @@ struct Paragraph::Pimpl {
bool isChanged(lyx::pos_type start, lyx::pos_type end) const;
/// is there a non-addition in this range ?
bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const;
/// set change at pos
void setChange(lyx::pos_type pos, Change::Type type);
/// mark as erased
void markErased();
/// accept change
void acceptChange(lyx::pos_type start, lyx::pos_type end);
/// reject change
void rejectChange(lyx::pos_type start, lyx::pos_type end);
/// are we tracking changes ?
bool tracking() const {
return changes_.get();
}
bool tracking() const { return changes_.get(); }
///
value_type getChar(lyx::pos_type pos) const;
///
void setChar(lyx::pos_type pos, value_type c);
///
void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font, Change change = Change(Change::INSERTED));
void insertChar(lyx::pos_type pos, value_type c,
LyXFont const & font, Change change = Change(Change::INSERTED));
///
void insertInset(lyx::pos_type pos, InsetOld * inset, LyXFont const & font, Change change = Change(Change::INSERTED));
void insertInset(lyx::pos_type pos, InsetBase * inset,
LyXFont const & font, Change change = Change(Change::INSERTED));
/// definite erase
void eraseIntern(lyx::pos_type pos);
/// erase the given position. Returns true if it was actually erased
@ -96,9 +95,9 @@ struct Paragraph::Pimpl {
///
FontTable(lyx::pos_type p, LyXFont const & f)
: pos_(p)
{
font_ = container.get(f);
}
{
font_ = container.get(f);
}
///
lyx::pos_type pos() const { return pos_; }
///

View File

@ -189,10 +189,8 @@ int RowPainter::leftMargin() const
void RowPainter::paintInset(pos_type const pos)
{
InsetOld * inset = const_cast<InsetOld*>(pit_->getInset(pos));
InsetBase * inset = const_cast<InsetBase *>(pit_->getInset(pos));
BOOST_ASSERT(inset);
PainterInfo pi(const_cast<BufferView *>(&bv_));
pi.base.font = getFont(pos);
inset->draw(pi, int(x_), yo_ + row_.baseline());
@ -242,7 +240,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
// first char
char c = pit_->getChar(pos);
c = pit_->transformChar(c, pos);
str +=c;
str += c;
++vpos;
LyXFont const & font = getFont(pos);
@ -392,13 +390,13 @@ void RowPainter::paintSelection()
// the current selection
LCursor const & cur = bv_.cursor();
int const startx = text_.cursorX(cur.selStart());
int const startx = text_.cursorX(cur.selBegin());
int const endx = text_.cursorX(cur.selEnd());
int const starty = text_.cursorY(cur.selStart());
int const starty = text_.cursorY(cur.selBegin());
int const endy = text_.cursorY(cur.selEnd());
ParagraphList::iterator startpit = text_.getPar(cur.selStart());
ParagraphList::iterator startpit = text_.getPar(cur.selBegin());
ParagraphList::iterator endpit = text_.getPar(cur.selEnd());
RowList::iterator startrow = startpit->getRow(cur.selStart().pos());
RowList::iterator startrow = startpit->getRow(cur.selBegin().pos());
RowList::iterator endrow = endpit->getRow(cur.selEnd().pos());
int const h = row_.height();
@ -469,7 +467,7 @@ void RowPainter::paintSelection()
}
if (((startpit != pit_ && startrow != rit_)
|| cur.selStart().pos() <= pos) &&
|| cur.selBegin().pos() <= pos) &&
((endpit != pit_ && endrow != rit_)
|| pos < cur.selEnd().pos())) {
// Here we do not use x_ as xo_ was added to x_.

View File

@ -2542,7 +2542,7 @@ InsetText & LyXTabular::getCellInset(int row, int column) const
}
int LyXTabular::getCellFromInset(InsetOld const * inset) const
int LyXTabular::getCellFromInset(InsetBase const * inset) const
{
// is this inset part of the tabular?
if (!inset) {

View File

@ -371,7 +371,7 @@ public:
InsetText & getCellInset(int row, int column) const;
/// Search for \param inset in the tabular, with the
///
int getCellFromInset(InsetOld const * inset) const;
int getCellFromInset(InsetBase const * inset) const;
///
int rows() const { return rows_; }
///

View File

@ -1027,7 +1027,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
int const ns = numberOfSeparators(*pit, row);
bool disp_inset = false;
if (row.endpos() < pit->size()) {
InsetOld * in = pit->getInset(row.endpos());
InsetBase * in = pit->getInset(row.endpos());
if (in)
disp_inset = in->display();
}
@ -1127,8 +1127,8 @@ void LyXText::acceptChange()
if (!cur.selection() && cursorPar()->size())
return;
if (cur.selStart().par() == cur.par()) {
CursorSlice const & startc = cur.selStart();
if (cur.selBegin().par() == cur.par()) {
CursorSlice const & startc = cur.selBegin();
CursorSlice const & endc = cur.selEnd();
recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->acceptChange(startc.pos(), endc.pos());
@ -1147,8 +1147,8 @@ void LyXText::rejectChange()
if (!cur.selection() && cursorPar()->size())
return;
if (cur.selStart().par() == cur.selEnd().par()) {
CursorSlice const & startc = cur.selStart();
if (cur.selBegin().par() == cur.selEnd().par()) {
CursorSlice const & startc = cur.selBegin();
CursorSlice const & endc = cur.selEnd();
recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->rejectChange(startc.pos(), endc.pos());
@ -1230,7 +1230,7 @@ void LyXText::changeCase(LyXText::TextCase action)
CursorSlice to;
if (cur.selection()) {
from = cur.selStart();
from = cur.selBegin();
to = cur.selEnd();
} else {
from = cursor();
@ -1517,9 +1517,9 @@ string LyXText::selectionAsString(Buffer const & buffer, bool label) const
return string();
// should be const ...
ParagraphList::iterator startpit = getPar(cur.selStart());
ParagraphList::iterator startpit = getPar(cur.selBegin());
ParagraphList::iterator endpit = getPar(cur.selEnd());
size_t const startpos = cur.selStart().pos();
size_t const startpos = cur.selBegin().pos();
size_t const endpos = cur.selEnd().pos();
if (startpit == endpit)

View File

@ -214,7 +214,7 @@ void LyXText::setCharFont(
}
InsetOld * LyXText::getInset() const
InsetBase * LyXText::getInset() const
{
ParagraphList::iterator pit = cursorPar();
pos_type const pos = cursor().pos();
@ -228,7 +228,7 @@ InsetOld * LyXText::getInset() const
bool LyXText::toggleInset()
{
InsetOld * inset = getInset();
InsetBase * inset = getInset();
// is there an editable inset at cursor position?
if (!isEditableInset(inset))
return false;
@ -324,7 +324,7 @@ void LyXText::setLayout(string const & layout)
bv()->owner()->dispatch(FuncRequest(LFUN_HOME));
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
InsetOld * inset = new InsetEnvironment(params, layout);
InsetBase * inset = new InsetEnvironment(params, layout);
if (bv()->insertInset(inset)) {
//inset->edit(bv());
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
@ -334,7 +334,7 @@ void LyXText::setLayout(string const & layout)
}
ParagraphList::iterator start =
getPar(bv()->cursor().selStart().par());
getPar(bv()->cursor().selBegin().par());
ParagraphList::iterator end =
boost::next(getPar(bv()->cursor().selEnd().par()));
ParagraphList::iterator endpit = setLayout(start, end, layout);
@ -355,7 +355,7 @@ void getSelectionSpan(LyXText & text,
beg = text.cursorPar();
end = boost::next(beg);
} else {
beg = text.getPar(text.bv()->cursor().selStart());
beg = text.getPar(text.bv()->cursor().selBegin());
end = boost::next(text.getPar(text.bv()->cursor().selEnd()));
}
}
@ -451,13 +451,13 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
}
// ok we have a selection.
recUndo(cur.selStart().par(), cur.selEnd().par());
recUndo(cur.selBegin().par(), cur.selEnd().par());
freezeUndo();
ParagraphList::iterator beg = getPar(cur.selStart().par());
ParagraphList::iterator beg = getPar(cur.selBegin().par());
ParagraphList::iterator end = getPar(cur.selEnd().par());
PosIterator pos(&paragraphs(), beg, cur.selStart().pos());
PosIterator pos(&paragraphs(), beg, cur.selBegin().pos());
PosIterator posend(&paragraphs(), end, cur.selEnd().pos());
BufferParams const & params = bv()->buffer()->params();
@ -553,7 +553,7 @@ string LyXText::getStringToIndex()
string idxstring;
if (!cur.selection())
bv()->owner()->message(_("Nothing to index!"));
else if (cur.selStart().par() != cur.selEnd().par())
else if (cur.selBegin().par() != cur.selEnd().par())
bv()->owner()->message(_("Cannot index more than one paragraph!"));
else
idxstring = selectionAsString(*bv()->buffer(), false);
@ -582,10 +582,10 @@ void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
LCursor & cur = bv()->cursor();
// make sure that the depth behind the selection are restored, too
ParagraphList::iterator undopit = undoSpan(getPar(cur.selEnd()));
recUndo(cur.selStart().par(), parOffset(undopit) - 1);
recUndo(cur.selBegin().par(), parOffset(undopit) - 1);
ParagraphList::reverse_iterator pit(getPar(cur.selEnd().par()));
ParagraphList::reverse_iterator beg(getPar(cur.selStart().par()));
ParagraphList::reverse_iterator beg(getPar(cur.selBegin().par()));
for (--pit; pit != beg; ++pit) {
ParagraphParameters & params = pit->params();
@ -606,7 +606,7 @@ void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
params.noindent(noindent);
}
redoParagraphs(getPar(cur.selStart()), undopit);
redoParagraphs(getPar(cur.selBegin()), undopit);
}
@ -819,14 +819,14 @@ void LyXText::setCounter(Buffer const & buf, ParagraphList::iterator pit)
if (layout->labeltype == LABEL_SENSITIVE) {
ParagraphList::iterator end = paragraphs().end();
ParagraphList::iterator tmppit = pit;
InsetOld * in = 0;
InsetBase * in = 0;
bool isOK = false;
while (tmppit != end && tmppit->inInset()
// the single '=' is intended below
&& (in = tmppit->inInset()->owner()))
{
if (in->lyxCode() == InsetOld::FLOAT_CODE ||
in->lyxCode() == InsetOld::WRAP_CODE) {
if (in->lyxCode() == InsetBase::FLOAT_CODE ||
in->lyxCode() == InsetBase::WRAP_CODE) {
isOK = true;
break;
} else {
@ -841,9 +841,9 @@ void LyXText::setCounter(Buffer const & buf, ParagraphList::iterator pit)
if (isOK) {
string type;
if (in->lyxCode() == InsetOld::FLOAT_CODE)
if (in->lyxCode() == InsetBase::FLOAT_CODE)
type = static_cast<InsetFloat*>(in)->params().type;
else if (in->lyxCode() == InsetOld::WRAP_CODE)
else if (in->lyxCode() == InsetBase::WRAP_CODE)
type = static_cast<InsetWrap*>(in)->params().type;
else
BOOST_ASSERT(false);
@ -899,7 +899,7 @@ void LyXText::updateCounters()
}
void LyXText::insertInset(InsetOld * inset)
void LyXText::insertInset(InsetBase * inset)
{
if (!cursorPar()->insetAllowed(inset->lyxCode()))
return;
@ -938,14 +938,14 @@ void LyXText::cutSelection(bool doclear, bool realcut)
if (!cur.selection())
return;
// OK, we have a selection. This is always between cur.selStart()
// OK, we have a selection. This is always between cur.selBegin()
// and cur.selEnd()
// make sure that the depth behind the selection are restored, too
ParagraphList::iterator begpit = getPar(cur.selStart().par());
ParagraphList::iterator begpit = getPar(cur.selBegin().par());
ParagraphList::iterator endpit = getPar(cur.selEnd().par());
ParagraphList::iterator undopit = undoSpan(endpit);
recUndo(cur.selStart().par(), parOffset(undopit) - 1);
recUndo(cur.selBegin().par(), parOffset(undopit) - 1);
int endpos = cur.selEnd().pos();
@ -954,13 +954,13 @@ void LyXText::cutSelection(bool doclear, bool realcut)
CutAndPaste::cutSelection(bufparams,
paragraphs(),
begpit , endpit,
cur.selStart().pos(), endpos,
cur.selBegin().pos(), endpos,
bufparams.textclass,
doclear)
: CutAndPaste::eraseSelection(bufparams,
paragraphs(),
begpit, endpit,
cur.selStart().pos(), endpos,
cur.selBegin().pos(), endpos,
doclear);
// sometimes necessary
if (doclear)
@ -989,19 +989,19 @@ void LyXText::copySelection()
if (!cur.selection())
return;
// ok we have a selection. This is always between cur.selStart()
// ok we have a selection. This is always between cur.selBegin()
// and sel_end cursor
// copy behind a space if there is one
while (getPar(cur.selStart())->size() > cur.selStart().pos()
&& getPar(cur.selStart())->isLineSeparator(cur.selStart().pos())
&& (cur.selStart().par() != cur.selEnd().par()
|| cur.selStart().pos() < cur.selEnd().pos()))
cur.selStart().pos(cur.selStart().pos() + 1);
while (getPar(cur.selBegin())->size() > cur.selBegin().pos()
&& getPar(cur.selBegin())->isLineSeparator(cur.selBegin().pos())
&& (cur.selBegin().par() != cur.selEnd().par()
|| cur.selBegin().pos() < cur.selEnd().pos()))
cur.selBegin().pos(cur.selBegin().pos() + 1);
CutAndPaste::copySelection(getPar(cur.selStart().par()),
CutAndPaste::copySelection(getPar(cur.selBegin().par()),
getPar(cur.selEnd().par()),
cur.selStart().pos(),
cur.selBegin().pos(),
cur.selEnd().pos(),
bv()->buffer()->params().textclass);
}
@ -1062,9 +1062,9 @@ void LyXText::replaceSelectionWithString(string const & str)
// Get font setting before we cut
pos_type pos = cur.selEnd().pos();
LyXFont const font = getPar(cur.selStart())
LyXFont const font = getPar(cur.selBegin())
->getFontSettings(bv()->buffer()->params(),
cur.selStart().pos());
cur.selBegin().pos());
// Insert the new string
string::const_iterator cit = str.begin();
@ -1375,7 +1375,7 @@ bool LyXText::checkAndActivateInset(bool front)
{
if (cursor().pos() == cursorPar()->size())
return false;
InsetOld * inset = cursorPar()->getInset(cursor().pos());
InsetBase * inset = cursorPar()->getInset(cursor().pos());
if (!isHighlyEditableInset(inset))
return false;
inset->edit(bv()->cursor(), front);
@ -1508,7 +1508,7 @@ void LyXText::cursorUp(bool selecting)
if (!selecting) {
int y_abs = y + yo_ - bv()->top_y();
InsetOld * inset_hit = checkInsetHit(cur.x_target(), y_abs);
InsetBase * inset_hit = checkInsetHit(cur.x_target(), y_abs);
if (inset_hit && isHighlyEditableInset(inset_hit))
inset_hit->edit(cur, cur.x_target(), y_abs);
}
@ -1525,7 +1525,7 @@ void LyXText::cursorDown(bool selecting)
if (!selecting) {
int y_abs = y + yo_ - bv()->top_y();
InsetOld * inset_hit = checkInsetHit(cur.x_target(), y_abs);
InsetBase * inset_hit = checkInsetHit(cur.x_target(), y_abs);
if (inset_hit && isHighlyEditableInset(inset_hit))
inset_hit->edit(cur, cur.x_target(), y_abs);
}

View File

@ -48,7 +48,7 @@
#include "support/tostr.h"
#include "support/std_sstream.h"
#include "mathed/formulabase.h"
#include "mathed/math_hullinset.h"
#include <clocale>
@ -69,7 +69,7 @@ using std::vector;
extern string current_layout;
// the selection possible is needed, that only motion events are
// used, where the bottom press event was on the drawing area too
// used, where the button press event was on the drawing area too
bool selection_possible = false;
@ -246,7 +246,7 @@ string const freefont2string()
}
InsetOld * LyXText::checkInsetHit(int x, int y)
InsetBase * LyXText::checkInsetHit(int x, int y)
{
ParagraphList::iterator pit;
ParagraphList::iterator end;
@ -261,7 +261,7 @@ InsetOld * LyXText::checkInsetHit(int x, int y)
InsetList::iterator iit = pit->insetlist.begin();
InsetList::iterator iend = pit->insetlist.end();
for ( ; iit != iend; ++iit) {
InsetOld * inset = iit->inset;
InsetBase * inset = iit->inset;
//lyxerr << "examining inset " << inset
// << " xy: " << inset->x() << "/" << inset->y()
// << " x: " << inset->x() << "..." << inset->x() + inset->width()
@ -283,14 +283,14 @@ InsetOld * LyXText::checkInsetHit(int x, int y)
}
bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
bool LyXText::gotoNextInset(vector<InsetOld_code> const & codes,
string const & contents)
{
ParagraphList::iterator end = paragraphs().end();
ParagraphList::iterator pit = cursorPar();
pos_type pos = cursor().pos();
InsetOld * inset;
InsetBase * inset;
do {
if (pos + 1 < pit->size()) {
++pos;
@ -315,7 +315,7 @@ bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
}
void LyXText::gotoInset(vector<InsetOld::Code> const & codes, bool same_content)
void LyXText::gotoInset(vector<InsetOld_code> const & codes, bool same_content)
{
LCursor & cur = bv()->cursor();
cur.clearSelection();
@ -324,7 +324,7 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes, bool same_content)
if (same_content
&& cur.pos() < cur.lastpos()
&& cur.paragraph().isInset(cur.pos())) {
InsetOld const * inset = cur.paragraph().getInset(cur.pos());
InsetBase const * inset = cur.paragraph().getInset(cur.pos());
if (find(codes.begin(), codes.end(), inset->lyxCode())
!= codes.end())
contents = static_cast<InsetCommand const *>(inset)->getContents();
@ -348,9 +348,9 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes, bool same_content)
}
void LyXText::gotoInset(InsetOld::Code code, bool same_content)
void LyXText::gotoInset(InsetOld_code code, bool same_content)
{
gotoInset(vector<InsetOld::Code>(1, code), same_content);
gotoInset(vector<InsetOld_code>(1, code), same_content);
}
@ -412,7 +412,7 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
void doInsertInset(BufferView * bv, FuncRequest const & cmd,
bool edit, bool pastesel)
{
InsetOld * inset = createInset(bv, cmd);
InsetBase * inset = createInset(bv, cmd);
if (!inset)
return;
@ -865,7 +865,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
case LFUN_INSET_INSERT: {
InsetOld * inset = createInset(bv, cmd);
InsetBase * inset = createInset(bv, cmd);
if (inset && !bv->insertInset(inset))
delete inset;
break;
@ -1042,9 +1042,9 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
bool change_layout = (current_layout != layout);
if (!change_layout && cur.selection() &&
cur.selStart().par() != cur.selEnd().par())
cur.selBegin().par() != cur.selEnd().par())
{
ParagraphList::iterator spit = getPar(cur.selStart());
ParagraphList::iterator spit = getPar(cur.selBegin());
ParagraphList::iterator epit = boost::next(getPar(cur.selEnd()));
while (spit != epit) {
if (spit->layout()->name() != current_layout) {
@ -1079,17 +1079,17 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
case LFUN_GOTOERROR:
gotoInset(InsetOld::ERROR_CODE, false);
gotoInset(InsetBase::ERROR_CODE, false);
break;
case LFUN_GOTONOTE:
gotoInset(InsetOld::NOTE_CODE, false);
gotoInset(InsetBase::NOTE_CODE, false);
break;
case LFUN_REFERENCE_GOTO: {
vector<InsetOld::Code> tmp;
tmp.push_back(InsetOld::LABEL_CODE);
tmp.push_back(InsetOld::REF_CODE);
vector<InsetOld_code> tmp;
tmp.push_back(InsetBase::LABEL_CODE);
tmp.push_back(InsetBase::REF_CODE);
gotoInset(tmp, true);
break;
}