#include "insets/insetbib.h"
#include "insets/insetspecialchar.h"
#include "insets/insettext.h"
+#include "insets/insetfloat.h"
#include "layout.h"
#include "LyXView.h"
#include "support/textutils.h"
#include "Painter.h"
#include "font.h"
#include "debug.h"
-
-//#define USE_OLD_CUT_AND_PASTE 1
+#include "lyxrc.h"
+#include "FloatList.h"
using std::copy;
using std::endl;
using std::pair;
+
LyXText::LyXText(BufferView * bv)
{
bv_owner = bv;
lastrow = 0;
number_of_rows = 0;
refresh_y = 0;
- height = width = 0;
+ height = 0;
+ width = 0;
+ first = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position
selection = true; /* these setting is necessary
par = par->Next();
}
SetCursorIntern(bview, firstrow->par(), 0);
-#if 1
+ sel_cursor = cursor;
+#if 0
// Dump all rowinformation:
Row * tmprow = firstrow;
lyxerr << "Width = " << width << endl;
}
-#if 0
-void LyXText::owner(BufferView * bv)
-{
- if (bv_owner && bv) lyxerr << "LyXText::bv_owner already set!" << endl;
- bv_owner = bv;
-}
-#endif
-
// Gets the fully instantiated font at a given position in a paragraph
// Basically the same routine as LyXParagraph::getFont() in paragraph.C.
// The difference is that this one is used for displaying, and thus we
char par_depth = par->GetDepth();
// We specialize the 95% common case:
- if (par->footnoteflag == LyXParagraph::NO_FOOTNOTE && !par_depth) {
+ if (
+#ifndef NEW_INSETS
+ par->footnoteflag == LyXParagraph::NO_FOOTNOTE &&
+#endif
+ !par_depth) {
if (pos >= 0){
// 95% goes here
if (layout.labeltype == LABEL_MANUAL
tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+#ifndef NEW_INSETS
// Cosmetic improvement: If this is an open footnote, make the font
// smaller.
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
tmpfont.decSize();
}
-
+#endif
return tmpfont;
}
layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+#ifndef NEW_INSETS
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
layoutfont.decSize();
}
-
+#endif
// Now, reduce font against full layout font
font.reduce(layoutfont);
AppendParagraph(bview, row->next());
}
}
-
+
+#ifndef NEW_INSETS
void LyXText::ToggleFootnote(BufferView * bview)
{
LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos());
CloseFootnote(bview);
}
}
+#endif
+#ifndef NEW_INSETS
void LyXText::OpenStuff(BufferView * bview)
{
if (cursor.pos() == 0 && cursor.par()->bibkey){
cursor.par()->bibkey->Edit(bview, 0, 0, 0);
- }
- else if (cursor.pos() < cursor.par()->Last()
+ } else if (cursor.pos() < cursor.par()->Last()
&& cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos())->Editable()) {
bview->owner()->getMiniBuffer()
if (cursor.par()->GetInset(cursor.pos())->Editable() != Inset::HIGHLY_EDITABLE)
SetCursorParUndo(bview->buffer());
cursor.par()->GetInset(cursor.pos())->Edit(bview, 0, 0, 0);
- } else {
+ }
+#ifndef NEW_INSETS
+ else {
ToggleFootnote(bview);
}
+#endif
}
+#endif
+#ifndef NEW_INSETS
void LyXText::CloseFootnote(BufferView * bview)
{
LyXParagraph * tmppar;
if (cursor.row()->next())
SetHeightOfRow(bview, cursor.row()->next());
}
+#endif
/* used in setlayout */
// Asger is not sure we want to do this...
-void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, LyXParagraph * par)
+void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf,
+ LyXParagraph * par)
{
LyXLayout const & layout =
}
}
+
LyXParagraph * LyXText::SetLayout(BufferView * bview,
LyXCursor & cur, LyXCursor & sstart_cur,
LyXCursor & send_cur,
LyXTextClass::size_type layout)
{
+#ifndef NEW_INSETS
LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->Next();
+#else
+ LyXParagraph * endpar = send_cur.par()->Next();
+#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
undoendpar = endpar;
}
} else if (endpar) {
}
SetUndo(bview->buffer(), Undo::EDIT,
- sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous,
+#ifndef NEW_INSETS
+ sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous,
+#else
+ sstart_cur.par()->previous,
+#endif
undoendpar);
/* ok we have a selection. This is always between sstart_cur
textclasslist.Style(bview->buffer()->params.textclass, layout);
while (cur.par() != send_cur.par()) {
+#ifndef NEW_INSETS
if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) {
+#endif
cur.par()->SetLayout(bview->buffer()->params, layout);
MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
+#ifndef NEW_INSETS
LyXParagraph * fppar = cur.par()->FirstPhysicalPar();
+#else
+ LyXParagraph * fppar = cur.par();
+#endif
fppar->added_space_top = lyxlayout.fill_top ?
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
fppar->added_space_bottom = lyxlayout.fill_bottom ?
delete fppar->bibkey;
fppar->bibkey = 0;
}
+#ifndef NEW_INSETS
}
+#endif
cur.par(cur.par()->Next());
}
+#ifndef NEW_INSETS
if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) {
+#endif
cur.par()->SetLayout(bview->buffer()->params, layout);
MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
+#ifndef NEW_INSETS
LyXParagraph * fppar = cur.par()->FirstPhysicalPar();
+#else
+ LyXParagraph * fppar = cur.par();
+#endif
fppar->added_space_top = lyxlayout.fill_top ?
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
fppar->added_space_bottom = lyxlayout.fill_bottom ?
delete fppar->bibkey;
fppar->bibkey = 0;
}
+#ifndef NEW_INSETS
}
+#endif
return endpar;
}
// set layout over selection and make a total rebreak of those paragraphs
void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)
{
- LyXCursor
- tmpcursor = cursor; /* store the current cursor */
+ LyXCursor tmpcursor = cursor; /* store the current cursor */
-#ifdef USE_OLD_SET_LAYOUT
- // if there is no selection just set the layout
- // of the current paragraph */
- if (!selection) {
- sel_start_cursor = cursor; // dummy selection
- sel_end_cursor = cursor;
- }
-
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
- LyXParagraph * undoendpar = endpar;
-
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
- endpar = endpar->LastPhysicalPar()->Next();
- undoendpar = endpar;
- }
- }
- else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
- }
-
- SetUndo(Undo::EDIT,
- sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous,
- undoendpar);
-
- /* ok we have a selection. This is always between sel_start_cursor
- * and sel_end cursor */
- cursor = sel_start_cursor;
-
- LyXLayout const & lyxlayout =
- textclasslist.Style(bview->buffer()->params.textclass, layout);
-
- while (cursor.par() != sel_end_cursor.par()) {
- if (cursor.par()->footnoteflag ==
- sel_start_cursor.par()->footnoteflag) {
- cursor.par()->SetLayout(layout);
- MakeFontEntriesLayoutSpecific(cursor.par());
- LyXParagraph* fppar = cursor.par()->FirstPhysicalPar();
- fppar->added_space_top = lyxlayout.fill_top ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- fppar->added_space_bottom = lyxlayout.fill_bottom ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- if (lyxlayout.margintype == MARGIN_MANUAL)
- cursor.par()->SetLabelWidthString(lyxlayout.labelstring());
- if (lyxlayout.labeltype != LABEL_BIBLIO
- && fppar->bibkey) {
- delete fppar->bibkey;
- fppar->bibkey = 0;
- }
- }
- cursor.par() = cursor.par()->Next();
- }
- if (cursor.par()->footnoteflag ==
- sel_start_cursor.par()->footnoteflag) {
- cursor.par()->SetLayout(layout);
- MakeFontEntriesLayoutSpecific(cursor.par());
- LyXParagraph* fppar = cursor.par()->FirstPhysicalPar();
- fppar->added_space_top = lyxlayout.fill_top ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- fppar->added_space_bottom = lyxlayout.fill_bottom ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- if (lyxlayout.margintype == MARGIN_MANUAL)
- cursor.par()->SetLabelWidthString(lyxlayout.labelstring());
- if (lyxlayout.labeltype != LABEL_BIBLIO
- && fppar->bibkey) {
- delete fppar->bibkey;
- fppar->bibkey = 0;
- }
- }
-#else
// if there is no selection just set the layout
// of the current paragraph */
if (!selection) {
LyXParagraph *
endpar = SetLayout(bview, cursor, sel_start_cursor,
sel_end_cursor, layout);
-#endif
RedoParagraphs(bview, sel_start_cursor, endpar);
// we have to reset the selection, because the
- // geometry could have changed */
+ // geometry could have changed
SetCursor(bview, sel_start_cursor.par(),
sel_start_cursor.pos(), false);
sel_cursor = cursor;
}
// We end at the next paragraph with depth 0
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar =
+#ifndef NEW_INSETS
+ sel_end_cursor.par()->LastPhysicalPar()->Next();
+#else
+ sel_end_cursor.par()->Next();
+#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
undoendpar = endpar;
}
}
endpar = endpar->Next(); // because of parindents etc.
}
- SetUndo(bview->buffer(), Undo::EDIT,
+ SetUndo(bview->buffer(), Undo::EDIT,
+#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous,
+#else
+ sel_start_cursor.par()->previous,
+#endif
undoendpar);
LyXCursor tmpcursor = cursor; // store the current cursor
while (true) {
// NOTE: you can't change the depth of a bibliography entry
- if (cursor.par()->footnoteflag ==
- sel_start_cursor.par()->footnoteflag
- && textclasslist.Style(bview->buffer()->params.textclass,
+ if (
+#ifndef NEW_INSETS
+ cursor.par()->footnoteflag ==
+ sel_start_cursor.par()->footnoteflag &&
+#endif
+ textclasslist.Style(bview->buffer()->params.textclass,
cursor.par()->GetLayout()
).labeltype != LABEL_BIBLIO) {
LyXParagraph * prev =
+#ifndef NEW_INSETS
cursor.par()->FirstPhysicalPar()->Previous();
+#else
+ cursor.par()->Previous();
+#endif
if (prev
&& (prev->GetDepth() - cursor.par()->GetDepth() > 0
|| (prev->GetDepth() == cursor.par()->GetDepth()
&& textclasslist.Style(bview->buffer()->params.textclass,
prev->GetLayout()).isEnvironment()))) {
+#ifndef NEW_INSETS
cursor.par()->FirstPhysicalPar()->depth++;
+#else
+ cursor.par()->depth++;
+#endif
anything_changed = true;
}
}
if (!anything_changed) {
cursor = sel_start_cursor;
while (cursor.par() != sel_end_cursor.par()) {
+#ifndef NEW_INSETS
cursor.par()->FirstPhysicalPar()->depth = 0;
+#else
+ cursor.par()->depth = 0;
+#endif
cursor.par(cursor.par()->Next());
}
+#ifndef NEW_INSETS
if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag)
cursor.par()->FirstPhysicalPar()->depth = 0;
+#else
+ cursor.par()->depth = 0;
+#endif
}
RedoParagraphs(bview, sel_start_cursor, endpar);
sel_start_cursor = cursor; // dummy selection
sel_end_cursor = cursor;
}
-
+#ifndef NEW_INSETS
LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+#else
+ LyXParagraph * endpar = sel_end_cursor.par()->Next();
+#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
undoendpar = endpar;
}
}
endpar = endpar->Next(); // because of parindents etc.
}
- SetUndo(bview->buffer(), Undo::EDIT,
+ SetUndo(bview->buffer(), Undo::EDIT,
+#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous,
+#else
+ sel_start_cursor.par()->previous,
+#endif
undoendpar);
LyXCursor tmpcursor = cursor; // store the current cursor
cursor = sel_start_cursor;
while (true) {
+#ifndef NEW_INSETS
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
if (cursor.par()->FirstPhysicalPar()->depth)
cursor.par()->FirstPhysicalPar()->depth--;
}
+#else
+ if (cursor.par()->depth)
+ cursor.par()->depth--;
+#endif
if (cursor.par() == sel_end_cursor.par())
break;
cursor.par(cursor.par()->Next());
// ok we have a selection. This is always between sel_start_cursor
// and sel_end cursor
- SetUndo(bview->buffer(), Undo::EDIT,
+ SetUndo(bview->buffer(), Undo::EDIT,
+#ifndef NEW_INSETS
sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous,
- sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next);
+ sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next
+#else
+ sel_start_cursor.par()->previous,
+ sel_end_cursor.par()->next
+#endif
+ );
cursor = sel_start_cursor;
while (cursor.par() != sel_end_cursor.par() ||
- (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag
- && cursor.pos() < sel_end_cursor.pos()))
+ (
+#ifndef NEW_INSETS
+ cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag &&
+#endif
+ cursor.pos() < sel_end_cursor.pos()))
{
if (cursor.pos() < cursor.par()->Last()
+#ifndef NEW_INSETS
&& cursor.par()->footnoteflag
- == sel_start_cursor.par()->footnoteflag) {
+ == sel_start_cursor.par()->footnoteflag
+#endif
+ ) {
// an open footnote should behave
// like a closed one
LyXFont newfont = GetFont(bview->buffer(),
long y = cur.y() - tmprow->baseline();
SetHeightOfRow(bview, tmprow);
+#ifndef NEW_INSETS
LyXParagraph * first_phys_par = tmprow->par()->FirstPhysicalPar();
+#else
+ LyXParagraph * first_phys_par = tmprow->par();
+#endif
// find the first row of the paragraph
if (first_phys_par != tmprow->par())
while (tmprow->previous()
long y = cur.y() - tmprow->baseline();
SetHeightOfRow(bview, tmprow);
+#ifndef NEW_INSETS
LyXParagraph * first_phys_par = tmprow->par()->FirstPhysicalPar();
+#else
+ LyXParagraph * first_phys_par = tmprow->par();
+#endif
// find the first row of the paragraph
if (first_phys_par != tmprow->par())
while (tmprow->previous() && tmprow->previous()->par() != first_phys_par) {
if (!tmprow->previous()){
first_phys_par = FirstParagraph(); // a trick/hack for UNDO
} else {
+#ifndef NEW_INSETS
first_phys_par = tmprow->par()->FirstPhysicalPar();
+#else
+ first_phys_par = tmprow->par();
+#endif
// find the first row of the paragraph
if (first_phys_par != tmprow->par())
while (tmprow->previous() &&
}
-void LyXText::ToggleFree(BufferView * bview, LyXFont const & font, bool toggleall)
+void LyXText::ToggleFree(BufferView * bview,
+ LyXFont const & font, bool toggleall)
{
// If the mask is completely neutral, tell user
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
LyXParagraph::size_type
-LyXText::BeginningOfMainBody(Buffer const * buf, LyXParagraph const * par) const
+LyXText::BeginningOfMainBody(Buffer const * buf,
+ LyXParagraph const * par) const
{
if (textclasslist.Style(buf->params.textclass,
par->GetLayout()).labeltype != LABEL_MANUAL)
}
+#ifndef NEW_INSETS
/* if there is a selection, reset every environment you can find
* in the selection, otherwise just the environment you are in */
void LyXText::MeltFootnoteEnvironment(BufferView * bview)
ClearSelection();
}
+#endif
/* the DTP switches for paragraphs. LyX will store them in the
}
// make sure that the depth behind the selection are restored, too
+#ifndef NEW_INSETS
LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+#else
+ LyXParagraph * endpar = sel_end_cursor.par()->Next();
+#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
undoendpar = endpar;
}
}
endpar = endpar->Next(); // because of parindents etc.
}
- SetUndo(bview->buffer(), Undo::EDIT,
+ SetUndo(bview->buffer(), Undo::EDIT,
+#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous,
+#else
+ sel_start_cursor.par()->previous,
+#endif
undoendpar);
LyXParagraph * tmppar = sel_end_cursor.par();
+#ifndef NEW_INSETS
while (tmppar != sel_start_cursor.par()->FirstPhysicalPar()->Previous()) {
SetCursor(bview, tmppar->FirstPhysicalPar(), 0);
+#else
+ while (tmppar != sel_start_cursor.par()->Previous()) {
+ SetCursor(bview, tmppar, 0);
+#endif
status = LyXText::NEED_MORE_REFRESH;
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
+#ifndef NEW_INSETS
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
+#endif
cursor.par()->line_top = line_top;
cursor.par()->line_bottom = line_bottom;
cursor.par()->pagebreak_top = pagebreak_top;
}
cursor.par()->SetLabelWidthString(labelwidthstring);
cursor.par()->noindent = noindent;
+#ifndef NEW_INSETS
}
tmppar = cursor.par()->FirstPhysicalPar()->Previous();
+#else
+ tmppar = cursor.par()->Previous();
+#endif
}
RedoParagraphs(bview, sel_start_cursor, endpar);
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
+ if (inset_owner)
+ bview->updateInset(inset_owner, true);
}
}
// make sure that the depth behind the selection are restored, too
+#ifndef NEW_INSETS
LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+#else
+ LyXParagraph * endpar = sel_end_cursor.par()->Next();
+#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
undoendpar = endpar;
}
}
endpar = endpar->Next(); // because of parindents etc.
}
- SetUndo(bview->buffer(), Undo::EDIT,
+ SetUndo(bview->buffer(), Undo::EDIT,
+#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous,
+#else
+ sel_start_cursor.par()->previous,
+#endif
undoendpar);
tmppar = sel_end_cursor.par();
+#ifndef NEW_INSETS
while(tmppar != sel_start_cursor.par()->FirstPhysicalPar()->Previous()) {
SetCursor(bview, tmppar->FirstPhysicalPar(), 0);
+#else
+ while(tmppar != sel_start_cursor.par()->Previous()) {
+ SetCursor(bview, tmppar, 0);
+#endif
status = LyXText::NEED_MORE_REFRESH;
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
+#ifndef NEW_INSETS
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
+#endif
if (type == LyXParagraph::PEXTRA_NONE) {
if (cursor.par()->pextra_type != LyXParagraph::PEXTRA_NONE) {
cursor.par()->UnsetPExtraType(bview->buffer()->params);
cursor.par()->pextra_start_minipage = start_minipage;
cursor.par()->pextra_alignment = alignment;
}
- }
+#ifndef NEW_INSETS
+ }
tmppar = cursor.par()->FirstPhysicalPar()->Previous();
+#else
+ tmppar = cursor.par()->Previous();
+#endif
}
RedoParagraphs(bview, sel_start_cursor, endpar);
ClearSelection();
return 'a' + n - 1;
}
+
char alphaCounter(int n)
{
if (n < 1 || n > 26)
return 'A' + n - 1;
}
+
char hebrewCounter(int n)
{
static const char hebrew[22] = {
return hebrew[n-1];
}
-static char const * romanCounter(int n)
+
+static
+char const * romanCounter(int n)
{
static char const * roman[20] = {
"i", "ii", "iii", "iv", "v",
return roman[n-1];
}
+
// set the counter of a paragraph. This includes the labels
void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const
{
+#ifndef NEW_INSETS
// this is only relevant for the beginning of paragraph
par = par->FirstPhysicalPar();
-
+#endif
LyXLayout const & layout =
textclasslist.Style(buf->params.textclass,
par->GetLayout());
/* copy the prev-counters to this one, unless this is the start of a
footnote or of a bibliography or the very first paragraph */
if (par->Previous()
+#ifndef NEW_INSETS
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
+#endif
&& !(textclasslist.Style(buf->params.textclass,
par->Previous()->GetLayout()
).labeltype != LABEL_BIBLIO
for (int i = 0; i < 10; ++i) {
par->setCounter(i, par->Previous()->GetFirstCounter(i));
}
+#ifndef NEW_INSETS
par->appendix = par->Previous()->FirstPhysicalPar()->appendix;
+#else
+ par->appendix = par->Previous()->appendix;
+#endif
if (!par->appendix && par->start_of_appendix){
par->appendix = true;
for (int i = 0; i < 10; ++i) {
par->setCounter(i, 0);
}
}
+#ifndef NEW_INSETS
par->enumdepth = par->Previous()->FirstPhysicalPar()->enumdepth;
par->itemdepth = par->Previous()->FirstPhysicalPar()->itemdepth;
- }
- else {
+#else
+ par->enumdepth = par->Previous()->enumdepth;
+ par->itemdepth = par->Previous()->itemdepth;
+#endif
+ } else {
for (int i = 0; i < 10; ++i) {
par->setCounter(i, 0);
}
par->itemdepth = 0;
}
+#ifndef NEW_INSETS
// if this is an open marginnote and this is the first
// entry in the marginnote and the enclosing
// environment is an enum/item then correct for the
par->enumdepth++;
par->itemdepth++;
}
-
+#endif
/* Maybe we have to increment the enumeration depth.
* BUT, enumeration in a footnote is considered in isolation from its
* surrounding paragraph so don't increment if this is the
par->Previous()->GetLayout()
).labeltype == LABEL_COUNTER_ENUMI
&& par->enumdepth < 3
+#ifndef NEW_INSETS
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
+#endif
&& layout.labeltype != LABEL_BIBLIO) {
par->enumdepth++;
}
/* Maybe we have to decrement the enumeration depth, see note above */
if (par->Previous()
&& par->Previous()->GetDepth() > par->GetDepth()
+#ifndef NEW_INSETS
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
+#endif
&& layout.labeltype != LABEL_BIBLIO) {
par->enumdepth = par->DepthHook(par->GetDepth())->enumdepth;
par->setCounter(6 + par->enumdepth,
}
/* is it a layout that has an automatic label ? */
- if (layout.labeltype >= LABEL_FIRST_COUNTER) {
+ if (layout.labeltype >= LABEL_COUNTER_CHAPTER) {
- int i = layout.labeltype - LABEL_FIRST_COUNTER;
+ int i = layout.labeltype - LABEL_COUNTER_CHAPTER;
if (i >= 0 && i<= buf->params.secnumdepth) {
par->incCounter(i); // increment the counter
ostrstream s;
#endif
if (!par->appendix) {
- switch (2 * LABEL_FIRST_COUNTER -
+ switch (2 * LABEL_COUNTER_CHAPTER -
textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
s << par->getCounter(i);
break;
default:
+ // Can this ever be reached? And in the
+ // case it is, how can this be correct?
+ // (Lgb)
s << par->getCounter(i) << '.';
break;
}
} else { // appendix
- switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) {
+ switch (2 * LABEL_COUNTER_CHAPTER - textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i));
// Can this ever be reached? And in the
// case it is, how can this be correct?
// (Lgb)
- s << static_cast<unsigned char>(par->getCounter(i)) << '.';
+ s << par->getCounter(i) << '.';
break;
}
}
} else if (layout.labeltype == LABEL_BIBLIO) {// ale970302
- int i = LABEL_COUNTER_ENUMI - LABEL_FIRST_COUNTER + par->enumdepth;
+ int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth;
par->incCounter(i);
int number = par->getCounter(i);
- if (!par->bibkey)
- par->bibkey = new InsetBibKey();
+ if (!par->bibkey) {
+ InsetCommandParams p( "bibitem" );
+ par->bibkey = new InsetBibKey(p);
+ }
par->bibkey->setCounter(number);
par->labelstring = layout.labelstring();
string s = layout.labelstring();
// the caption hack:
-
if (layout.labeltype == LABEL_SENSITIVE) {
+ bool isOK (par->InInset() && par->InInset()->owner() &&
+ (par->InInset()->owner()->LyxCode() == Inset::FLOAT_CODE));
+#ifndef NEW_INSETS
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& (par->footnotekind == LyXParagraph::FIG
- || par->footnotekind == LyXParagraph::WIDE_FIG))
+ || par->footnotekind == LyXParagraph::WIDE_FIG)) {
s = (par->getParLanguage(buf->params)->lang() == "hebrew")
? ":øåéà " : "Figure:";
- else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
+ } else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& (par->footnotekind == LyXParagraph::TAB
- || par->footnotekind == LyXParagraph::WIDE_TAB))
+ || par->footnotekind == LyXParagraph::WIDE_TAB)) {
s = (par->getParLanguage(buf->params)->lang() == "hebrew")
? ":äìáè" : "Table:";
- else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
- && par->footnotekind == LyXParagraph::ALGORITHM)
+ } else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
+ && par->footnotekind == LyXParagraph::ALGORITHM) {
s = (par->getParLanguage(buf->params)->lang() == "hebrew")
? ":Ãúéøåâìà " : "Algorithm:";
- else {
+ } else
+#endif
+ if (isOK) {
+ InsetFloat * tmp = static_cast<InsetFloat*>(par->InInset()->owner());
+ Floating const & fl
+ = floatList.getType(tmp->type());
+ // We should get the correct number here too.
+ s = fl.name + " #:";
+ } else {
/* par->SetLayout(0);
s = layout->labelstring; */
s = (par->getParLanguage(buf->params)->lang() == "hebrew")
if (!row) {
row = firstrow;
par = row->par();
- }
- else {
+ } else {
if (row->par()->next
- && row->par()->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) {
+#ifndef NEW_INSETS
+ && row->par()->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
+#endif
+ ) {
+#ifndef NEW_INSETS
par = row->par()->LastPhysicalPar()->Next();
+#else
+ par = row->par()->Next();
+#endif
} else {
par = row->par()->next;
}
/* now check for the headline layouts. remember that they
* have a dynamic left margin */
- if (!par->IsDummy()
- && ( textclasslist.Style(bview->buffer()->params.textclass,
+ if (
+#ifndef NEW_INSETS
+ !par->IsDummy() &&
+#endif
+ ( textclasslist.Style(bview->buffer()->params.textclass,
par->layout).margintype == MARGIN_DYNAMIC
|| textclasslist.Style(bview->buffer()->params.textclass,
par->layout).labeltype == LABEL_SENSITIVE)
/* Rebreak the paragraph */
RemoveParagraph(row);
AppendParagraph(bview, row);
-
+
+#ifndef NEW_INSETS
/* think about the damned open footnotes! */
while (par->Next() &&
(par->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
AppendParagraph(bview, row);
}
}
+#endif
}
-
+#ifndef NEW_INSETS
par = par->LastPhysicalPar()->Next();
+#else
+ par = par->Next();
+#endif
}
}
/* insets an inset. */
-void LyXText::InsertInset(BufferView * bview, Inset *inset)
+void LyXText::InsertInset(BufferView * bview, Inset * inset)
{
if (!cursor.par()->InsertInsetAllowed(inset))
return;
- SetUndo(bview->buffer(), Undo::INSERT,
+ SetUndo(bview->buffer(), Undo::INSERT,
+#ifndef NEW_INSETS
cursor.par()->ParFromPos(cursor.pos())->previous,
- cursor.par()->ParFromPos(cursor.pos())->next);
- cursor.par()->InsertChar(cursor.pos(), LyXParagraph::META_INSET);
+ cursor.par()->ParFromPos(cursor.pos())->next
+#else
+ cursor.par()->previous,
+ cursor.par()->next
+#endif
+ );
cursor.par()->InsertInset(cursor.pos(), inset);
InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a
// OK, we have a selection. This is always between sel_start_cursor
// and sel_end cursor
- LyXParagraph * tmppar;
-
+#ifndef NEW_INSETS
// Check whether there are half footnotes in the selection
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
|| sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- tmppar = sel_start_cursor.par();
+ LyXParagraph * tmppar = sel_start_cursor.par();
while (tmppar != sel_end_cursor.par()){
if (tmppar->footnoteflag != sel_end_cursor.par()->footnoteflag) {
WriteAlert(_("Impossible operation"),
tmppar = tmppar->Next();
}
}
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table) {
/* table stuff -- end */
#endif
// make sure that the depth behind the selection are restored, too
+#ifndef NEW_INSETS
LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+#else
+ LyXParagraph * endpar = sel_end_cursor.par()->Next();
+#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
undoendpar = endpar;
}
} else if (endpar) {
endpar = endpar->Next(); // because of parindents etc.
}
- SetUndo(bview->buffer(), Undo::DELETE, sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous, undoendpar);
+ SetUndo(bview->buffer(), Undo::DELETE,
+#ifndef NEW_INSETS
+ sel_start_cursor
+ .par()->ParFromPos(sel_start_cursor.pos())->previous,
+#else
+ sel_start_cursor.par()->previous,
+#endif
+ undoendpar);
CutAndPaste cap;
// there are two cases: cut only within one paragraph or
// more than one paragraph
+#ifndef NEW_INSETS
if (sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())
- == sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())) {
+ == sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos()))
+#else
+ if (sel_start_cursor.par() == sel_end_cursor.par())
+#endif
+ {
// only within one paragraph
endpar = sel_start_cursor.par();
int pos = sel_end_cursor.pos();
// ok we have a selection. This is always between sel_start_cursor
// and sel_end cursor
- LyXParagraph * tmppar;
-
+
+#ifndef NEW_INSETS
/* check wether there are half footnotes in the selection */
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
|| sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- tmppar = sel_start_cursor.par();
+ LyXParagraph * tmppar = sel_start_cursor.par();
while (tmppar != sel_end_cursor.par()) {
if (tmppar->footnoteflag !=
sel_end_cursor.par()->footnoteflag) {
tmppar = tmppar->Next();
}
}
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){
if (!cap.checkPastePossible(cursor.par(), cursor.pos()))
return;
- SetUndo(bview->buffer(), Undo::INSERT,
+ SetUndo(bview->buffer(), Undo::INSERT,
+#ifndef NEW_INSETS
cursor.par()->ParFromPos(cursor.pos())->previous,
- cursor.par()->ParFromPos(cursor.pos())->next);
+ cursor.par()->ParFromPos(cursor.pos())->next
+#else
+ cursor.par()->previous,
+ cursor.par()->next
+#endif
+ );
LyXParagraph * endpar;
LyXParagraph * actpar = cursor.par();
// Insert the new string
for (int i = 0; str[i]; ++i) {
- sel_end_cursor.par()->InsertChar(pos, str[i]);
- sel_end_cursor.par()->SetFont(pos, font);
+ sel_end_cursor.par()->InsertChar(pos, str[i], font);
++pos;
}
LyXParagraph * par = cursor.par();
LyXParagraph::size_type pos = cursor.pos();
LyXParagraph::size_type a = 0;
- int cell = 0;
LyXParagraph * endpar = cursor.par()->Next();
SetCursorParUndo(bview->buffer());
if (str[i] == ' '
&& i + 1 < str.length() && str[i + 1] != ' '
&& pos && par->GetChar(pos - 1)!= ' ') {
- par->InsertChar(pos,' ');
- par->SetFont(pos, current_font);
+ par->InsertChar(pos, ' ', current_font);
++pos;
-#ifndef NEW_TABLAR
+#ifndef NEW_TABULAR
} else if (par->table) {
if (str[i] == '\t') {
while((pos < par->size()) &&
break;
} else if ((str[i] != 13) &&
((str[i] & 127) >= ' ')) {
- par->InsertChar(pos, str[i]);
- par->SetFont(pos, current_font);
+ par->InsertChar(pos, str[i],
+ current_font);
++pos;
}
#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
+ par->InsertInset(pos, new_inset,
+ current_font);
} else {
delete new_inset;
}
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
+ par->InsertInset(pos, new_inset,
+ current_font);
} else {
delete new_inset;
}
} else if (str[i] != 13 &&
// Ignore unprintables
(str[i] & 127) >= ' ') {
- par->InsertChar(pos, str[i]);
- par->SetFont(pos, current_font);
+ par->InsertChar(pos, str[i], current_font);
++pos;
}
} else {
(par->GetChar(pos) != LyXParagraph::META_NEWLINE))
++pos;
++pos;
- cell = NumberOfCell(par, pos);
+ int cell = NumberOfCell(par, pos);
while((pos < par->size()) &&
!(par->table->IsFirstCell(cell))) {
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
+ par->InsertInset(pos,
+ new_inset,
+ current_font);
} else {
delete new_inset;
}
void LyXText::InsertStringB(BufferView * bview, string const & s)
{
string str(s);
+#ifndef NEW_TABULAR
LyXParagraph * par = cursor.par();
+#endif
string::size_type i = 1;
while (i < str.length()) {
- if (str[i] == '\t' && !par->table)
+ if (str[i] == '\t'
+#ifndef NEW_TABULAR
+ && !par->table
+#endif
+ )
str[i] = ' ';
if (str[i] == ' ' && i + 1 < str.length() && str[i + 1] == ' ')
str[i] = 13;
- if (str[i] == '\n' && i + 1 < str.length() && !par->table){
+ if (str[i] == '\n' && i + 1 < str.length()
+#ifndef NEW_TABULAR
+ && !par->table
+#endif
+ ){
if (str[i + 1] != '\n') {
if (str[i - 1] != ' ')
str[i] = ' ';
LyXParagraph * par = FirstParagraph();
do {
+#ifndef NEW_INSETS
// make sure the paragraph is open
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
+#endif
pos = par->GetPositionOfInset(inset);
if (pos != -1){
CheckParagraph(bview, par, pos);
return true;
}
+#ifndef NEW_INSETS
}
+#endif
par = par->Next();
} while (par);
void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par,
LyXParagraph::size_type pos, bool boundary) const
{
+#ifndef NEW_INSETS
// correct the cursor position if impossible
if (pos > par->Last()){
LyXParagraph * tmppar = par->ParFromPos(pos);
}
pos += par->size() + 1;
}
-
+#endif
cur.par(par);
cur.pos(pos);
cur.boundary(boundary);
cursor_vpos = (row->par()->isRightToLeftPar(bview->buffer()->params))
? row->pos() : last + 1;
else if (pos > row->pos() &&
- (pos > last || boundary ||
- (row->par()->table && row->par()->IsNewline(pos))))
+ (pos > last || boundary
+#ifndef NEW_TABULAR
+ || (row->par()->table && row->par()->IsNewline(pos))
+#endif
+ ))
/// Place cursor after char at (logical) position pos - 1
cursor_vpos = (bidi_level(pos - 1) % 2 == 0)
? log2vis(pos - 1) + 1 : log2vis(pos - 1);
bool setfont, bool boundary) const
{
SetCursor(bview, cursor, par, pos, boundary);
-// #warning Remove this when verified working (Jug 20000413)
-#if 0
- // correct the cursor position if impossible
- if (pos > par->Last()){
- LyXParagraph * tmppar = par->ParFromPos(pos);
- pos = par->PositionInParFromPos(pos);
- par = tmppar;
- }
- if (par->IsDummy() && par->previous &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
- while (par->previous &&
- ((par->previous->IsDummy() && par->previous->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) ||
- (par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))) {
- par = par->previous ;
- if (par->IsDummy() &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
- pos += par->size() + 1;
- }
- if (par->previous) {
- par = par->previous;
- }
- pos += par->size() + 1;
- }
-
- cursor.par() = par;
- cursor.pos() = pos;
-
- /* get the cursor y position in text */
- long y = 0;
- Row * row = GetRow(par, pos, y);
- /* y is now the beginning of the cursor row */
- y += row->baseline();
- /* y is now the cursor baseline */
- cursor.y() = y;
-
- /* now get the cursors x position */
- float x;
- float fill_separator, fill_hfill, fill_label_hfill;
- PrepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill);
- LyXParagraph::size_type cursor_vpos;
- LyXParagraph::size_type last = RowLastPrintable(row);
-
- if (pos > last + 1) // This shouldn't happen.
- pos = last+1;
-
- if (last < row->pos())
- cursor_vpos = 0;
- else if (pos > last ||
- (pos - 1 >= row->pos() &&
- (row->par()->IsSeparator(pos) ||
- (row->par()->table && row->par()->IsNewline(pos))
- )))
- /// Place cursor after char at (logical) position pos-1
- cursor_vpos = (bidi_level(pos-1) % 2 == 0)
- ? log2vis(pos-1) + 1 : log2vis(pos-1);
- else
- /// Place cursor before char at (logical) position pos
- cursor_vpos = (bidi_level(pos) % 2 == 0)
- ? log2vis(pos) : log2vis(pos) + 1;
-
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
- if (row->par()->table) {
- int cell = NumberOfCell(row->par(), row->pos());
- float x_old = x;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- for (LyXParagraph::size_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (row->par()->IsNewline(pos)) {
- x = x_old + row->par()->table->WidthOfColumn(cell);
- x_old = x;
- ++cell;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- } else {
- x += SingleWidth(row->par(), pos);
- }
- }
- } else {
- /* table stuff -- end*/
-#endif
- LyXParagraph::size_type main_body =
- BeginningOfMainBody(row->par());
- if (main_body > 0 &&
- (main_body-1 > last ||
- !row->par()->IsLineSeparator(main_body-1)))
- main_body = 0;
-
- for (LyXParagraph::size_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (main_body > 0 && pos == main_body-1) {
- x += fill_label_hfill +
- lyxfont::width(textclasslist
- .Style(bview->buffer()->params.textclass,
- row->par()->GetLayout())
- .labelsep,
- GetFont(row->par(), -2));
- if (row->par()->IsLineSeparator(main_body-1))
- x -= SingleWidth(row->par(), main_body-1);
- }
- if (HfillExpansion(row, pos)) {
- x += SingleWidth(row->par(), pos);
- if (pos >= main_body)
- x += fill_hfill;
- else
- x += fill_label_hfill;
- }
- else if (row->par()->IsSeparator(pos)) {
- x += SingleWidth(row->par(), pos);
- if (pos >= main_body)
- x += fill_separator;
- } else
- x += SingleWidth(row->par(), pos);
- }
-#ifndef NEW_TABULAR
- }
-#endif
- cursor.x = int(x);
-
- cursor.x_fix = cursor.x;
- cursor.row() = row;
-#endif
if (setfont)
SetCurrentFont(bview);
}
--pos;
if (pos > 0) {
- if (pos == cursor.par()->Last() ||
- (cursor.par()->table && cursor.par()->IsNewline(pos)))
+ if (pos == cursor.par()->Last()
+#ifndef NEW_TABULAR
+ || (cursor.par()->table && cursor.par()->IsNewline(pos))
+#endif
+ )
--pos;
else if (cursor.par()->IsSeparator(pos)) {
if (pos > cursor.row()->pos() &&
}
}
- current_font = cursor.par()->GetFontSettings(bview->buffer()->params, pos);
+ current_font =
+ cursor.par()->GetFontSettings(bview->buffer()->params, pos);
real_current_font = GetFont(bview->buffer(), cursor.par(), pos);
+
+ if (cursor.pos() == cursor.par()->Last() &&
+ IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) &&
+ !cursor.boundary()) {
+ Language const * lang =
+ cursor.par()->getParLanguage(bview->buffer()->params);
+ current_font.setLanguage(lang);
+ real_current_font.setLanguage(lang);
+ }
}
SetCursor(bview, cursor.par(), cursor.pos() + 1, true, true);
} else if (cursor.par()->Previous()) { // steps into the above paragraph.
LyXParagraph * par = cursor.par()->Previous();
- LyXParagraph::size_type pos = par->Last();
- SetCursor(bview, par, pos);
- if (IsBoundary(bview->buffer(), par, pos))
- SetCursor(bview, par, pos, false, true);
+ SetCursor(bview, par, par->Last());
}
}
void LyXText::CursorRightIntern(BufferView * bview, bool internal) const
{
- if (cursor.pos() < cursor.par()->Last()) {
- if (!internal && cursor.boundary() &&
- (!cursor.par()->table || !cursor.par()->IsNewline(cursor.pos())))
- SetCursor(bview, cursor.par(), cursor.pos(), true, false);
- else {
- SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false);
- if (!internal && IsBoundary(bview->buffer(), cursor.par(), cursor.pos()))
- SetCursor(bview, cursor.par(), cursor.pos(), true, true);
- }
+ if (!internal && cursor.boundary() &&
+ (
+#ifndef NEW_TABULAR
+ !cursor.par()->table ||
+#endif
+ !cursor.par()->IsNewline(cursor.pos())))
+ SetCursor(bview, cursor.par(), cursor.pos(), true, false);
+ else if (cursor.pos() < cursor.par()->Last()) {
+ SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false);
+ if (!internal &&
+ IsBoundary(bview->buffer(), cursor.par(), cursor.pos()))
+ SetCursor(bview, cursor.par(), cursor.pos(), true, true);
} else if (cursor.par()->Next())
SetCursor(bview, cursor.par()->Next(), 0);
}
if ( (old_cursor.par()->Last() == 0
|| (old_cursor.par()->Last() == 1
&& old_cursor.par()->IsLineSeparator(0)))
+#ifndef NEW_INSETS
&& old_cursor.par()->FirstPhysicalPar()
- == old_cursor.par()->LastPhysicalPar()) {
+ == old_cursor.par()->LastPhysicalPar()
+#endif
+ ) {
// ok, we will delete anything
// make sure that you do not delete any environments
- if ((old_cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE &&
+#ifndef NEW_INSETS
+ if ((
+ old_cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE &&
!(old_cursor.row()->previous()
&& old_cursor.row()->previous()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
&& !(old_cursor.row()->next()
|| (old_cursor.row()->next()
&& old_cursor.row()->next()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE))
)) {
+#endif
status = LyXText::NEED_MORE_REFRESH;
deleted = true;
LyXParagraph * endpar = old_cursor.par()->next;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
}
}
SetUndo(bview->buffer(), Undo::DELETE,
LyXParagraph * endpar = old_cursor.par()->next;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
+#ifndef NEW_INSETS
endpar = endpar->LastPhysicalPar()->Next();
+#else
+ endpar = endpar->Next();
+#endif
}
}
SetUndo(bview->buffer(), Undo::DELETE,
// correct selection
sel_cursor = cursor;
}
+#ifndef NEW_INSETS
}
+#endif
}
if (!deleted) {
if (old_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass)) {
else
OwnerParagraph(tmppar3);
tmppar3->previous = before;
- }
- else {
+ } else {
if (!before)
OwnerParagraph(behind);
}
// Set the cursor for redoing
if (before) {
+#ifndef NEW_INSETS
SetCursorIntern(bview, before->FirstSelfrowPar(), 0);
+#else
+ SetCursorIntern(bview, before, 0);
+#endif
+#ifndef NEW_INSETS
// check wether before points to a closed float and open it if necessary
if (before && before->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE
&& before->next && before->next->footnoteflag != LyXParagraph::NO_FOOTNOTE){
tmppar4 = tmppar4->next;
}
}
+#endif
}
-
+
+#ifndef NEW_INSETS
// open a cosed footnote at the end if necessary
if (behind && behind->previous &&
behind->previous->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
behind = behind->next;
}
}
+#endif
// calculate the endpar for redoing the paragraphs.
if (behind) {
+#ifndef NEW_INSETS
if (behind->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE)
endpar = behind->LastPhysicalPar()->Next();
else
endpar = behind->NextAfterFootnote()->LastPhysicalPar()->Next();
+#else
+ endpar = behind->Next();
+#endif
} else
endpar = behind;
tmppar2->next = 0;
} else
undopar = 0; // nothing to replace (undo of delete maybe)
-
+
+#ifndef NEW_INSETS
int cursor_par = cursor.par()->ParFromPos(cursor.pos())->id();
int cursor_pos = cursor.par()->PositionInParFromPos(cursor.pos());
+#else
+ int cursor_par = cursor.par()->id();
+ int cursor_pos = cursor.pos();
+#endif
Undo * undo = new Undo(kind,
before_number, behind_number,
{
if (inset_owner)
return;
- SetUndo(buf, Undo::FINISH,
+ SetUndo(buf, Undo::FINISH,
+#ifndef NEW_INSETS
cursor.par()->ParFromPos(cursor.pos())->previous,
- cursor.par()->ParFromPos(cursor.pos())->next);
+ cursor.par()->ParFromPos(cursor.pos())->next
+#else
+ cursor.par()->previous,
+ cursor.par()->next
+#endif
+ );
}
void LyXText::toggleAppendix(BufferView * bview)
{
+#ifndef NEW_INSETS
LyXParagraph * par = cursor.par()->FirstPhysicalPar();
+#else
+ LyXParagraph * par = cursor.par();
+#endif
bool start = !par->start_of_appendix;
// ensure that we have only one start_of_appendix in this document
SetCursor(bview, cursor.par(), cursor.pos());
}
+
LyXParagraph * LyXText::OwnerParagraph() const
{
if (inset_owner)