mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Make lyxcursor store a ParagraphList::iterator, change three functions to take a ParagraphList::iterator instead of a ParagraphList::iterator. Other changes to adjust for this.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6741 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
80837fb324
commit
0408f69287
@ -358,7 +358,7 @@ bool BufferView::insertLyXFile(string const & filen)
|
||||
bool BufferView::removeAutoInsets()
|
||||
{
|
||||
// keep track of which pos and par the cursor was on
|
||||
Paragraph * cursor_par = text->cursor.par();
|
||||
Paragraph * cursor_par = &*text->cursor.par();
|
||||
Paragraph * cursor_par_prev = cursor_par ? cursor_par->previous() : 0;
|
||||
Paragraph * cursor_par_next = cursor_par ? cursor_par->next() : 0;
|
||||
pos_type cursor_pos = text->cursor.pos();
|
||||
@ -830,7 +830,7 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
|
||||
if (kind == Undo::EDIT) // in this case insets would not be stored!
|
||||
kind = Undo::FINISH;
|
||||
setUndo(this, kind,
|
||||
text->cursor.par(),
|
||||
&*text->cursor.par(),
|
||||
text->cursor.par()->next());
|
||||
}
|
||||
|
||||
|
@ -275,11 +275,11 @@ int BufferView::Pimpl::resizeCurrentBuffer()
|
||||
owner_->message(_("Formatting document..."));
|
||||
|
||||
if (bv_->text) {
|
||||
par = bv_->text->cursor.par();
|
||||
par = &*bv_->text->cursor.par();
|
||||
pos = bv_->text->cursor.pos();
|
||||
selstartpar = bv_->text->selection.start.par();
|
||||
selstartpar = &*bv_->text->selection.start.par();
|
||||
selstartpos = bv_->text->selection.start.pos();
|
||||
selendpar = bv_->text->selection.end.par();
|
||||
selendpar = &*bv_->text->selection.end.par();
|
||||
selendpos = bv_->text->selection.end.pos();
|
||||
selection = bv_->text->selection.set();
|
||||
mark_set = bv_->text->selection.mark();
|
||||
@ -1172,7 +1172,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_PARAGRAPH: {
|
||||
Paragraph const * par = bv_->getLyXText()->cursor.par();
|
||||
Paragraph const * par = &*bv_->getLyXText()->cursor.par();
|
||||
if (!par)
|
||||
break;
|
||||
|
||||
@ -1185,7 +1185,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
||||
}
|
||||
|
||||
case LFUN_PARAGRAPH_UPDATE: {
|
||||
Paragraph const * par = bv_->getLyXText()->cursor.par();
|
||||
Paragraph const * par = &*bv_->getLyXText()->cursor.par();
|
||||
if (!par)
|
||||
break;
|
||||
|
||||
|
@ -1,3 +1,59 @@
|
||||
2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* undo_funcs.C (setCursorParUndo): adjust
|
||||
|
||||
* text_funcs.C (transposeChars): adjust
|
||||
|
||||
* text3.C (gotoNextInset): adjust
|
||||
(dispatch): adjust
|
||||
|
||||
* text2.C (setLayout): adjust
|
||||
(changeDepth): adjust
|
||||
(setFont): adjust
|
||||
(redoParagraphs): adjust
|
||||
(selectionAsString): adjust
|
||||
(setParagraph): adjust
|
||||
(insertInset): adjust
|
||||
(cutSelection): adjust
|
||||
(copySelection): adjust
|
||||
(pasteSelection): adjust
|
||||
(insertStringAsLines): adjust
|
||||
(updateInset): adjust
|
||||
(setCursor): change to take a ParagraphList::iterator parameter
|
||||
(setCursorIntern): change to take a ParagraphList::iterator parameter
|
||||
(setCurrentFont): adjust
|
||||
(cursorLeft): adjust
|
||||
(cursorRight): adjust
|
||||
(deleteEmptyParagraphMechanism): adjust
|
||||
|
||||
* text.C (breakParagraph): adjust
|
||||
(insertChar): adjust
|
||||
(acceptChange): adjust
|
||||
(rejectChange): adjust
|
||||
(selectNextWordToSpellcheck): adjust
|
||||
(changeCase): adjust
|
||||
(Delete): adjust
|
||||
(backspace): adjust
|
||||
|
||||
* lyxfind.C (SearchForward): adjust
|
||||
(SearchBackward): adjust
|
||||
(nextChange): adjust
|
||||
|
||||
* lyxcursor.C (par): adjust
|
||||
|
||||
* lyxcursor.h: store a ParagraphList::iterator instead of a
|
||||
Paragraph*
|
||||
|
||||
* lyx_cb.C (getPossibleLabel): adjust
|
||||
|
||||
* bufferview_funcs.C (toggleAndShow): adjust
|
||||
|
||||
* BufferView_pimpl.C (resizeCurrentBuffer): adjust
|
||||
(dispatch): adjust
|
||||
|
||||
* BufferView.C (removeAutoInsets): adjust
|
||||
(lockedInsetStoreUndo): adjust
|
||||
|
||||
2003-04-09 John Levon <levon@movementarian.org>
|
||||
|
||||
* ToolbarBackend.C: try icon without argument
|
||||
|
@ -400,7 +400,7 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
LyXCursor & cursor = text->cursor;
|
||||
text->computeBidiTables(bv->buffer(), cursor.row());
|
||||
if (cursor.boundary() !=
|
||||
text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(),
|
||||
text->isBoundary(bv->buffer(), &*cursor.par(), cursor.pos(),
|
||||
text->real_current_font))
|
||||
text->setCursor(cursor.par(), cursor.pos(),
|
||||
false, !cursor.boundary());
|
||||
|
@ -1,3 +1,16 @@
|
||||
2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* insettext.C (saveLyXTextState): adjust
|
||||
(localDispatch): adjust
|
||||
(setFont): adjust
|
||||
(cx): adjust
|
||||
(cix): adjust
|
||||
(cpar): adjust
|
||||
|
||||
* insettabular.C (localDispatch): adjust
|
||||
(setFont): adjust
|
||||
(tabularFeatures): adjust
|
||||
|
||||
2003-04-05 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* insettabular.C (searchForward,searchBackward): fix bug 782
|
||||
|
@ -1070,8 +1070,8 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
|
||||
// no break here!
|
||||
case LFUN_DELETE:
|
||||
setUndo(bv, Undo::DELETE,
|
||||
bv->text->cursor.par(),
|
||||
bv->text->cursor.par()->next());
|
||||
&*bv->text->cursor.par(),
|
||||
&*boost::next(bv->text->cursor.par()));
|
||||
cutSelection(bv->buffer()->params);
|
||||
updateLocal(bv, INIT);
|
||||
break;
|
||||
@ -1155,8 +1155,8 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
|
||||
case LFUN_PASTE:
|
||||
if (hasPasteBuffer()) {
|
||||
setUndo(bv, Undo::INSERT,
|
||||
bv->text->cursor.par(),
|
||||
bv->text->cursor.par()->next());
|
||||
&*bv->text->cursor.par(),
|
||||
&*boost::next(bv->text->cursor.par()));
|
||||
pasteSelection(bv);
|
||||
updateLocal(bv, INIT);
|
||||
break;
|
||||
@ -1684,8 +1684,8 @@ void InsetTabular::setFont(BufferView * bv, LyXFont const & font, bool tall,
|
||||
}
|
||||
if (hasSelection()) {
|
||||
setUndo(bv, Undo::EDIT,
|
||||
bv->text->cursor.par(),
|
||||
bv->text->cursor.par()->next());
|
||||
&*bv->text->cursor.par(),
|
||||
&*boost::next(bv->text->cursor.par()));
|
||||
bool const frozen = undo_frozen;
|
||||
if (!frozen)
|
||||
freezeUndo();
|
||||
@ -1808,8 +1808,8 @@ void InsetTabular::tabularFeatures(BufferView * bv,
|
||||
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
|
||||
}
|
||||
setUndo(bv, Undo::FINISH,
|
||||
bv->text->cursor.par(),
|
||||
bv->text->cursor.par()->next());
|
||||
&*bv->text->cursor.par(),
|
||||
&*boost::next(bv->text->cursor.par()));
|
||||
|
||||
int row = tabular->row_of_cell(actcell);
|
||||
int column = tabular->column_of_cell(actcell);
|
||||
|
@ -84,13 +84,13 @@ void InsetText::saveLyXTextState(LyXText * t) const
|
||||
}
|
||||
|
||||
if (it != end && t->cursor.pos() <= it->size()) {
|
||||
sstate.lpar = t->cursor.par();
|
||||
sstate.lpar = &*t->cursor.par();
|
||||
sstate.pos = t->cursor.pos();
|
||||
sstate.boundary = t->cursor.boundary();
|
||||
sstate.selstartpar = t->selection.start.par();
|
||||
sstate.selstartpar = &*t->selection.start.par();
|
||||
sstate.selstartpos = t->selection.start.pos();
|
||||
sstate.selstartboundary = t->selection.start.boundary();
|
||||
sstate.selendpar = t->selection.end.par();
|
||||
sstate.selendpar = &*t->selection.end.par();
|
||||
sstate.selendpos = t->selection.end.pos();
|
||||
sstate.selendboundary = t->selection.end.boundary();
|
||||
sstate.selection = t->selection.set();
|
||||
@ -1397,11 +1397,11 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
|
||||
// inherit bufferparams/paragraphparams in a strange way. (Lgb)
|
||||
// FIXME: how old is this comment ? ...
|
||||
{
|
||||
Paragraph * par = lt->cursor.par();
|
||||
Spacing::Space cur_spacing = par->params().spacing().getSpace();
|
||||
ParagraphList::iterator pit = lt->cursor.par();
|
||||
Spacing::Space cur_spacing = pit->params().spacing().getSpace();
|
||||
float cur_value = 1.0;
|
||||
if (cur_spacing == Spacing::Other) {
|
||||
cur_value = par->params().spacing().getValue();
|
||||
cur_value = pit->params().spacing().getValue();
|
||||
}
|
||||
|
||||
istringstream istr(ev.argument.c_str());
|
||||
@ -1432,7 +1432,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
|
||||
<< ev.argument << endl;
|
||||
}
|
||||
if (cur_spacing != new_spacing || cur_value != new_value) {
|
||||
par->params().spacing(Spacing(new_spacing, new_value));
|
||||
pit->params().spacing(Spacing(new_spacing, new_value));
|
||||
updwhat = CURSOR_PAR;
|
||||
updflag = true;
|
||||
}
|
||||
@ -1938,7 +1938,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
||||
clear = true;
|
||||
}
|
||||
if (lt->selection.set()) {
|
||||
setUndo(bv, Undo::EDIT, lt->cursor.par(), lt->cursor.par()->next());
|
||||
setUndo(bv, Undo::EDIT, &*lt->cursor.par(), lt->cursor.par()->next());
|
||||
}
|
||||
if (selectall)
|
||||
selectAll(bv);
|
||||
@ -2106,7 +2106,7 @@ int InsetText::cx(BufferView * bv) const
|
||||
LyXText * llt = getLyXText(bv);
|
||||
int x = llt->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
|
||||
if (the_locking_inset) {
|
||||
LyXFont font = llt->getFont(bv->buffer(), llt->cursor.par(),
|
||||
LyXFont font = llt->getFont(bv->buffer(), &*llt->cursor.par(),
|
||||
llt->cursor.pos());
|
||||
if (font.isVisibleRightToLeft())
|
||||
x -= the_locking_inset->width(bv, font);
|
||||
@ -2121,7 +2121,7 @@ int InsetText::cix(BufferView * bv) const
|
||||
LyXText * llt = getLyXText(bv);
|
||||
int x = llt->cursor.ix() + top_x + TEXT_TO_INSET_OFFSET;
|
||||
if (the_locking_inset) {
|
||||
LyXFont font = llt->getFont(bv->buffer(), llt->cursor.par(),
|
||||
LyXFont font = llt->getFont(bv->buffer(), &*llt->cursor.par(),
|
||||
llt->cursor.pos());
|
||||
if (font.isVisibleRightToLeft())
|
||||
x -= the_locking_inset->width(bv, font);
|
||||
@ -2152,7 +2152,7 @@ pos_type InsetText::cpos(BufferView * bv) const
|
||||
|
||||
Paragraph * InsetText::cpar(BufferView * bv) const
|
||||
{
|
||||
return getLyXText(bv)->cursor.par();
|
||||
return &*getLyXText(bv)->cursor.par();
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,7 +462,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
|
||||
|
||||
string const getPossibleLabel(BufferView const & bv)
|
||||
{
|
||||
Paragraph * par = bv.getLyXText()->cursor.par();
|
||||
Paragraph * par = &*bv.getLyXText()->cursor.par();
|
||||
LyXLayout_ptr layout = par->layout();
|
||||
if (layout->latextype == LATEX_PARAGRAPH && par->previous()) {
|
||||
Paragraph * par2 = par->previous();
|
||||
|
@ -17,13 +17,13 @@ LyXCursor::LyXCursor()
|
||||
{}
|
||||
|
||||
|
||||
void LyXCursor::par(Paragraph * p)
|
||||
void LyXCursor::par(ParagraphList::iterator pit)
|
||||
{
|
||||
par_ = p;
|
||||
par_ = pit;
|
||||
}
|
||||
|
||||
|
||||
Paragraph * LyXCursor::par() const
|
||||
ParagraphList::iterator LyXCursor::par() const
|
||||
{
|
||||
return par_;
|
||||
}
|
||||
|
@ -11,10 +11,9 @@
|
||||
#define LYXCURSOR_H
|
||||
|
||||
#include "RowList.h"
|
||||
#include "ParagraphList.h"
|
||||
#include "support/types.h"
|
||||
|
||||
class Paragraph;
|
||||
|
||||
/**
|
||||
* The cursor class describes the position of a cursor within a document.
|
||||
* Several cursors exist within LyX; for example, when locking an inset,
|
||||
@ -26,9 +25,9 @@ class LyXCursor {
|
||||
public:
|
||||
LyXCursor();
|
||||
/// set the paragraph that contains this cursor
|
||||
void par(Paragraph * p);
|
||||
void par(ParagraphList::iterator pit);
|
||||
/// return the paragraph this cursor is in
|
||||
Paragraph * par() const;
|
||||
ParagraphList::iterator par() const;
|
||||
/// set the position within the paragraph
|
||||
void pos(lyx::pos_type p);
|
||||
/// return the position within the paragraph
|
||||
@ -96,7 +95,7 @@ public:
|
||||
RowList::iterator irow() const;
|
||||
private:
|
||||
/// The paragraph the cursor is in.
|
||||
Paragraph * par_;
|
||||
ParagraphList::iterator par_;
|
||||
/// The position inside the paragraph
|
||||
lyx::pos_type pos_;
|
||||
/**
|
||||
|
@ -232,7 +232,7 @@ bool IsStringInText(Paragraph * par, pos_type pos,
|
||||
SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str,
|
||||
bool const & cs, bool const & mw)
|
||||
{
|
||||
Paragraph * par = text->cursor.par();
|
||||
Paragraph * par = &*text->cursor.par();
|
||||
pos_type pos = text->cursor.pos();
|
||||
UpdatableInset * inset;
|
||||
|
||||
@ -265,7 +265,7 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
|
||||
string const & str,
|
||||
bool const & cs, bool const & mw)
|
||||
{
|
||||
Paragraph * par = text->cursor.par();
|
||||
Paragraph * par = &*text->cursor.par();
|
||||
pos_type pos = text->cursor.pos();
|
||||
|
||||
do {
|
||||
@ -297,7 +297,7 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
|
||||
|
||||
SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length)
|
||||
{
|
||||
Paragraph * par = text->cursor.par();
|
||||
Paragraph * par = &*text->cursor.par();
|
||||
pos_type pos = text->cursor.pos();
|
||||
Paragraph * prev_par = par;
|
||||
UpdatableInset * inset;
|
||||
|
@ -330,16 +330,16 @@ public:
|
||||
///
|
||||
void selectSelectedWord();
|
||||
/// returns true if par was empty and was removed
|
||||
bool setCursor(Paragraph * par,
|
||||
bool setCursor(ParagraphList::iterator pit,
|
||||
lyx::pos_type pos,
|
||||
bool setfont = true,
|
||||
bool boundary = false);
|
||||
///
|
||||
void setCursor(LyXCursor &, Paragraph * par,
|
||||
void setCursor(LyXCursor &, ParagraphList::iterator pit,
|
||||
lyx::pos_type pos,
|
||||
bool boundary = false);
|
||||
///
|
||||
void setCursorIntern(Paragraph * par,
|
||||
void setCursorIntern(ParagraphList::iterator pit,
|
||||
lyx::pos_type pos,
|
||||
bool setfont = true,
|
||||
bool boundary = false);
|
||||
|
89
src/text.C
89
src/text.C
@ -787,7 +787,6 @@ LyXText::rowBreakPoint(Row const & row) const
|
||||
|
||||
pos_type i = pos;
|
||||
for (; i < last; ++i) {
|
||||
|
||||
if (pit->isNewline(i)) {
|
||||
point = i;
|
||||
break;
|
||||
@ -1430,7 +1429,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
||||
&& !layout->keepempty)
|
||||
return;
|
||||
|
||||
setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next());
|
||||
setUndo(bv(), Undo::FINISH, &*cursor.par(), &*boost::next(cursor.par()));
|
||||
|
||||
// Always break behind a space
|
||||
//
|
||||
@ -1532,7 +1531,7 @@ void LyXText::redoParagraph()
|
||||
// same Paragraph one to the right and make a rebreak
|
||||
void LyXText::insertChar(char c)
|
||||
{
|
||||
setUndo(bv(), Undo::INSERT, cursor.par(), cursor.par()->next());
|
||||
setUndo(bv(), Undo::INSERT, &*cursor.par(), &*boost::next(cursor.par()));
|
||||
|
||||
// When the free-spacing option is set for the current layout,
|
||||
// disable the double-space checking
|
||||
@ -1551,10 +1550,10 @@ void LyXText::insertChar(char c)
|
||||
cursor.pos() >= 1 &&
|
||||
cursor.pos() < cursor.par()->size() &&
|
||||
getFont(bv()->buffer(),
|
||||
cursor.par(),
|
||||
&*cursor.par(),
|
||||
cursor.pos()).number() == LyXFont::ON &&
|
||||
getFont(bv()->buffer(),
|
||||
cursor.par(),
|
||||
&*cursor.par(),
|
||||
cursor.pos() - 1).number() == LyXFont::ON)
|
||||
)
|
||||
number(bv()); // Set current_font.number to OFF
|
||||
@ -1570,16 +1569,16 @@ void LyXText::insertChar(char c)
|
||||
cursor.par()->isNewline(cursor.pos() - 2))
|
||||
) {
|
||||
setCharFont(bv()->buffer(),
|
||||
cursor.par(),
|
||||
&*cursor.par(),
|
||||
cursor.pos() - 1,
|
||||
current_font);
|
||||
} else if (contains(number_seperators, c) &&
|
||||
cursor.pos() >= 2 &&
|
||||
getFont(bv()->buffer(),
|
||||
cursor.par(),
|
||||
&*cursor.par(),
|
||||
cursor.pos() - 2).number() == LyXFont::ON) {
|
||||
setCharFont(bv()->buffer(),
|
||||
cursor.par(),
|
||||
&*cursor.par(),
|
||||
cursor.pos() - 1,
|
||||
current_font);
|
||||
}
|
||||
@ -1648,7 +1647,7 @@ void LyXText::insertChar(char c)
|
||||
// Here case LyXText::InsertInset already insertet the character
|
||||
cursor.par()->insertChar(cursor.pos(), c);
|
||||
}
|
||||
setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
|
||||
setCharFont(bv()->buffer(), &*cursor.par(), cursor.pos(), rawtmpfont);
|
||||
|
||||
if (!jumped_over_space) {
|
||||
// refresh the positions
|
||||
@ -1733,7 +1732,7 @@ void LyXText::insertChar(char c)
|
||||
|
||||
setCursor(cursor.par(), cursor.pos() + 1, false,
|
||||
cursor.boundary());
|
||||
if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos())
|
||||
if (isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos())
|
||||
!= cursor.boundary())
|
||||
setCursor(cursor.par(), cursor.pos(), false,
|
||||
!cursor.boundary());
|
||||
@ -2083,7 +2082,7 @@ void LyXText::acceptChange()
|
||||
if (selection.start.par() == selection.end.par()) {
|
||||
LyXCursor & startc = selection.start;
|
||||
LyXCursor & endc = selection.end;
|
||||
setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next());
|
||||
setUndo(bv(), Undo::INSERT, &*startc.par(), &*boost::next(startc.par()));
|
||||
startc.par()->acceptChange(startc.pos(), endc.pos());
|
||||
finishUndo();
|
||||
clearSelection();
|
||||
@ -2104,7 +2103,8 @@ void LyXText::rejectChange()
|
||||
if (selection.start.par() == selection.end.par()) {
|
||||
LyXCursor & startc = selection.start;
|
||||
LyXCursor & endc = selection.end;
|
||||
setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next());
|
||||
setUndo(bv(), Undo::INSERT, &*startc.par(),
|
||||
&*boost::next(startc.par()));
|
||||
startc.par()->rejectChange(startc.pos(), endc.pos());
|
||||
finishUndo();
|
||||
clearSelection();
|
||||
@ -2136,7 +2136,7 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
||||
} else
|
||||
cursor.pos(cursor.pos() + 1);
|
||||
}
|
||||
Paragraph * tmppar = cursor.par();
|
||||
ParagraphList::iterator tmppit = cursor.par();
|
||||
|
||||
// If this is not the very first word, skip rest of
|
||||
// current word because we are probably in the middle
|
||||
@ -2148,23 +2148,23 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
||||
}
|
||||
|
||||
// Now, skip until we have real text (will jump paragraphs)
|
||||
while (1) {
|
||||
Paragraph * cpar(cursor.par());
|
||||
while (true) {
|
||||
ParagraphList::iterator cpit = cursor.par();
|
||||
pos_type const cpos(cursor.pos());
|
||||
|
||||
if (cpos == cpar->size()) {
|
||||
if (cpar->next()) {
|
||||
cursor.par(cpar->next());
|
||||
if (cpos == cpit->size()) {
|
||||
if (boost::next(cpit) != ownerParagraphs().end()) {
|
||||
cursor.par(boost::next(cpit));
|
||||
cursor.pos(0);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
bool const is_bad_inset(cpar->isInset(cpos)
|
||||
&& !cpar->getInset(cpos)->allowSpellcheck());
|
||||
bool const is_bad_inset(cpit->isInset(cpos)
|
||||
&& !cpit->getInset(cpos)->allowSpellcheck());
|
||||
|
||||
if (cpar->isLetter(cpos) && !isDeletedText(*cpar, cpos)
|
||||
if (cpit->isLetter(cpos) && !isDeletedText(*cpit, cpos)
|
||||
&& !is_bad_inset)
|
||||
break;
|
||||
|
||||
@ -2182,7 +2182,7 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
||||
}
|
||||
|
||||
// Update the value if we changed paragraphs
|
||||
if (cursor.par() != tmppar) {
|
||||
if (cursor.par() != tmppit) {
|
||||
setCursor(cursor.par(), cursor.pos());
|
||||
value = float(cursor.y())/float(height);
|
||||
}
|
||||
@ -2191,7 +2191,7 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
||||
selection.cursor = cursor;
|
||||
|
||||
string lang_code(
|
||||
getFont(bv()->buffer(), cursor.par(), cursor.pos())
|
||||
getFont(bv()->buffer(), &*cursor.par(), cursor.pos())
|
||||
.language()->code());
|
||||
// and find the end of the word (insets like optional hyphens
|
||||
// and ligature break are part of a word)
|
||||
@ -2320,18 +2320,19 @@ void LyXText::changeCase(LyXText::TextCase action)
|
||||
|
||||
lyx::Assert(from <= to);
|
||||
|
||||
setUndo(bv(), Undo::FINISH, from.par(), to.par()->next());
|
||||
setUndo(bv(), Undo::FINISH, &*from.par(), &*boost::next(to.par()));
|
||||
|
||||
pos_type pos = from.pos();
|
||||
Paragraph * par = from.par();
|
||||
ParagraphList::iterator pit = from.par();
|
||||
|
||||
while (par && (pos != to.pos() || par != to.par())) {
|
||||
if (pos == par->size()) {
|
||||
par = par->next();
|
||||
while (pit != ownerParagraphs().end() &&
|
||||
(pos != to.pos() || pit != to.par())) {
|
||||
if (pos == pit->size()) {
|
||||
++pit;
|
||||
pos = 0;
|
||||
continue;
|
||||
}
|
||||
unsigned char c = par->getChar(pos);
|
||||
unsigned char c = pit->getChar(pos);
|
||||
if (!IsInsetChar(c)) {
|
||||
switch (action) {
|
||||
case text_lowercase:
|
||||
@ -2347,8 +2348,8 @@ void LyXText::changeCase(LyXText::TextCase action)
|
||||
}
|
||||
}
|
||||
#warning changes
|
||||
par->setChar(pos, c);
|
||||
checkParagraph(par, pos);
|
||||
pit->setChar(pos, c);
|
||||
checkParagraph(&*pit, pos);
|
||||
|
||||
++pos;
|
||||
}
|
||||
@ -2389,7 +2390,7 @@ void LyXText::Delete()
|
||||
// to make sure undo gets the right cursor position
|
||||
cursor = old_cursor;
|
||||
setUndo(bv(), Undo::DELETE,
|
||||
cursor.par(), cursor.par()->next());
|
||||
&*cursor.par(), &*boost::next(cursor.par()));
|
||||
cursor = tmpcursor;
|
||||
backspace();
|
||||
}
|
||||
@ -2450,17 +2451,17 @@ void LyXText::backspace()
|
||||
cursor.par()->previous(), cursor.par()->next());
|
||||
}
|
||||
|
||||
Paragraph * tmppar = cursor.par();
|
||||
ParagraphList::iterator tmppit = cursor.par();
|
||||
RowList::iterator tmprow = cursor.row();
|
||||
|
||||
// We used to do cursorLeftIntern() here, but it is
|
||||
// not a good idea since it triggers the auto-delete
|
||||
// mechanism. So we do a cursorLeftIntern()-lite,
|
||||
// without the dreaded mechanism. (JMarc)
|
||||
if (cursor.par()->previous()) {
|
||||
if (cursor.par() != ownerParagraphs().begin()) {
|
||||
// steps into the above paragraph.
|
||||
setCursorIntern(cursor.par()->previous(),
|
||||
cursor.par()->previous()->size(),
|
||||
setCursorIntern(boost::prior(cursor.par()),
|
||||
boost::prior(cursor.par())->size(),
|
||||
false);
|
||||
}
|
||||
|
||||
@ -2476,10 +2477,10 @@ void LyXText::backspace()
|
||||
LyXTextClass const & tclass =
|
||||
bv()->buffer()->params.getLyXTextClass();
|
||||
|
||||
if (cursor.par() != tmppar
|
||||
&& (cursor.par()->layout() == tmppar->layout()
|
||||
|| tmppar->layout() == tclass.defaultLayout())
|
||||
&& cursor.par()->getAlign() == tmppar->getAlign()) {
|
||||
if (cursor.par() != tmppit
|
||||
&& (cursor.par()->layout() == tmppit->layout()
|
||||
|| tmppit->layout() == tclass.defaultLayout())
|
||||
&& cursor.par()->getAlign() == tmppit->getAlign()) {
|
||||
removeParagraph(tmprow);
|
||||
removeRow(tmprow);
|
||||
mergeParagraph(bv()->buffer()->params, bv()->buffer()->paragraphs, cursor.par());
|
||||
@ -2514,7 +2515,7 @@ void LyXText::backspace()
|
||||
// this is the code for a normal backspace, not pasting
|
||||
// any paragraphs
|
||||
setUndo(bv(), Undo::DELETE,
|
||||
cursor.par(), cursor.par()->next());
|
||||
&*cursor.par(), &*boost::next(cursor.par()));
|
||||
// We used to do cursorLeftIntern() here, but it is
|
||||
// not a good idea since it triggers the auto-delete
|
||||
// mechanism. So we do a cursorLeftIntern()-lite,
|
||||
@ -2541,7 +2542,7 @@ void LyXText::backspace()
|
||||
if (cursor.pos() < lastPos(*this, row) ||
|
||||
!cursor.par()->isLineSeparator(cursor.pos())) {
|
||||
row->fill(row->fill() + singleWidth(
|
||||
cursor.par(),
|
||||
&*cursor.par(),
|
||||
cursor.pos()));
|
||||
}
|
||||
|
||||
@ -2562,7 +2563,7 @@ void LyXText::backspace()
|
||||
if (cursor.pos() < cursor.par()->size()
|
||||
&& !cursor.par()->isSeparator(cursor.pos())) {
|
||||
cursor.par()->insertChar(cursor.pos(), ' ');
|
||||
setCharFont(bv()->buffer(), cursor.par(),
|
||||
setCharFont(bv()->buffer(), &*cursor.par(),
|
||||
cursor.pos(), current_font);
|
||||
// refresh the positions
|
||||
tmprow = row;
|
||||
@ -2689,7 +2690,7 @@ void LyXText::backspace()
|
||||
// current_font = rawtmpfont;
|
||||
// real_current_font = realtmpfont;
|
||||
|
||||
if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos())
|
||||
if (isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos())
|
||||
!= cursor.boundary())
|
||||
setCursor(cursor.par(), cursor.pos(), false,
|
||||
!cursor.boundary());
|
||||
|
157
src/text2.C
157
src/text2.C
@ -394,32 +394,32 @@ Paragraph * LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
||||
endpar = endpar->next(); // because of parindents etc.
|
||||
}
|
||||
|
||||
setUndo(bv(), Undo::EDIT, sstart_cur.par(), undoendpar);
|
||||
setUndo(bv(), Undo::EDIT, &*sstart_cur.par(), undoendpar);
|
||||
|
||||
// ok we have a selection. This is always between sstart_cur
|
||||
// and sel_end cursor
|
||||
cur = sstart_cur;
|
||||
Paragraph * par = sstart_cur.par();
|
||||
Paragraph * epar = send_cur.par()->next();
|
||||
ParagraphList::iterator pit = sstart_cur.par();
|
||||
ParagraphList::iterator epit = boost::next(send_cur.par());
|
||||
|
||||
LyXLayout_ptr const & lyxlayout =
|
||||
bv()->buffer()->params.getLyXTextClass()[layout];
|
||||
|
||||
do {
|
||||
par->applyLayout(lyxlayout);
|
||||
makeFontEntriesLayoutSpecific(*bv()->buffer(), *par);
|
||||
Paragraph * fppar = par;
|
||||
fppar->params().spaceTop(lyxlayout->fill_top ?
|
||||
pit->applyLayout(lyxlayout);
|
||||
makeFontEntriesLayoutSpecific(*bv()->buffer(), *pit);
|
||||
ParagraphList::iterator fppit = pit;
|
||||
fppit->params().spaceTop(lyxlayout->fill_top ?
|
||||
VSpace(VSpace::VFILL)
|
||||
: VSpace(VSpace::NONE));
|
||||
fppar->params().spaceBottom(lyxlayout->fill_bottom ?
|
||||
fppit->params().spaceBottom(lyxlayout->fill_bottom ?
|
||||
VSpace(VSpace::VFILL)
|
||||
: VSpace(VSpace::NONE));
|
||||
if (lyxlayout->margintype == MARGIN_MANUAL)
|
||||
par->setLabelWidthString(lyxlayout->labelstring());
|
||||
cur.par(par);
|
||||
par = par->next();
|
||||
} while (par != epar);
|
||||
pit->setLabelWidthString(lyxlayout->labelstring());
|
||||
cur.par(pit);
|
||||
++pit;
|
||||
} while (pit != epit);
|
||||
|
||||
return endpar;
|
||||
}
|
||||
@ -465,8 +465,8 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||
start = pit;
|
||||
}
|
||||
|
||||
ParagraphList::iterator pastend = end;
|
||||
++pastend;
|
||||
ParagraphList::iterator pastend = boost::next(end);
|
||||
|
||||
if (!test_only)
|
||||
setUndo(bv(), Undo::EDIT, &(*start), &(*pastend));
|
||||
|
||||
@ -474,8 +474,9 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||
|
||||
int prev_after_depth = 0;
|
||||
#warning parlist ... could be nicer ?
|
||||
if (start != ownerParagraphs().begin())
|
||||
if (start != ownerParagraphs().begin()) {
|
||||
prev_after_depth = boost::prior(start)->getMaxDepthAfter();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
int const depth = pit->params().depth();
|
||||
@ -483,9 +484,11 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||
if (depth < prev_after_depth
|
||||
&& pit->layout()->labeltype != LABEL_BIBLIO) {
|
||||
changed = true;
|
||||
if (!test_only)
|
||||
if (!test_only) {
|
||||
pit->params().depth(depth + 1);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (depth) {
|
||||
changed = true;
|
||||
if (!test_only)
|
||||
@ -494,8 +497,9 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||
|
||||
prev_after_depth = pit->getMaxDepthAfter();
|
||||
|
||||
if (pit == end)
|
||||
if (pit == end) {
|
||||
break;
|
||||
}
|
||||
|
||||
++pit;
|
||||
}
|
||||
@ -506,6 +510,8 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||
// Wow, redoParagraphs is stupid.
|
||||
LyXCursor tmpcursor;
|
||||
setCursor(tmpcursor, &(*start), 0);
|
||||
|
||||
//redoParagraphs(tmpcursor, &(*pastend));
|
||||
redoParagraphs(tmpcursor, &(*pastend));
|
||||
|
||||
// We need to actually move the text->cursor. I don't
|
||||
@ -540,10 +546,10 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
LyXFont layoutfont;
|
||||
if (cursor.pos() < cursor.par()->beginningOfBody()) {
|
||||
layoutfont = getLabelFont(bv()->buffer(),
|
||||
cursor.par());
|
||||
&*cursor.par());
|
||||
} else {
|
||||
layoutfont = getLayoutFont(bv()->buffer(),
|
||||
cursor.par());
|
||||
&*cursor.par());
|
||||
}
|
||||
// Update current font
|
||||
real_current_font.update(font,
|
||||
@ -565,7 +571,7 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
// and sel_end cursor
|
||||
|
||||
setUndo(bv(), Undo::EDIT,
|
||||
selection.start.par(), selection.end.par()->next());
|
||||
&*selection.start.par(), &*boost::next(selection.end.par()));
|
||||
freezeUndo();
|
||||
cursor = selection.start;
|
||||
while (cursor.par() != selection.end.par() ||
|
||||
@ -573,7 +579,7 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
{
|
||||
if (cursor.pos() < cursor.par()->size()) {
|
||||
// an open footnote should behave like a closed one
|
||||
setCharFont(cursor.par(), cursor.pos(),
|
||||
setCharFont(&*cursor.par(), cursor.pos(),
|
||||
font, toggleall);
|
||||
cursor.pos(cursor.pos() + 1);
|
||||
} else {
|
||||
@ -642,6 +648,7 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
||||
Paragraph const * ep)
|
||||
{
|
||||
RowList::iterator tmprit = cur.row();
|
||||
ParagraphList::iterator begpit = cur.row()->par();
|
||||
ParagraphList::iterator endpit(const_cast<Paragraph*>(ep));
|
||||
int y = cur.y() - tmprit->baseline();
|
||||
|
||||
@ -711,6 +718,7 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
||||
}
|
||||
if (tmprit != rows().end())
|
||||
setHeightOfRow(tmprit);
|
||||
|
||||
updateCounters();
|
||||
}
|
||||
|
||||
@ -799,32 +807,34 @@ string const LyXText::selectionAsString(Buffer const * buffer,
|
||||
if (!selection.set()) return string();
|
||||
|
||||
// should be const ...
|
||||
Paragraph * startpar(selection.start.par());
|
||||
Paragraph * endpar(selection.end.par());
|
||||
ParagraphList::iterator startpit = selection.start.par();
|
||||
ParagraphList::iterator endpit = selection.end.par();
|
||||
pos_type const startpos(selection.start.pos());
|
||||
pos_type const endpos(selection.end.pos());
|
||||
|
||||
if (startpar == endpar) {
|
||||
return startpar->asString(buffer, startpos, endpos, label);
|
||||
if (startpit == endpit) {
|
||||
return startpit->asString(buffer, startpos, endpos, label);
|
||||
}
|
||||
|
||||
string result;
|
||||
|
||||
// First paragraph in selection
|
||||
result += startpar->asString(buffer, startpos, startpar->size(), label) + "\n\n";
|
||||
result += startpit->asString(buffer, startpos, startpit->size(), label) + "\n\n";
|
||||
|
||||
// The paragraphs in between (if any)
|
||||
#warning FIXME Why isnt ParagraphList::iterator used here?
|
||||
// as loop variable.
|
||||
LyXCursor tmpcur(selection.start);
|
||||
tmpcur.par(tmpcur.par()->next());
|
||||
while (tmpcur.par() != endpar) {
|
||||
while (tmpcur.par() != endpit) {
|
||||
result += tmpcur.par()->asString(buffer, 0,
|
||||
tmpcur.par()->size(),
|
||||
label) + "\n\n";
|
||||
tmpcur.par(tmpcur.par()->next());
|
||||
tmpcur.par(boost::next(tmpcur.par()));
|
||||
}
|
||||
|
||||
// Last paragraph in selection
|
||||
result += endpar->asString(buffer, 0, endpos, label);
|
||||
result += endpit->asString(buffer, 0, endpos, label);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -986,13 +996,13 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
||||
endpar = endpar->next();
|
||||
}
|
||||
|
||||
setUndo(bv(), Undo::EDIT, selection.start.par(), undoendpar);
|
||||
setUndo(bv(), Undo::EDIT, &*selection.start.par(), undoendpar);
|
||||
|
||||
|
||||
Paragraph * tmppar = selection.end.par();
|
||||
ParagraphList::iterator tmppit = selection.end.par();
|
||||
|
||||
while (tmppar != selection.start.par()->previous()) {
|
||||
setCursor(tmppar, 0);
|
||||
while (tmppit != boost::prior(selection.start.par())) {
|
||||
setCursor(tmppit, 0);
|
||||
postPaint(cursor.y() - cursor.row()->baseline());
|
||||
cursor.par()->params().lineTop(line_top);
|
||||
cursor.par()->params().lineBottom(line_bottom);
|
||||
@ -1014,7 +1024,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
||||
}
|
||||
cursor.par()->setLabelWidthString(labelwidthstring);
|
||||
cursor.par()->params().noindent(noindent);
|
||||
tmppar = cursor.par()->previous();
|
||||
tmppit = boost::prior(cursor.par());
|
||||
}
|
||||
|
||||
redoParagraphs(selection.start, endpar);
|
||||
@ -1267,7 +1277,8 @@ void LyXText::insertInset(Inset * inset)
|
||||
{
|
||||
if (!cursor.par()->insetAllowed(inset->lyxCode()))
|
||||
return;
|
||||
setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next());
|
||||
setUndo(bv(), Undo::FINISH, &*cursor.par(),
|
||||
&*boost::next(cursor.par()));
|
||||
freezeUndo();
|
||||
cursor.par()->insertInset(cursor.pos(), inset);
|
||||
// Just to rebreak and refresh correctly.
|
||||
@ -1332,23 +1343,23 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
||||
}
|
||||
|
||||
setUndo(bv(), Undo::DELETE,
|
||||
selection.start.par(), undoendpar);
|
||||
&*selection.start.par(), undoendpar);
|
||||
|
||||
// there are two cases: cut only within one paragraph or
|
||||
// more than one paragraph
|
||||
if (selection.start.par() == selection.end.par()) {
|
||||
// only within one paragraph
|
||||
endpar = selection.end.par();
|
||||
endpar = &*selection.end.par();
|
||||
int pos = selection.end.pos();
|
||||
CutAndPaste::cutSelection(selection.start.par(), &endpar,
|
||||
CutAndPaste::cutSelection(&*selection.start.par(), &endpar,
|
||||
selection.start.pos(), pos,
|
||||
bv()->buffer()->params.textclass,
|
||||
doclear, realcut);
|
||||
selection.end.pos(pos);
|
||||
} else {
|
||||
endpar = selection.end.par();
|
||||
endpar = &*selection.end.par();
|
||||
int pos = selection.end.pos();
|
||||
CutAndPaste::cutSelection(selection.start.par(), &endpar,
|
||||
CutAndPaste::cutSelection(&*selection.start.par(), &endpar,
|
||||
selection.start.pos(), pos,
|
||||
bv()->buffer()->params.textclass,
|
||||
doclear, realcut);
|
||||
@ -1398,7 +1409,8 @@ void LyXText::copySelection()
|
||||
|| selection.start.pos() < selection.end.pos()))
|
||||
selection.start.pos(selection.start.pos() + 1);
|
||||
|
||||
CutAndPaste::copySelection(selection.start.par(), selection.end.par(),
|
||||
CutAndPaste::copySelection(&*selection.start.par(),
|
||||
&*selection.end.par(),
|
||||
selection.start.pos(), selection.end.pos(),
|
||||
bv()->buffer()->params.textclass);
|
||||
}
|
||||
@ -1411,12 +1423,13 @@ void LyXText::pasteSelection()
|
||||
return;
|
||||
|
||||
setUndo(bv(), Undo::INSERT,
|
||||
cursor.par(), cursor.par()->next());
|
||||
&*cursor.par(), &*boost::next(cursor.par()));
|
||||
|
||||
Paragraph * endpar;
|
||||
Paragraph * actpar = cursor.par();
|
||||
ParagraphList::iterator actpit = cursor.par();
|
||||
int pos = cursor.pos();
|
||||
|
||||
Paragraph * actpar = &*actpit;
|
||||
CutAndPaste::pasteSelection(&actpar, &endpar, pos,
|
||||
bv()->buffer()->params.textclass);
|
||||
|
||||
@ -1426,7 +1439,7 @@ void LyXText::pasteSelection()
|
||||
clearSelection();
|
||||
|
||||
selection.cursor = cursor;
|
||||
setCursor(actpar, pos);
|
||||
setCursor(actpit, pos);
|
||||
setSelection();
|
||||
updateCounters();
|
||||
}
|
||||
@ -1477,21 +1490,22 @@ void LyXText::replaceSelectionWithString(string const & str)
|
||||
// needed to insert the selection
|
||||
void LyXText::insertStringAsLines(string const & str)
|
||||
{
|
||||
Paragraph * par = cursor.par();
|
||||
ParagraphList::iterator pit = cursor.par();
|
||||
pos_type pos = cursor.pos();
|
||||
Paragraph * endpar = cursor.par()->next();
|
||||
ParagraphList::iterator endpit = boost::next(cursor.par());
|
||||
|
||||
setCursorParUndo(bv());
|
||||
|
||||
// only to be sure, should not be neccessary
|
||||
clearSelection();
|
||||
|
||||
Paragraph * par = &*pit;
|
||||
bv()->buffer()->insertStringAsLines(par, pos, current_font, str);
|
||||
|
||||
redoParagraphs(cursor, endpar);
|
||||
redoParagraphs(cursor, &*endpit);
|
||||
setCursor(cursor.par(), cursor.pos());
|
||||
selection.cursor = cursor;
|
||||
setCursor(par, pos);
|
||||
setCursor(pit, pos);
|
||||
setSelection();
|
||||
}
|
||||
|
||||
@ -1605,7 +1619,7 @@ bool LyXText::updateInset(Inset * inset)
|
||||
// first check the current paragraph
|
||||
int pos = cursor.par()->getPositionOfInset(inset);
|
||||
if (pos != -1) {
|
||||
checkParagraph(cursor.par(), pos);
|
||||
checkParagraph(&*cursor.par(), pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1627,28 +1641,28 @@ bool LyXText::updateInset(Inset * inset)
|
||||
}
|
||||
|
||||
|
||||
bool LyXText::setCursor(Paragraph * par,
|
||||
bool LyXText::setCursor(ParagraphList::iterator pit,
|
||||
pos_type pos,
|
||||
bool setfont, bool boundary)
|
||||
{
|
||||
LyXCursor old_cursor = cursor;
|
||||
setCursorIntern(par, pos, setfont, boundary);
|
||||
setCursorIntern(pit, pos, setfont, boundary);
|
||||
return deleteEmptyParagraphMechanism(old_cursor);
|
||||
}
|
||||
|
||||
|
||||
void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
|
||||
void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
||||
pos_type pos, bool boundary)
|
||||
{
|
||||
lyx::Assert(par);
|
||||
lyx::Assert(pit != ownerParagraphs().end());
|
||||
|
||||
cur.par(par);
|
||||
cur.par(pit);
|
||||
cur.pos(pos);
|
||||
cur.boundary(boundary);
|
||||
|
||||
// get the cursor y position in text
|
||||
int y = 0;
|
||||
RowList::iterator row = getRow(par, pos, y);
|
||||
RowList::iterator row = getRow(&*pit, pos, y);
|
||||
RowList::iterator beg = rows().begin();
|
||||
|
||||
RowList::iterator old_row = row;
|
||||
@ -1660,9 +1674,9 @@ void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
|
||||
Inset * ins;
|
||||
if (row != beg && pos &&
|
||||
boost::prior(row)->par() == row->par() &&
|
||||
pos < par->size() &&
|
||||
par->getChar(pos) == Paragraph::META_INSET &&
|
||||
(ins = par->getInset(pos)) && (ins->needFullRow() || ins->display()))
|
||||
pos < pit->size() &&
|
||||
pit->getChar(pos) == Paragraph::META_INSET &&
|
||||
(ins = pit->getInset(pos)) && (ins->needFullRow() || ins->display()))
|
||||
{
|
||||
--row;
|
||||
y -= row->height();
|
||||
@ -1677,7 +1691,7 @@ void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
|
||||
pos_type last = lastPrintablePos(*this, old_row);
|
||||
|
||||
// None of these should happen, but we're scaredy-cats
|
||||
if (pos > par->size()) {
|
||||
if (pos > pit->size()) {
|
||||
lyxerr << "dont like 1 please report" << endl;
|
||||
pos = 0;
|
||||
cur.pos(0);
|
||||
@ -1777,10 +1791,10 @@ float LyXText::getCursorX(RowList::iterator rit,
|
||||
}
|
||||
|
||||
|
||||
void LyXText::setCursorIntern(Paragraph * par,
|
||||
void LyXText::setCursorIntern(ParagraphList::iterator pit,
|
||||
pos_type pos, bool setfont, bool boundary)
|
||||
{
|
||||
InsetText * it = static_cast<InsetText *>(par->inInset());
|
||||
InsetText * it = static_cast<InsetText *>(pit->inInset());
|
||||
if (it) {
|
||||
if (it != inset_owner) {
|
||||
lyxerr[Debug::INSETS] << "InsetText is " << it
|
||||
@ -1806,7 +1820,7 @@ void LyXText::setCursorIntern(Paragraph * par,
|
||||
}
|
||||
}
|
||||
|
||||
setCursor(cursor, par, pos, boundary);
|
||||
setCursor(cursor, pit, pos, boundary);
|
||||
if (setfont)
|
||||
setCurrentFont();
|
||||
}
|
||||
@ -1834,10 +1848,10 @@ void LyXText::setCurrentFont()
|
||||
|
||||
current_font =
|
||||
cursor.par()->getFontSettings(bv()->buffer()->params, pos);
|
||||
real_current_font = getFont(bv()->buffer(), cursor.par(), pos);
|
||||
real_current_font = getFont(bv()->buffer(), &*cursor.par(), pos);
|
||||
|
||||
if (cursor.pos() == cursor.par()->size() &&
|
||||
isBoundary(bv()->buffer(), cursor.par(), cursor.pos()) &&
|
||||
isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos()) &&
|
||||
!cursor.boundary()) {
|
||||
Language const * lang =
|
||||
cursor.par()->getParLanguage(bv()->buffer()->params);
|
||||
@ -2031,7 +2045,7 @@ void LyXText::cursorLeft(bool internal)
|
||||
bool boundary = cursor.boundary();
|
||||
setCursor(cursor.par(), cursor.pos() - 1, true, false);
|
||||
if (!internal && !boundary &&
|
||||
isBoundary(bv()->buffer(), cursor.par(), cursor.pos() + 1))
|
||||
isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos() + 1))
|
||||
setCursor(cursor.par(), cursor.pos() + 1, true, true);
|
||||
} else if (cursor.par()->previous()) { // steps into the above paragraph.
|
||||
Paragraph * par = cursor.par()->previous();
|
||||
@ -2048,7 +2062,7 @@ void LyXText::cursorRight(bool internal)
|
||||
else if (cursor.pos() < cursor.par()->size()) {
|
||||
setCursor(cursor.par(), cursor.pos() + 1, true, false);
|
||||
if (!internal &&
|
||||
isBoundary(bv()->buffer(), cursor.par(), cursor.pos()))
|
||||
isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos()))
|
||||
setCursor(cursor.par(), cursor.pos(), true, true);
|
||||
} else if (cursor.par()->next())
|
||||
setCursor(cursor.par()->next(), 0);
|
||||
@ -2253,7 +2267,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
endpar = endpar->next();
|
||||
}
|
||||
}
|
||||
setUndo(bv(), Undo::DELETE, old_cursor.par(), endpar);
|
||||
setUndo(bv(), Undo::DELETE, &*old_cursor.par(), endpar);
|
||||
cursor = tmpcursor;
|
||||
|
||||
// delete old row
|
||||
@ -2261,8 +2275,9 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
if (ownerParagraphs().begin() == old_cursor.par()) {
|
||||
ownerParagraph(&*boost::next(ownerParagraphs().begin()));
|
||||
}
|
||||
#warning FIXME Do the proper ParagraphList operation here (Lgb)
|
||||
// delete old par
|
||||
delete old_cursor.par();
|
||||
delete &*old_cursor.par();
|
||||
|
||||
/* Breakagain the next par. Needed because of
|
||||
* the parindent that can occur or dissappear.
|
||||
@ -2286,7 +2301,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
endpar = endpar->next();
|
||||
}
|
||||
}
|
||||
setUndo(bv(), Undo::DELETE, old_cursor.par(), endpar);
|
||||
setUndo(bv(), Undo::DELETE, &*old_cursor.par(), endpar);
|
||||
cursor = tmpcursor;
|
||||
|
||||
// delete old row
|
||||
@ -2295,8 +2310,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
if (ownerParagraphs().begin() == old_cursor.par()) {
|
||||
ownerParagraph(&*boost::next(ownerParagraphs().begin()));
|
||||
}
|
||||
|
||||
delete old_cursor.par();
|
||||
#warning FIXME Do the proper ParagraphList operations here. (Lgb)
|
||||
delete &*old_cursor.par();
|
||||
|
||||
/* Breakagain the next par. Needed because of
|
||||
the parindent that can occur or dissappear.
|
||||
|
44
src/text3.C
44
src/text3.C
@ -176,11 +176,11 @@ bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
|
||||
if (res.pos() < res.par()->size() - 1) {
|
||||
res.pos(res.pos() + 1);
|
||||
} else {
|
||||
res.par(res.par()->next());
|
||||
res.par(boost::next(res.par()));
|
||||
res.pos(0);
|
||||
}
|
||||
|
||||
} while (res.par() &&
|
||||
} while (res.par() != ownerParagraphs().end()&&
|
||||
!(res.par()->isInset(res.pos())
|
||||
&& (inset = res.par()->getInset(res.pos())) != 0
|
||||
&& find(codes.begin(), codes.end(), inset->lyxCode())
|
||||
@ -190,7 +190,7 @@ bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
|
||||
res.par()->getInset(res.pos()))->getContents()
|
||||
== contents)));
|
||||
|
||||
if (res.par()) {
|
||||
if (res.par() != ownerParagraphs().end()) {
|
||||
setCursor(res.par(), res.pos(), false);
|
||||
return true;
|
||||
}
|
||||
@ -407,8 +407,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_APPENDIX: {
|
||||
Paragraph * par = cursor.par();
|
||||
bool start = !par->params().startOfAppendix();
|
||||
ParagraphList::iterator pit = cursor.par();
|
||||
bool start = !pit->params().startOfAppendix();
|
||||
|
||||
// ensure that we have only one start_of_appendix in this document
|
||||
ParagraphList::iterator tmp = ownerParagraphs().begin();
|
||||
@ -424,8 +424,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
}
|
||||
|
||||
setUndo(bv, Undo::EDIT, par, par->next());
|
||||
par->params().startOfAppendix(start);
|
||||
setUndo(bv, Undo::EDIT, &*pit, &*boost::next(pit));
|
||||
pit->params().startOfAppendix(start);
|
||||
|
||||
// we can set the refreshing parameters now
|
||||
updateCounters();
|
||||
@ -874,11 +874,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_PARAGRAPH_SPACING: {
|
||||
Paragraph * par = cursor.par();
|
||||
Spacing::Space cur_spacing = par->params().spacing().getSpace();
|
||||
ParagraphList::iterator pit = cursor.par();
|
||||
Spacing::Space cur_spacing = pit->params().spacing().getSpace();
|
||||
float cur_value = 1.0;
|
||||
if (cur_spacing == Spacing::Other)
|
||||
cur_value = par->params().spacing().getValue();
|
||||
cur_value = pit->params().spacing().getValue();
|
||||
|
||||
istringstream is(cmd.argument.c_str());
|
||||
string tmp;
|
||||
@ -908,7 +908,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
<< cmd.argument << endl;
|
||||
}
|
||||
if (cur_spacing != new_spacing || cur_value != new_value) {
|
||||
par->params().spacing(Spacing(new_spacing, new_value));
|
||||
pit->params().spacing(Spacing(new_spacing, new_value));
|
||||
redoParagraph();
|
||||
update();
|
||||
}
|
||||
@ -1123,14 +1123,14 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
if (!change_layout && selection.set() &&
|
||||
selection.start.par() != selection.end.par())
|
||||
{
|
||||
Paragraph * spar = selection.start.par();
|
||||
Paragraph * epar = selection.end.par()->next();
|
||||
while (spar != epar) {
|
||||
if (spar->layout()->name() != current_layout) {
|
||||
ParagraphList::iterator spit = selection.start.par();
|
||||
ParagraphList::iterator epit = boost::next(selection.end.par());
|
||||
while (spit != epit) {
|
||||
if (spit->layout()->name() != current_layout) {
|
||||
change_layout = true;
|
||||
break;
|
||||
}
|
||||
spar = spar->next();
|
||||
++spit;
|
||||
}
|
||||
}
|
||||
if (change_layout) {
|
||||
@ -1182,21 +1182,21 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_QUOTE: {
|
||||
Paragraph const * par = cursor.par();
|
||||
ParagraphList::iterator pit = cursor.par();
|
||||
lyx::pos_type pos = cursor.pos();
|
||||
char c;
|
||||
if (!pos)
|
||||
c = ' ';
|
||||
else if (par->isInset(pos - 1) && par->getInset(pos - 1)->isSpace())
|
||||
else if (pit->isInset(pos - 1) && pit->getInset(pos - 1)->isSpace())
|
||||
c = ' ';
|
||||
else
|
||||
c = par->getChar(pos - 1);
|
||||
c = pit->getChar(pos - 1);
|
||||
|
||||
bv->hideCursor();
|
||||
LyXLayout_ptr const & style = par->layout();
|
||||
LyXLayout_ptr const & style = pit->layout();
|
||||
|
||||
if (style->pass_thru ||
|
||||
par->getFontSettings(bv->buffer()->params,
|
||||
pit->getFontSettings(bv->buffer()->params,
|
||||
pos).language()->lang() == "hebrew" ||
|
||||
(!bv->insertInset(new InsetQuotes(c, bv->buffer()->params))))
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
|
||||
@ -1279,7 +1279,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
Inset * tli = bv->theLockingInset();
|
||||
LyXCursor cursor = bv->text->cursor;
|
||||
LyXFont font = bv->text->getFont(bv->buffer(),
|
||||
cursor.par(), cursor.pos());
|
||||
&*cursor.par(), cursor.pos());
|
||||
int width = tli->width(bv, font);
|
||||
int inset_x = font.isVisibleRightToLeft()
|
||||
? cursor.ix() - width : cursor.ix();
|
||||
|
@ -23,7 +23,7 @@ using lyx::pos_type;
|
||||
|
||||
void transposeChars(LyXText & text, LyXCursor const & cursor)
|
||||
{
|
||||
Paragraph * tmppar = cursor.par();
|
||||
Paragraph * tmppar = &*cursor.par();
|
||||
|
||||
setUndo(text.bv(), Undo::FINISH, tmppar, tmppar->next());
|
||||
|
||||
|
@ -486,6 +486,6 @@ void setRedo(BufferView * bv, Undo::undo_kind kind,
|
||||
|
||||
void setCursorParUndo(BufferView * bv)
|
||||
{
|
||||
setUndo(bv, Undo::FINISH, bv->text->cursor.par(),
|
||||
setUndo(bv, Undo::FINISH, &*bv->text->cursor.par(),
|
||||
bv->text->cursor.par()->next());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user