}
-InsetBase * LyXText::getInset() const
-{
- ParagraphList::iterator pit = cursorPar();
- pos_type const pos = cursor().pos();
-
- if (pos < pit->size() && pit->isInset(pos)) {
- return pit->getInset(pos);
- }
- return 0;
-}
-
-
-bool LyXText::toggleInset()
-{
- InsetBase * inset = getInset();
- // is there an editable inset at cursor position?
- if (!isEditableInset(inset))
- return false;
- //bv()->owner()->message(inset->editMessage());
-
- // do we want to keep this?? (JMarc)
- if (!isHighlyEditableInset(inset))
- recUndo(cursor().par());
-
- if (inset->isOpen())
- inset->close();
- else
- inset->open();
- return true;
-}
-
-
// used in setLayout
// Asger is not sure we want to do this...
void LyXText::makeFontEntriesLayoutSpecific(BufferParams const & params,
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
InsetBase * inset = new InsetEnvironment(params, layout);
- if (bv()->insertInset(inset)) {
- //inset->edit(bv());
- //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
- } else
- delete inset;
+ insertInset(inset);
+ //inset->edit(bv());
+ //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
return;
}
void LyXText::cursorBottom()
{
- ParagraphList::iterator lastpit =
- boost::prior(paragraphs().end());
+ ParagraphList::iterator lastpit = boost::prior(paragraphs().end());
setCursor(lastpit, lastpit->size());
}
else if (cur.selBegin().par() != cur.selEnd().par())
bv()->owner()->message(_("Cannot index more than one paragraph!"));
else
- idxstring = selectionAsString(*bv()->buffer(), false);
+ idxstring = cur.selectionAsString(false);
// Reset cursors to their original position.
cursor() = reset_cursor;
// finished. The solution used currently just works, to make it
// faster we need to be more clever and probably also have more
// calls to stuffClipboard. (Lgb)
- bv()->stuffClipboard(selectionAsString(*bv()->buffer(), true));
+ bv()->stuffClipboard(cur.selectionAsString(true));
// This doesn't make sense, if there is no selection
if (!cur.selection())
{
LCursor & cur = bv()->cursor();
// stuff the selection onto the X clipboard, from an explicit copy request
- bv()->stuffClipboard(selectionAsString(*bv()->buffer(), true));
+ bv()->stuffClipboard(cur.selectionAsString(true));
// this doesnt make sense, if there is no selection
if (!cur.selection())
ParagraphList::iterator pit = cursorPar();
pos_type pos = cursor().pos();
ParagraphList::iterator endpit = boost::next(cursorPar());
-
- recUndo(cursor().par());
+ recordUndo(cur, Undo::ATOMIC);
// only to be sure, should not be neccessary
cur.clearSelection();
}
}
-
+// x is an absolute screen coord
// returns the column near the specified x-coordinate of the row
// x is set to the real beginning of this column
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
ParagraphList::iterator pit;
Row const & row = *getRowNearY(y, pit);
bool bound = false;
- pos_type const pos = row.pos() + getColumnNearX(pit, row, x, bound);
+ int xx = x + xo_; // getRowNearX get absolute x coords
+ pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
cur.par() = parOffset(pit);
cur.pos() = pos;
cur.boundary() = bound;
// x,y are absolute screen coordinates
void LyXText::edit(LCursor & cur, int x, int y)
{
- int xx = x; // is modified by getColumnNearX
ParagraphList::iterator pit;
- Row const & row = *getRowNearY(y, pit);
+ Row const & row = *getRowNearY(y - yo_, pit);
bool bound = false;
+
+ int xx = x; // is modified by getColumnNearX
pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
cur.par() = parOffset(pit);
cur.pos() = pos;
// try to descend into nested insets
InsetBase * inset = checkInsetHit(x, y);
if (inset) {
- // This should be just before or just behind the cursor position
- // set above.
+ // This should be just before or just behind the
+ // cursor position set above.
BOOST_ASSERT((pos != 0 && inset == pit->getInset(pos - 1))
|| inset == pit->getInset(pos));
- // Make sure the cursor points to the position before this inset.
+ // Make sure the cursor points to the position before
+ // this inset.
if (inset == pit->getInset(pos - 1))
--cur.pos();
inset->edit(cur, x, y);
DispatchResult LyXText::moveUp()
{
- if (cursorPar() == firstPar() && cursorRow() == firstRow())
+ LCursor & cur = bv()->cursor();
+ if (cur.par() == 0 && cursorRow() == firstRow())
return DispatchResult(false, FINISHED_UP);
cursorUp(false);
- bv()->cursor().clearSelection();
+ cur.clearSelection();
return DispatchResult(true);
}
DispatchResult LyXText::moveDown()
{
LCursor & cur = bv()->cursor();
- if (cursorPar() == lastPar() && cursorRow() == lastRow())
+ if (cur.par() == cur.lastpar() && cursorRow() == lastRow())
return DispatchResult(false, FINISHED_DOWN);
cursorDown(false);
cur.clearSelection();
void LyXText::recUndo(paroffset_type first, paroffset_type last) const
{
- recordUndo(Undo::ATOMIC, this, first, last);
+ recordUndo(bv()->cursor(), Undo::ATOMIC, first, last);
}
void LyXText::recUndo(lyx::paroffset_type par) const
{
- recordUndo(Undo::ATOMIC, this, par, par);
+ recordUndo(bv()->cursor(), Undo::ATOMIC, par, par);
}
}
+bool LyXText::toggleInset()
+{
+ InsetBase * inset = bv()->cursor().nextInset();
+ // is there an editable inset at cursor position?
+ if (!isEditableInset(inset))
+ return false;
+ //bv()->owner()->message(inset->editMessage());
+
+ // do we want to keep this?? (JMarc)
+ if (!isHighlyEditableInset(inset))
+ recUndo(cursor().par());
+
+ if (inset->isOpen())
+ inset->close();
+ else
+ inset->open();
+ return true;
+}
+
+
int defaultRowHeight()
{
return int(font_metrics::maxHeight(LyXFont(LyXFont::ALL_SANE)) * 1.2);